Use structured custom fields in entry editor
This commit is contained in:
+40
-2
@@ -908,7 +908,10 @@ func TestUICreatesEntryWithAllSupportedEditorFields(t *testing.T) {
|
||||
u.entryNotes.SetText("Registrar account")
|
||||
u.entryTags.SetText("dns, registrar")
|
||||
u.entryPath.SetText("Root / Internet")
|
||||
u.entryFields.SetText("Environment=prod\nAccount ID=12345")
|
||||
u.setCustomFieldRows(map[string]string{
|
||||
"Environment": "prod",
|
||||
"Account ID": "12345",
|
||||
})
|
||||
|
||||
if err := u.saveEntryAction(); err != nil {
|
||||
t.Fatalf("saveEntryAction() create error = %v", err)
|
||||
@@ -937,6 +940,41 @@ func TestUICreatesEntryWithAllSupportedEditorFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUILoadSelectedEntryIntoEditorPopulatesStructuredCustomFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{
|
||||
ID: "gitlab",
|
||||
Title: "Gitlab",
|
||||
Path: []string{"Root", "Internet"},
|
||||
Fields: map[string]string{
|
||||
"AndroidApp1": "androidapp://com.gitlab.android",
|
||||
"OTP": "123456",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
u.showEntriesSection()
|
||||
u.state.NavigateToPath([]string{"Root", "Internet"})
|
||||
u.filter()
|
||||
u.state.SelectedEntryID = "gitlab"
|
||||
u.loadSelectedEntryIntoEditor()
|
||||
|
||||
if len(u.customFieldKeys) != 2 || len(u.customFieldValues) != 2 {
|
||||
t.Fatalf("custom field rows = %d/%d, want 2 rows", len(u.customFieldKeys), len(u.customFieldValues))
|
||||
}
|
||||
|
||||
got := map[string]string{}
|
||||
for i := range u.customFieldKeys {
|
||||
got[u.customFieldKeys[i].Text()] = u.customFieldValues[i].Text()
|
||||
}
|
||||
if got["AndroidApp1"] != "androidapp://com.gitlab.android" || got["OTP"] != "123456" {
|
||||
t.Fatalf("custom field rows = %#v, want AndroidApp1 and OTP values", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIEditingEntryPathMovesEntryBetweenGroups(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1145,7 +1183,7 @@ func TestUITemplatesCanBeBrowsedCreatedEditedDeletedAndInstantiated(t *testing.T
|
||||
u.state.SelectedEntryID = "tpl-web"
|
||||
u.loadSelectedEntryIntoEditor()
|
||||
u.entryTitle.SetText("Website Login Updated")
|
||||
u.entryFields.SetText("Environment=prod")
|
||||
u.setCustomFieldRows(map[string]string{"Environment": "prod"})
|
||||
if err := u.saveTemplateAction(); err != nil {
|
||||
t.Fatalf("saveTemplateAction(edit) error = %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user