Improve KeePassGO vault navigation UX

This commit is contained in:
Joe Julian
2026-03-29 15:18:14 -07:00
parent 4a629c16bd
commit d492743eb1
4 changed files with 187 additions and 33 deletions
+47
View File
@@ -1694,6 +1694,53 @@ func TestUIRequiresExplicitEditModeForEntryEditor(t *testing.T) {
}
}
func TestUIAutoEntersSingleVaultRootGroupAndDisplaysSlashRoot(t *testing.T) {
t.Parallel()
path := filepath.Join(t.TempDir(), "keepass.kdbx")
var encoded bytes.Buffer
if err := vault.SaveKDBX(&encoded, vault.Model{
Entries: []vault.Entry{
{ID: "git-server", Title: "Git Server", Path: []string{"keepass", "Joe", "Internet"}},
},
}, "correct horse battery staple"); err != nil {
t.Fatalf("SaveKDBX() error = %v", err)
}
if err := os.WriteFile(path, encoded.Bytes(), 0o600); err != nil {
t.Fatalf("WriteFile(keepass.kdbx) error = %v", err)
}
u := newUIWithSession("desktop", &session.Manager{})
u.masterPassword.SetText("correct horse battery staple")
u.vaultPath.SetText(path)
if err := u.openVaultAction(); err != nil {
t.Fatalf("openVaultAction() error = %v", err)
}
if got := u.currentPath; !slices.Equal(got, []string{"keepass"}) {
t.Fatalf("currentPath = %v, want [keepass]", got)
}
if got := u.displayPath(); len(got) != 0 {
t.Fatalf("displayPath() = %v, want root slash path", got)
}
if got := u.childGroups(); !slices.Equal(got, []string{"Joe"}) {
t.Fatalf("childGroups() = %v, want [Joe]", got)
}
}
func TestUINoteRecentVaultDeduplicatesAndOrdersMostRecentFirst(t *testing.T) {
t.Parallel()
u := newUIWithSession("desktop", &session.Manager{})
u.noteRecentVault("/tmp/one.kdbx")
u.noteRecentVault("/tmp/two.kdbx")
u.noteRecentVault("/tmp/one.kdbx")
if got := u.recentVaults; !slices.Equal(got, []string{"/tmp/one.kdbx", "/tmp/two.kdbx"}) {
t.Fatalf("recentVaults = %v, want [/tmp/one.kdbx /tmp/two.kdbx]", got)
}
}
func TestUICopyActionsWriteExpectedClipboardContentsAndSanitizedFeedback(t *testing.T) {
t.Parallel()