test: add regression test for issue-only fields in FieldsToEditSurvey
Verifies Type and Parent only appear in the interactive picker when Allowed is explicitly set. Prevents regression where issue-only fields leak into gh pr edit's interactive mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
2a72a59f76
commit
4a196ddf1d
1 changed files with 35 additions and 0 deletions
|
|
@ -260,3 +260,38 @@ func TestTitleSurvey(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFieldsToEditSurvey_IssueOnlyFields(t *testing.T) {
|
||||
t.Run("without Allowed flags omits Type and Parent", func(t *testing.T) {
|
||||
pm := prompter.NewMockPrompter(t)
|
||||
pm.RegisterMultiSelect("What would you like to edit?", []string{},
|
||||
// Type and Parent should NOT appear here
|
||||
[]string{"Title", "Body", "Assignees", "Labels", "Projects", "Milestone"},
|
||||
func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{0}, nil
|
||||
})
|
||||
|
||||
editable := &Editable{}
|
||||
err := FieldsToEditSurvey(pm, editable)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, editable.Title.Edited)
|
||||
})
|
||||
|
||||
t.Run("with Allowed flags includes Type and Parent", func(t *testing.T) {
|
||||
pm := prompter.NewMockPrompter(t)
|
||||
pm.RegisterMultiSelect("What would you like to edit?", []string{},
|
||||
// Type and Parent should appear between Labels and Projects
|
||||
[]string{"Title", "Body", "Assignees", "Labels", "Type", "Parent", "Projects", "Milestone"},
|
||||
func(_ string, _, _ []string) ([]int, error) {
|
||||
return []int{4, 5}, nil // select Type and Parent
|
||||
})
|
||||
|
||||
editable := &Editable{}
|
||||
editable.IssueType.Allowed = true
|
||||
editable.Parent.Allowed = true
|
||||
err := FieldsToEditSurvey(pm, editable)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, editable.IssueType.Edited)
|
||||
assert.True(t, editable.Parent.Edited)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue