feat: improve textbox editor behaviour
This commit is contained in:
@@ -68,19 +68,23 @@ func TestTargetBranchCompletionIsKeyboardFirst(t *testing.T) {
|
||||
m = updated.(App)
|
||||
updated, _ = m.updatePREditInput(tea.KeyMsg{Type: tea.KeyTab})
|
||||
m = updated.(App)
|
||||
if got := m.prEditEditors[prEditBaseField].Text; got != "release" {
|
||||
t.Fatalf("tab unexpectedly completed selected branch: %q", got)
|
||||
}
|
||||
if m.prEditField != prEditReviewersField {
|
||||
t.Fatalf("tab did not advance from target branch: field=%d", m.prEditField)
|
||||
}
|
||||
|
||||
m.prEditField = prEditBaseField
|
||||
updated, _ = m.updatePREditInput(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
m = updated.(App)
|
||||
if got := m.prEditEditors[prEditBaseField].Text; got != "release/2.0" &&
|
||||
got != "release/1.0" {
|
||||
t.Fatalf("tab did not complete selected branch: %q", got)
|
||||
t.Fatalf("enter did not complete selected branch: %q", got)
|
||||
}
|
||||
if m.prEditField != prEditBaseField {
|
||||
t.Fatalf("completion moved away from target branch: field=%d", m.prEditField)
|
||||
}
|
||||
|
||||
updated, _ = m.updatePREditInput(tea.KeyMsg{Type: tea.KeyTab})
|
||||
m = updated.(App)
|
||||
if m.prEditField != prEditReviewersField {
|
||||
t.Fatalf("second tab did not advance: field=%d", m.prEditField)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTargetBranchSuggestionsRenderAndValidationRejectsUnknownBranch(t *testing.T) {
|
||||
@@ -94,7 +98,7 @@ func TestTargetBranchSuggestionsRenderAndValidationRejectsUnknownBranch(t *testi
|
||||
m.prEditBranches = []RepositoryBranch{{Name: "main"}, {Name: "release/2.0"}}
|
||||
|
||||
view := ansi.Strip(strings.Join(m.prEditFieldLines("target branch", prEditBaseField, 80), "\n"))
|
||||
if !strings.Contains(view, "release/2.0") || !strings.Contains(view, "tab / enter complete") {
|
||||
if !strings.Contains(view, "release/2.0") || !strings.Contains(view, "enter complete") {
|
||||
t.Fatalf("branch suggestions missing:\n%s", view)
|
||||
}
|
||||
if err := m.validatePREdit(); err == nil || !strings.Contains(err.Error(), "not an available") {
|
||||
|
||||
Reference in New Issue
Block a user