Limit group view to direct entries

This commit is contained in:
Joe Julian
2026-04-03 08:51:19 -07:00
parent da53696435
commit 198732239a
4 changed files with 27 additions and 37 deletions
+1 -1
View File
@@ -302,7 +302,7 @@ func (s *State) VisibleEntries() ([]vault.Entry, error) {
}
if s.Section == SectionEntries {
return model.EntriesUnderPath(s.CurrentPath), nil
return entriesInPath(model.Entries, s.CurrentPath), nil
}
if s.Section == SectionRecycleBin || len(s.CurrentPath) == 0 {
return entries, nil
+6 -5
View File
@@ -44,13 +44,14 @@ func TestVisibleEntriesFollowsCurrentPathWithoutSearch(t *testing.T) {
}
}
func TestVisibleEntriesIncludesDescendantEntriesAtParentGroup(t *testing.T) {
func TestVisibleEntriesAtParentGroupOnlyShowsDirectEntries(t *testing.T) {
t.Parallel()
state := State{
Session: stubSession{
model: vault.Model{
Entries: []vault.Entry{
{ID: "joe-note", Title: "Joe Note", Path: []string{"Joe"}},
{ID: "dynadot", Title: "Dynadot", Path: []string{"Joe", "Internet"}},
{ID: "git-server", Title: "Git Server", Path: []string{"Joe", "Internet"}},
{ID: "ha-codex", Title: "Home Assistant (Codex)", Path: []string{"Joe", "Home Assistant"}},
@@ -69,8 +70,8 @@ func TestVisibleEntriesIncludesDescendantEntriesAtParentGroup(t *testing.T) {
for _, entry := range got {
titles = append(titles, entry.Title)
}
if !slices.Equal(titles, []string{"Dynadot", "Git Server", "Home Assistant (Codex)"}) {
t.Fatalf("visible titles = %v, want descendant entries from Joe", titles)
if !slices.Equal(titles, []string{"Joe Note"}) {
t.Fatalf("visible titles = %v, want only direct entries from Joe", titles)
}
}
@@ -220,8 +221,8 @@ func TestVisibleEntriesReturnsDescendantsAfterClearingSearch(t *testing.T) {
if err != nil {
t.Fatalf("VisibleEntries() after clearing search error = %v", err)
}
if len(got) != 3 {
t.Fatalf("len(VisibleEntries()) after clearing search = %d, want 3 descendant entries", len(got))
if len(got) != 0 {
t.Fatalf("len(VisibleEntries()) after clearing search = %d, want 0 direct entries at Joe", len(got))
}
}