Repository: cli/cli
File: pkg/cmd/agent-task/create/create_test.go (Go)

Code before:
				Prompter: &prompter.PrompterMock{
					MarkdownEditorFunc: func(prompt, defaultValue string, blankAllowed bool) (string, error) {
						require.Equal(t, "Enter the task description", prompt)
						return "From editor", nil
					},
					ConfirmFunc: func(message string, defaultValue bool) (bool, error) {
						require.Equal(t, "Submit agent task", message)
						return false, nil
					},
				},
			},
			isTTY:      true,
			wantErr:    "SilentError",
			wantStdErr: "",
		},
		{
			name:  "interactively entering task description with editor, no file",
			isTTY: true,
			opts: &CreateOptions{
				BaseRepo: func() (ghrepo.Interface, error) {
					return ghrepo.New("OWNER", "REPO"), nil
				},
				ProblemStatement: "",
				Prompter: &prompter.PrompterMock{
					MarkdownEditorFunc: func(prompt, defaultValue string, blankAllowed bool) (string, error) {
						require.Equal(t, "Enter the task description", prompt)
						return "From editor", nil
					},
					ConfirmFunc: func(message string, defaultValue bool) (bool, error) {
						require.Equal(t, "Submit agent task", message)
						return true, nil
					},
				},
			},
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.CreateJobFunc = func(ctx context.Context, owner, repo, problemStatement, baseBranch string) (*capi.Job, error) {
					require.Equal(t, "From editor", problemStatement)
					return &createdJobSuccessWithPR, nil
				}
			},
			wantStdout: "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n",
		},
		{
			name:  "empty task description from interactive prompt returns error",
			isTTY: true,
			opts: &CreateOptions{
				BaseRepo: func() (ghrepo.Interface, error) {
					return ghrepo.New("OWNER", "REPO"), nil
				},
				Prompter: &prompter.PrompterMock{
					MarkdownEditorFunc: func(prompt, defaultValue string, blankAllowed bool) (string, error) {

Review comment (suggestion):
I think we also need another test case for a non-empty arg.

```go
		{
			name: "problem statement loaded from arg non-interactively doesn't prompt or return error",
			opts: &CreateOptions{
				BaseRepo:             func() (ghrepo.Interface, error) { return ghrepo.New("OWNER", "REPO"), nil },
				ProblemStatement:     "task description",
			},
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.CreateJobFunc = func(ctx context.Context, owner, repo, problemStatement, baseBranch string) (*capi.Job, error) {
					require.Equal(t, "OWNER", owner)
					require.Equal(t, "REPO", repo)
					require.Equal(t, "task description", problemStatement)
					return &createdJobSuccessWithPR, nil
				}
			},
			wantStdout: "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n",
		},
```

Code after:
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.CreateJobFunc = func(ctx context.Context, owner, repo, problemStatement, baseBranch string) (*capi.Job, error) {
					require.Equal(t, "From editor", problemStatement)
					return &createdJobSuccessWithPR, nil
				}
			},
			wantStdout: "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n",
		},
		{
			name:  "empty task description from interactive prompt returns error",
			isTTY: true,
			opts: &CreateOptions{
				BaseRepo: func() (ghrepo.Interface, error) {
					return ghrepo.New("OWNER", "REPO"), nil
				},
				Prompter: &prompter.PrompterMock{
					MarkdownEditorFunc: func(prompt, defaultValue string, blankAllowed bool) (string, error) {
						return "   ", nil
					},
				},
			},
			wantErr:    "SilentError",
			wantErrIs:  cmdutil.SilentError,
			wantStdErr: "a task description is required.\n",
		},
		{
			name: "problem statement loaded from file non-interactively doesn't prompt or return error",
			opts: &CreateOptions{
				BaseRepo:             func() (ghrepo.Interface, error) { return ghrepo.New("OWNER", "REPO"), nil },
				ProblemStatement:     "",
				ProblemStatementFile: taskDescFile,
			},
			capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
				m.CreateJobFunc = func(ctx context.Context, owner, repo, problemStatement, baseBranch string) (*capi.Job, error) {
					require.Equal(t, "OWNER", owner)
					require.Equal(t, "REPO", repo)
					require.Equal(t, "task description from file", problemStatement)
					return &createdJobSuccessWithPR, nil
				}
			},
			wantStdout: "https://github.com/OWNER/REPO/pull/42/agent-sessions/sess1\n",
		},
		{
			name: "missing repo returns error",
			opts: &CreateOptions{
				BaseRepo: func() (ghrepo.Interface, error) {
					return nil, nil
				}},
			wantErr: "a repository is required; re-run in a repository or supply one with --repo owner/name",
		},
		{