Fix entry and group navigation workflows

This commit is contained in:
Joe Julian
2026-04-01 10:24:57 -07:00
parent 69aa72ee3b
commit b9ecd0ae70
8 changed files with 389 additions and 8 deletions
+67
View File
@@ -1231,6 +1231,73 @@ func TestUIGroupControlsCanBeCollapsed(t *testing.T) {
}
}
func TestUIParentGroupShowsDescendantEntries(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{
Entries: []vault.Entry{
{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"}},
},
})
u.showEntriesSection()
u.state.NavigateToPath([]string{"Joe"})
u.filter()
if got := u.filteredTitles(); !slices.Equal(got, []string{"Dynadot", "Git Server", "Home Assistant (Codex)"}) {
t.Fatalf("filteredTitles() = %v, want descendant entries under Joe", got)
}
}
func TestUICreateGroupActionSupportsNestedSubgroups(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{})
u.showEntriesSection()
u.state.NavigateToPath([]string{"Root"})
u.groupName.SetText("Infrastructure / Prod")
if err := u.createGroupAction(); err != nil {
t.Fatalf("createGroupAction() error = %v", err)
}
if got := u.state.Session.(*uiSession).model.ChildGroups([]string{"Root"}); !slices.Equal(got, []string{"Infrastructure"}) {
t.Fatalf("ChildGroups(Root) = %v, want [Infrastructure]", got)
}
if got := u.state.Session.(*uiSession).model.ChildGroups([]string{"Root", "Infrastructure"}); !slices.Equal(got, []string{"Prod"}) {
t.Fatalf("ChildGroups(Root/Infrastructure) = %v, want [Prod]", got)
}
}
func TestUIMoveCurrentGroupActionMovesHierarchy(t *testing.T) {
t.Parallel()
model := vault.Model{
Entries: []vault.Entry{
{ID: "git-server", Title: "Git Server", Path: []string{"Root", "Internet"}},
},
}
model.CreateGroup([]string{"Root", "Internet"}, "Infrastructure")
u := newUIWithModel("desktop", model)
u.showEntriesSection()
u.setCurrentPath([]string{"Root", "Internet"})
u.groupParentPath.SetText("Root / Joe")
if err := u.moveCurrentGroupAction(); err != nil {
t.Fatalf("moveCurrentGroupAction() error = %v", err)
}
if !slices.Equal(u.state.CurrentPath, []string{"Root", "Joe", "Internet"}) {
t.Fatalf("state.CurrentPath = %v, want [Root Joe Internet]", u.state.CurrentPath)
}
got := u.state.Session.(*uiSession).model.EntriesInPath([]string{"Root", "Joe", "Internet"})
if len(got) != 1 || got[0].ID != "git-server" {
t.Fatalf("EntriesInPath(Root/Joe/Internet) = %#v, want moved git-server entry", got)
}
}
func TestUISavingEntryWithDifferentPathMovesItBetweenGroups(t *testing.T) {
t.Parallel()