diff --git a/pkg/cmd/pr/shared/survey_test.go b/pkg/cmd/pr/shared/survey_test.go index 384e54895..5b84548a2 100644 --- a/pkg/cmd/pr/shared/survey_test.go +++ b/pkg/cmd/pr/shared/survey_test.go @@ -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) + }) +}