Add lifecycle remote sync shortcut

This commit is contained in:
Joe Julian
2026-04-06 21:56:29 -07:00
parent 332ab58f58
commit 739d918c21
3 changed files with 213 additions and 1 deletions
+136
View File
@@ -5988,6 +5988,45 @@ func TestUIRemoteSyncSetupShortcutLabelUsesClearLanguage(t *testing.T) {
}
}
func TestUILifecycleRemoteSyncActionLabelUsesSetupLanguageWithoutSavedBinding(t *testing.T) {
t.Parallel()
u := newUIWithSession("desktop", &session.Manager{})
u.vaultPath.SetText("/vaults/family.kdbx")
if !u.shouldShowLifecycleRemoteSyncAction() {
t.Fatal("shouldShowLifecycleRemoteSyncAction() = false, want true with a selected vault")
}
if got := u.lifecycleRemoteSyncActionLabel(); got != "Open Vault And Set Up Remote Sync" {
t.Fatalf("lifecycleRemoteSyncActionLabel() = %q, want setup label", got)
}
}
func TestUILifecycleRemoteSyncActionLabelUsesSettingsLanguageWithSavedBinding(t *testing.T) {
t.Parallel()
dir := t.TempDir()
u := newUIWithSession("desktop", &session.Manager{}, statePaths{
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
})
u.vaultPath.SetText("/vaults/family.kdbx")
u.recentRemotes = []recentRemoteRecord{{
BaseURL: "https://dav.example.invalid/remote.php/dav",
Path: "files/family/keepass.kdbx",
LocalVaultPath: "/vaults/family.kdbx",
RemoteProfileID: "family-webdav",
CredentialEntryID: "remote-creds-1",
SyncMode: string(appstate.SyncModeManual),
}}
if got := u.lifecycleRemoteSyncActionLabel(); got != "Open Vault And Open Remote Sync Settings" {
t.Fatalf("lifecycleRemoteSyncActionLabel() = %q, want settings label", got)
}
}
func TestUIShouldShowRemoteSyncSettingsShortcutForSavedBinding(t *testing.T) {
t.Parallel()
@@ -6110,6 +6149,103 @@ func TestUIOpenRemoteSyncSetupDialogPrefillsCurrentVaultSetupFlow(t *testing.T)
}
}
func TestUILifecycleRemoteSyncActionOpensSetupAfterVaultOpen(t *testing.T) {
t.Parallel()
key := vault.MasterKey{Password: "correct horse battery staple"}
path := filepath.Join(t.TempDir(), "family.kdbx")
writeKDBXMainTestFile(t, path, vault.Model{
Entries: []vault.Entry{{
ID: "vault-console",
Title: "Vault Console",
Username: "dannyocean",
Password: "bellagio-pass-1",
URL: "https://vault.crew.example.invalid",
Path: []string{"Root", "Internet"},
}},
}, key)
u := newUIWithSession("desktop", &session.Manager{})
u.masterPassword.SetText(key.Password)
u.vaultPath.SetText(path)
u.pendingLifecycleOpenIntent = lifecycleOpenIntentRemoteSyncSetup
if err := u.openVaultAction(); err != nil {
t.Fatalf("openVaultAction() error = %v", err)
}
if !u.syncDialogOpen {
t.Fatal("syncDialogOpen = false, want remote sync setup dialog")
}
if got := u.syncDialogTitle(); got != "Set Up Remote Sync" {
t.Fatalf("syncDialogTitle() = %q, want Set Up Remote Sync", got)
}
}
func TestUILifecycleRemoteSyncActionOpensSettingsAfterVaultOpen(t *testing.T) {
t.Parallel()
key := vault.MasterKey{Password: "correct horse battery staple"}
path := filepath.Join(t.TempDir(), "family.kdbx")
writeKDBXMainTestFile(t, path, vault.Model{
Entries: []vault.Entry{
{
ID: "vault-console",
Title: "Vault Console",
Username: "dannyocean",
Password: "bellagio-pass-1",
URL: "https://vault.crew.example.invalid",
Path: []string{"Root", "Internet"},
},
{
ID: "remote-creds-1",
Title: "Bellagio WebDAV Sign-In",
Username: "linuscaldwell",
Password: "bellagio-pass-1",
URL: "https://dav.example.invalid/remote.php/dav",
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",
}},
}, key)
dir := t.TempDir()
u := newUIWithSession("desktop", &session.Manager{}, statePaths{
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
})
u.masterPassword.SetText(key.Password)
u.vaultPath.SetText(path)
u.recentRemotes = []recentRemoteRecord{{
BaseURL: "https://dav.example.invalid/remote.php/dav",
Path: "files/family/keepass.kdbx",
LocalVaultPath: path,
RemoteProfileID: "family-webdav",
CredentialEntryID: "remote-creds-1",
SyncMode: string(appstate.SyncModeManual),
}}
u.pendingLifecycleOpenIntent = lifecycleOpenIntentRemoteSyncSettings
if err := u.openVaultAction(); err != nil {
t.Fatalf("openVaultAction() error = %v", err)
}
if !u.syncDialogOpen {
t.Fatal("syncDialogOpen = false, want remote sync settings dialog")
}
if got := u.syncDialogTitle(); got != "Remote Sync Settings" {
t.Fatalf("syncDialogTitle() = %q, want Remote Sync Settings", got)
}
}
func TestUISelectedLocalVaultRemoteSyncSummaryMentionsSetup(t *testing.T) {
t.Parallel()