Simplify single-choice saved remote sync UI
This commit is contained in:
@@ -5169,6 +5169,80 @@ func TestUISelectVaultRemoteCredentialEntryUpdatesSelection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldShowSavedRemoteBindingSelectorsWhenMultipleChoices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "remote-creds-1", Title: "Alpha Sign-In", Username: "auser", Path: []string{"Crew", "Internet"}},
|
||||
{ID: "remote-creds-2", Title: "Bravo Sign-In", Username: "buser", Path: []string{"Crew", "Internet"}},
|
||||
},
|
||||
RemoteProfiles: []vault.RemoteProfile{
|
||||
{ID: "profile-1", Name: "Bellagio Vault", Backend: vault.RemoteBackendWebDAV, BaseURL: "https://dav1.example.invalid", Path: "files/bellagio.kdbx"},
|
||||
{ID: "profile-2", Name: "Vault Console", Backend: vault.RemoteBackendWebDAV, BaseURL: "https://dav2.example.invalid", Path: "files/console.kdbx"},
|
||||
},
|
||||
})
|
||||
|
||||
if !u.shouldShowSavedRemoteBindingSelectors() {
|
||||
t.Fatal("shouldShowSavedRemoteBindingSelectors() = false, want true with multiple profiles and credentials")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldHideSavedRemoteBindingSelectorsForSingleChoice(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",
|
||||
}},
|
||||
})
|
||||
|
||||
if u.shouldShowSavedRemoteBindingSelectors() {
|
||||
t.Fatal("shouldShowSavedRemoteBindingSelectors() = true, want false with a single saved binding choice")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(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",
|
||||
}},
|
||||
})
|
||||
|
||||
profileLabel, credentialLabel, ok := u.savedRemoteBindingSummary()
|
||||
if !ok {
|
||||
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
|
||||
}
|
||||
if profileLabel != "Family Vault" {
|
||||
t.Fatalf("profileLabel = %q, want Family Vault", profileLabel)
|
||||
}
|
||||
if credentialLabel != "WebDAV Sign-In · tjulian" {
|
||||
t.Fatalf("credentialLabel = %q, want WebDAV Sign-In · tjulian", credentialLabel)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user