From 2fdbe8a7957f089575e0f8772708d0c906c9e432 Mon Sep 17 00:00:00 2001 From: Junichi Kato Date: Thu, 26 Feb 2026 01:03:15 +0900 Subject: [PATCH] =?UTF-8?q?test(e2e):=20config-priority=E3=81=AE=E6=97=A2?= =?UTF-8?q?=E5=AD=98=E4=B8=8D=E5=AE=89=E5=AE=9A=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20(#388)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/specs/config-priority.e2e.ts | 34 +++++++++++--------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/e2e/specs/config-priority.e2e.ts b/e2e/specs/config-priority.e2e.ts index 525ff36..672155f 100644 --- a/e2e/specs/config-priority.e2e.ts +++ b/e2e/specs/config-priority.e2e.ts @@ -1,8 +1,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; -import { parse as parseYaml } from 'yaml'; +import { mkdirSync, writeFileSync } from 'node:fs'; import { createIsolatedEnv, updateIsolatedConfig, type IsolatedEnv } from '../helpers/isolated-env'; import { createTestRepo, type TestRepo } from '../helpers/test-repo'; import { runTakt } from '../helpers/takt-runner'; @@ -10,17 +9,6 @@ import { runTakt } from '../helpers/takt-runner'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -function readFirstTask(repoPath: string): Record { - const tasksPath = join(repoPath, '.takt', 'tasks.yaml'); - const raw = readFileSync(tasksPath, 'utf-8'); - const parsed = parseYaml(raw) as { tasks?: Array> } | null; - const first = parsed?.tasks?.[0]; - if (!first) { - throw new Error(`No task record found in ${tasksPath}`); - } - return first; -} - // E2E更新時は docs/testing/e2e.md も更新すること describe('E2E: Config priority (piece / autoPr)', () => { let isolatedEnv: IsolatedEnv; @@ -94,10 +82,10 @@ describe('E2E: Config priority (piece / autoPr)', () => { timeout: 240_000, }); - // PR creation fails in test env (no gh remote), so exit code 1 is expected - // when auto_pr defaults to true. The task record is still persisted. - const task = readFirstTask(testRepo.path); - expect(task['auto_pr']).toBe(true); + // auto_pr=true の場合は PR 作成フローに入り、テスト環境では gh 未認証のため失敗する + const output = result.stdout + result.stderr; + expect(result.exitCode).toBe(1); + expect(output).toContain('PR creation failed:'); }, 240_000); it('should use auto_pr from config when set', () => { @@ -120,9 +108,9 @@ describe('E2E: Config priority (piece / autoPr)', () => { timeout: 240_000, }); + const output = result.stdout + result.stderr; expect(result.exitCode).toBe(0); - const task = readFirstTask(testRepo.path); - expect(task['auto_pr']).toBe(false); + expect(output).not.toContain('PR creation failed:'); }, 240_000); it('should prioritize env auto_pr over config', () => { @@ -146,9 +134,9 @@ describe('E2E: Config priority (piece / autoPr)', () => { timeout: 240_000, }); - // PR creation fails in test env (no gh remote), so exit code 1 is expected - // when auto_pr is overridden to true. The task record is still persisted. - const task = readFirstTask(testRepo.path); - expect(task['auto_pr']).toBe(true); + // env override により auto_pr=true が優先され、PR 作成フローに入る + const output = result.stdout + result.stderr; + expect(result.exitCode).toBe(1); + expect(output).toContain('PR creation failed:'); }, 240_000); });