Unify open flow around local vaults
This commit is contained in:
+143
-7
@@ -4934,14 +4934,11 @@ func TestUIStartupPreselectsNewestTargetAcrossLocalAndRemote(t *testing.T) {
|
||||
|
||||
second := newUIWithSession("desktop", &session.Manager{}, paths)
|
||||
|
||||
if got := second.lifecycleMode; got != "remote" {
|
||||
t.Fatalf("lifecycleMode = %q, want remote", got)
|
||||
if got := second.lifecycleMode; got != "local" {
|
||||
t.Fatalf("lifecycleMode = %q, want local", got)
|
||||
}
|
||||
if got := second.remoteBaseURL.Text(); got != "https://dav.example.com" {
|
||||
t.Fatalf("remoteBaseURL = %q, want https://dav.example.com", got)
|
||||
}
|
||||
if got := second.remotePath.Text(); got != "vaults/home.kdbx" {
|
||||
t.Fatalf("remotePath = %q, want vaults/home.kdbx", got)
|
||||
if got := second.vaultPath.Text(); got != "/tmp/local.kdbx" {
|
||||
t.Fatalf("vaultPath = %q, want /tmp/local.kdbx", got)
|
||||
}
|
||||
if got := second.remoteUsername.Text(); got != "" {
|
||||
t.Fatalf("remoteUsername = %q, want empty for location-only recent remote", got)
|
||||
@@ -5422,6 +5419,31 @@ func TestRestoreStartupLifecycleTargetSelectsMostRecentLocalVault(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestoreStartupLifecycleTargetUsesLocalCacheFromRecentRemote(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.lifecycleMode = "remote"
|
||||
u.vaultPath.SetText("")
|
||||
u.recentVaults = []string{"/tmp/older.kdbx"}
|
||||
u.recentVaultUsedAt["/tmp/older.kdbx"] = time.Date(2026, time.April, 5, 1, 2, 3, 0, time.UTC)
|
||||
u.recentRemotes = []recentRemoteRecord{{
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
LocalVaultPath: "/tmp/family-cache.kdbx",
|
||||
UsedAt: time.Date(2026, time.April, 5, 2, 2, 3, 0, time.UTC).Format(time.RFC3339Nano),
|
||||
}}
|
||||
|
||||
u.restoreStartupLifecycleTarget()
|
||||
|
||||
if got := u.lifecycleMode; got != "local" {
|
||||
t.Fatalf("lifecycleMode after restore = %q, want local", got)
|
||||
}
|
||||
if got := u.vaultPath.Text(); got != "/tmp/family-cache.kdbx" {
|
||||
t.Fatalf("vaultPath after restore = %q, want /tmp/family-cache.kdbx", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShowLocalVaultChooser(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -5795,6 +5817,120 @@ func TestUIDirectRemoteSyncShortcutLabelUsesSyncLanguage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldShowRemoteSyncSetupShortcutForOpenedLocalVaultWithoutSavedBinding(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "entry-1",
|
||||
Title: "Vault Console",
|
||||
Path: []string{"Crew", "Internet"},
|
||||
}},
|
||||
})
|
||||
u.state.Section = appstate.SectionEntries
|
||||
|
||||
if !u.shouldShowRemoteSyncSetupShortcut() {
|
||||
t.Fatal("shouldShowRemoteSyncSetupShortcut() = false, want true for opened local vault without saved binding")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldHideRemoteSyncSetupShortcutWhenSavedBindingExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "remote-creds-1",
|
||||
Title: "WebDAV Sign-In",
|
||||
Username: "tjulian",
|
||||
Path: []string{"Crew", "Internet"},
|
||||
}},
|
||||
RemoteProfiles: []vault.RemoteProfile{{
|
||||
ID: "family-webdav",
|
||||
Name: "Family Vault",
|
||||
Backend: vault.RemoteBackendWebDAV,
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
}},
|
||||
})
|
||||
u.state.Section = appstate.SectionEntries
|
||||
|
||||
if u.shouldShowRemoteSyncSetupShortcut() {
|
||||
t.Fatal("shouldShowRemoteSyncSetupShortcut() = true, want false when saved binding already exists")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteSyncSetupShortcutLabelUsesClearLanguage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
|
||||
if got := u.remoteSyncSetupShortcutLabel(); got != "Set Up Remote Sync" {
|
||||
t.Fatalf("remoteSyncSetupShortcutLabel() = %q, want Set Up Remote Sync", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenRemoteSyncSetupDialogPrefillsCurrentVaultSetupFlow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "remote-creds-1",
|
||||
Title: "WebDAV Sign-In",
|
||||
Username: "tjulian",
|
||||
Password: "token-1",
|
||||
Path: []string{"Crew", "Internet"},
|
||||
}},
|
||||
RemoteProfiles: []vault.RemoteProfile{{
|
||||
ID: "family-webdav",
|
||||
Name: "Family Vault",
|
||||
Backend: vault.RemoteBackendWebDAV,
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
}},
|
||||
})
|
||||
u.vaultPath.SetText("/vaults/family.kdbx")
|
||||
|
||||
u.openRemoteSyncSetupDialog()
|
||||
|
||||
if !u.syncDialogOpen {
|
||||
t.Fatal("syncDialogOpen = false, want true")
|
||||
}
|
||||
if got := u.syncDialogPurpose; got != syncDialogPurposeRemoteSetup {
|
||||
t.Fatalf("syncDialogPurpose = %q, want remote setup", got)
|
||||
}
|
||||
if got := u.syncSourceMode; got != syncSourceRemote {
|
||||
t.Fatalf("syncSourceMode = %q, want remote", got)
|
||||
}
|
||||
if got := u.syncDirection; got != syncDirectionPush {
|
||||
t.Fatalf("syncDirection = %q, want push", got)
|
||||
}
|
||||
if got := u.syncLocalPath.Text(); got != "/vaults/family.kdbx" {
|
||||
t.Fatalf("syncLocalPath = %q, want current vault path", got)
|
||||
}
|
||||
if got := u.syncRemoteBaseURL.Text(); got != "https://dav.example.invalid/remote.php/dav" {
|
||||
t.Fatalf("syncRemoteBaseURL = %q, want saved remote base URL", got)
|
||||
}
|
||||
if got := u.syncRemotePath.Text(); got != "files/family/keepass.kdbx" {
|
||||
t.Fatalf("syncRemotePath = %q, want saved remote path", got)
|
||||
}
|
||||
if got := u.syncRemoteUsername.Text(); got != "tjulian" {
|
||||
t.Fatalf("syncRemoteUsername = %q, want tjulian", got)
|
||||
}
|
||||
if got := u.syncRemotePassword.Text(); got != "token-1" {
|
||||
t.Fatalf("syncRemotePassword = %q, want token-1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISelectedLocalVaultRemoteSyncSummaryMentionsSetup(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
|
||||
if got := u.selectedLocalVaultRemoteSyncSummary("/vaults/family.kdbx"); got != "Open this vault to set up a WebDAV sync target for it." {
|
||||
t.Fatalf("selectedLocalVaultRemoteSyncSummary() = %q, want setup guidance", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user