From 8edf8b02d8f039bf1d93133a69ff4bfd543555da Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:02:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=20PR=20=E3=81=A7=E3=82=82=20--pr=20=E3=81=8C=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/cli-routing-pr-resolve.test.ts | 20 ++++++++++---------- src/__tests__/pipelineExecution.test.ts | 6 ++++-- src/app/cli/routing.ts | 4 ---- src/features/pipeline/steps.ts | 4 ---- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/__tests__/cli-routing-pr-resolve.test.ts b/src/__tests__/cli-routing-pr-resolve.test.ts index 24d497a..dbc78ed 100644 --- a/src/__tests__/cli-routing-pr-resolve.test.ts +++ b/src/__tests__/cli-routing-pr-resolve.test.ts @@ -213,23 +213,23 @@ describe('PR resolution in routing', () => { mockExit.mockRestore(); }); - it('should exit with error when PR has no review comments', async () => { + it('should pass to interactive mode even when PR has no review comments', async () => { // Given mockOpts.pr = 456; const emptyPrReview = createMockPrReview({ reviews: [], comments: [] }); mockCheckCliStatus.mockReturnValue({ available: true }); mockFetchPrReviewComments.mockReturnValue(emptyPrReview); - const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => { - throw new Error('process.exit called'); - }); + // When + await executeDefaultAction(); - // When/Then - await expect(executeDefaultAction()).rejects.toThrow('process.exit called'); - expect(mockExit).toHaveBeenCalledWith(1); - expect(mockInteractiveMode).not.toHaveBeenCalled(); - - mockExit.mockRestore(); + // Then: PR title/description/files are still passed to interactive mode + expect(mockInteractiveMode).toHaveBeenCalledWith( + '/test/cwd', + expect.stringContaining('## PR #456 Review Comments:'), + expect.anything(), + undefined, + ); }); it('should not resolve issues when --pr is specified', async () => { diff --git a/src/__tests__/pipelineExecution.test.ts b/src/__tests__/pipelineExecution.test.ts index 9b2a208..4955b11 100644 --- a/src/__tests__/pipelineExecution.test.ts +++ b/src/__tests__/pipelineExecution.test.ts @@ -863,7 +863,7 @@ describe('executePipeline', () => { expect(exitCode).toBe(2); }); - it('should return exit code 2 when PR has no review comments', async () => { + it('should succeed even when PR has no review comments', async () => { mockFetchPrReviewComments.mockReturnValueOnce({ number: 456, title: 'Fix auth bug', @@ -874,6 +874,7 @@ describe('executePipeline', () => { reviews: [], files: ['src/auth.ts'], }); + mockExecuteTask.mockResolvedValueOnce(true); const exitCode = await executePipeline({ prNumber: 456, @@ -882,7 +883,8 @@ describe('executePipeline', () => { cwd: '/tmp/test', }); - expect(exitCode).toBe(2); + expect(exitCode).toBe(0); + expect(mockFormatPrReviewAsTask).toHaveBeenCalled(); }); it('should return exit code 2 when PR fetch fails', async () => { diff --git a/src/app/cli/routing.ts b/src/app/cli/routing.ts index c222c34..6519e3b 100644 --- a/src/app/cli/routing.ts +++ b/src/app/cli/routing.ts @@ -97,10 +97,6 @@ async function resolvePrInput( async () => getGitProvider().fetchPrReviewComments(prNumber), ); - if (prReview.reviews.length === 0 && prReview.comments.length === 0) { - throw new Error(`PR #${prNumber} has no review comments`); - } - return { initialInput: formatPrReviewAsTask(prReview) }; } diff --git a/src/features/pipeline/steps.ts b/src/features/pipeline/steps.ts index b4cd630..1e8bdf9 100644 --- a/src/features/pipeline/steps.ts +++ b/src/features/pipeline/steps.ts @@ -107,10 +107,6 @@ export function resolveTaskContent(options: PipelineExecutionOptions): TaskConte (provider) => provider.fetchPrReviewComments(options.prNumber!), ); if (!prReview) return undefined; - if (prReview.reviews.length === 0 && prReview.comments.length === 0) { - error(`PR #${options.prNumber} has no review comments`); - return undefined; - } const task = formatPrReviewAsTask(prReview); success(`PR #${options.prNumber} fetched: "${prReview.title}"`); return { task, prBranch: prReview.headRefName };