Add remote sync settings shortcut
This commit is contained in:
+129
@@ -5869,6 +5869,41 @@ func TestUIRemoteSyncSetupShortcutLabelUsesClearLanguage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldShowRemoteSyncSettingsShortcutForSavedBinding(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.shouldShowRemoteSyncSettingsShortcut() {
|
||||
t.Fatal("shouldShowRemoteSyncSettingsShortcut() = false, want true when a saved binding exists")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteSyncSettingsShortcutLabelUsesClearLanguage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
|
||||
if got := u.remoteSyncSettingsShortcutLabel(); got != "Remote Sync Settings" {
|
||||
t.Fatalf("remoteSyncSettingsShortcutLabel() = %q, want Remote Sync Settings", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenRemoteSyncSetupDialogPrefillsCurrentVaultSetupFlow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -5937,6 +5972,54 @@ func TestUISelectedLocalVaultRemoteSyncSummaryMentionsSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISelectedLocalVaultRemoteSyncSummaryMentionsAutomaticSync(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.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.SyncModeAutomaticOnOpenSave),
|
||||
}}
|
||||
|
||||
if got := u.selectedLocalVaultRemoteSyncSummary("/vaults/family.kdbx"); got != "Saved remote sync target: keepass.kdbx · dav.example.invalid · Syncs automatically on open and save." {
|
||||
t.Fatalf("selectedLocalVaultRemoteSyncSummary() = %q, want automatic sync guidance", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISelectedLocalVaultRemoteSyncSummaryMentionsManualSync(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.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.selectedLocalVaultRemoteSyncSummary("/vaults/family.kdbx"); got != "Saved remote sync target: keepass.kdbx · dav.example.invalid · Sync manually when you choose Use Remote Sync." {
|
||||
t.Fatalf("selectedLocalVaultRemoteSyncSummary() = %q, want manual sync guidance", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncDialogUsesRemoteSetupCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -5967,6 +6050,52 @@ func TestUISyncDialogUsesRemoteSetupCopy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncDialogUsesRemoteSettingsCopyForExistingBinding(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.state.Section = appstate.SectionEntries
|
||||
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),
|
||||
}}
|
||||
|
||||
u.openRemoteSyncSetupDialog()
|
||||
|
||||
if got := u.syncDialogTitle(); got != "Remote Sync Settings" {
|
||||
t.Fatalf("syncDialogTitle() = %q, want Remote Sync Settings", got)
|
||||
}
|
||||
if got := u.syncDialogDescription(); got != "Review or change this vault's saved WebDAV target, credentials, and sync mode." {
|
||||
t.Fatalf("syncDialogDescription() = %q, want settings guidance", got)
|
||||
}
|
||||
if got := u.syncDialogConfirmButtonLabel(); got != "Save Remote Sync Settings" {
|
||||
t.Fatalf("syncDialogConfirmButtonLabel() = %q, want Save Remote Sync Settings", got)
|
||||
}
|
||||
if u.syncSetupAutomatic.Value {
|
||||
t.Fatal("syncSetupAutomatic.Value = true, want false for an existing manual binding")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISyncDialogUsesAdvancedCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user