Fix entry and group navigation workflows

This commit is contained in:
Joe Julian
2026-04-01 10:24:57 -07:00
parent a4a5ad1579
commit 4eda211666
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: "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"}},
},
})
u.showEntriesSection()
u.state.NavigateToPath([]string{"Crew"})
u.filter()
if got := u.filteredTitles(); !slices.Equal(got, []string{"Bellagio", "Vault Console", "Surveillance Console"}) {
t.Fatalf("filteredTitles() = %v, want descendant entries under Crew", 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: "vault-console", Title: "Vault Console", 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 / Crew")
if err := u.moveCurrentGroupAction(); err != nil {
t.Fatalf("moveCurrentGroupAction() error = %v", err)
}
if !slices.Equal(u.state.CurrentPath, []string{"Root", "Crew", "Internet"}) {
t.Fatalf("state.CurrentPath = %v, want [Root Crew Internet]", u.state.CurrentPath)
}
got := u.state.Session.(*uiSession).model.EntriesInPath([]string{"Root", "Crew", "Internet"})
if len(got) != 1 || got[0].ID != "vault-console" {
t.Fatalf("EntriesInPath(Root/Crew/Internet) = %#v, want moved vault-console entry", got)
}
}
func TestUISavingEntryWithDifferentPathMovesItBetweenGroups(t *testing.T) {
t.Parallel()