test(e2e): config-priorityの既存不安定テストを修正 (#388)
This commit is contained in:
parent
e39792259e
commit
2fdbe8a795
@ -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<string, unknown> {
|
||||
const tasksPath = join(repoPath, '.takt', 'tasks.yaml');
|
||||
const raw = readFileSync(tasksPath, 'utf-8');
|
||||
const parsed = parseYaml(raw) as { tasks?: Array<Record<string, unknown>> } | 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);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user