Limit group view to direct entries

This commit is contained in:
Joe Julian
2026-04-03 08:51:19 -07:00
parent 520648e42c
commit a5397f37f8
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: "Crew Note", Path: []string{"Crew"}},
{ID: "bellagio", Title: "Bellagio", Path: []string{"Crew", "Internet"}},
{ID: "vault-console", Title: "Vault Console", Path: []string{"Crew", "Internet"}},
{ID: "surveillance-console", Title: "Surveillance Console", Path: []string{"Crew", "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{"Bellagio", "Vault Console", "Surveillance Console"}) {
t.Fatalf("visible titles = %v, want descendant entries from Crew", titles)
if !slices.Equal(titles, []string{"Crew Note"}) {
t.Fatalf("visible titles = %v, want only direct entries from Crew", 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 Crew", len(got))
}
}