Fix Android reopen crash and simplify group navigation

This commit is contained in:
Joe Julian
2026-04-02 07:28:55 -07:00
parent 7ad4759235
commit 4f54e9b6a8
3 changed files with 196 additions and 12 deletions
+119
View File
@@ -615,6 +615,125 @@ func TestUIAPITokenDetailPanelResizesPolicyRemoveClickablesAcrossTokenSelection(
_ = u.apiTokenDetailPanel(gtx)
}
func TestUILifecycleScreenWithSelectedRecentVaultDoesNotPanic(t *testing.T) {
t.Parallel()
dir := t.TempDir()
paths := statePaths{
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
SettingsPath: filepath.Join(dir, "settings.json"),
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
AutofillCachePath: filepath.Join(dir, "autofill-cache.json"),
}
first := newUIWithSession("phone", &session.Manager{}, paths)
first.noteRecentVault("/sdcard/Download/sample-vault.kdbx")
u := newUIWithSession("phone", &session.Manager{}, paths)
ops := new(op.Ops)
gtx := layout.Context{
Ops: ops,
Constraints: layout.Exact(image.Pt(1080, 2400)),
}
defer func() {
if r := recover(); r != nil {
t.Fatalf("layout() panicked with selected startup vault: %v", r)
}
}()
_ = u.layout(gtx)
}
func TestUILifecycleControlsWithSelectedRecentVaultDoesNotPanic(t *testing.T) {
t.Parallel()
dir := t.TempDir()
paths := statePaths{
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
SettingsPath: filepath.Join(dir, "settings.json"),
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
AutofillCachePath: filepath.Join(dir, "autofill-cache.json"),
}
first := newUIWithSession("phone", &session.Manager{}, paths)
first.noteRecentVault("/sdcard/Download/sample-vault.kdbx")
u := newUIWithSession("phone", &session.Manager{}, paths)
ops := new(op.Ops)
gtx := layout.Context{
Ops: ops,
Constraints: layout.Exact(image.Pt(1080, 2000)),
}
defer func() {
if r := recover(); r != nil {
t.Fatalf("lifecycleControls() panicked with selected startup vault: %v", r)
}
}()
_ = u.lifecycleControls(gtx)
}
func TestUIRecentVaultListWithSelectedRecentVaultDoesNotPanic(t *testing.T) {
t.Parallel()
dir := t.TempDir()
paths := statePaths{
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
SettingsPath: filepath.Join(dir, "settings.json"),
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
AutofillCachePath: filepath.Join(dir, "autofill-cache.json"),
}
first := newUIWithSession("phone", &session.Manager{}, paths)
first.noteRecentVault("/sdcard/Download/sample-vault.kdbx")
u := newUIWithSession("phone", &session.Manager{}, paths)
ops := new(op.Ops)
gtx := layout.Context{
Ops: ops,
Constraints: layout.Exact(image.Pt(1080, 800)),
}
defer func() {
if r := recover(); r != nil {
t.Fatalf("recentVaultList() panicked with selected startup vault: %v", r)
}
}()
_ = u.recentVaultList(gtx)
}
func TestUIPhoneGroupBarWithChildGroupsDoesNotPanic(t *testing.T) {
t.Parallel()
u := newUIWithModel("phone", vault.Model{
Groups: [][]string{
{"Crew"},
{"Crew", "Internet"},
{"Crew", "eMail"},
},
})
u.setCurrentPath([]string{"Crew"})
ops := new(op.Ops)
gtx := layout.Context{
Ops: ops,
Constraints: layout.Exact(image.Pt(1080, 700)),
}
defer func() {
if r := recover(); r != nil {
t.Fatalf("groupBar() panicked on phone with child groups: %v", r)
}
}()
_ = u.groupBar(gtx)
}
func TestUIAPIAuditSectionShowsRecordedEvents(t *testing.T) {
t.Parallel()