- E2Eテストのフィクスチャ、ヘルパー、スペックを追加 - mock/provider別のvitest設定を追加 - レビューエージェントのプロンプト改善 - TTY判定の共通化、list/confirmのnon-interactive対応 - eslint no-non-null-assertion を off に変更、未使用インポート削除
96 lines
2.7 KiB
TypeScript
96 lines
2.7 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
import { join, dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { createIsolatedEnv, type IsolatedEnv } from '../helpers/isolated-env';
|
|
import { createTestRepo, type TestRepo } from '../helpers/test-repo';
|
|
import { runTakt } from '../helpers/takt-runner';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
// E2E更新時は docs/testing/e2e.md も更新すること
|
|
describe('E2E: Add task from GitHub issue (takt add)', () => {
|
|
let isolatedEnv: IsolatedEnv;
|
|
let testRepo: TestRepo;
|
|
let issueNumber: string;
|
|
|
|
beforeEach(() => {
|
|
isolatedEnv = createIsolatedEnv();
|
|
testRepo = createTestRepo();
|
|
|
|
// Use mock provider to stabilize summarizer
|
|
writeFileSync(
|
|
join(isolatedEnv.taktDir, 'config.yaml'),
|
|
[
|
|
'provider: mock',
|
|
'model: mock-model',
|
|
'language: en',
|
|
'log_level: info',
|
|
'default_piece: default',
|
|
].join('\n'),
|
|
);
|
|
|
|
const createOutput = execFileSync(
|
|
'gh',
|
|
[
|
|
'issue', 'create',
|
|
'--title', 'E2E Add Issue',
|
|
'--body', 'Add task via issue for E2E',
|
|
'--repo', testRepo.repoName,
|
|
],
|
|
{ encoding: 'utf-8' },
|
|
);
|
|
|
|
const match = createOutput.match(/\/issues\/(\d+)/);
|
|
if (!match?.[1]) {
|
|
throw new Error(`Failed to extract issue number from: ${createOutput}`);
|
|
}
|
|
issueNumber = match[1];
|
|
});
|
|
|
|
afterEach(() => {
|
|
try {
|
|
execFileSync('gh', ['issue', 'close', issueNumber, '--repo', testRepo.repoName], { stdio: 'pipe' });
|
|
} catch {
|
|
// ignore
|
|
}
|
|
try {
|
|
testRepo.cleanup();
|
|
} catch {
|
|
// best-effort
|
|
}
|
|
try {
|
|
isolatedEnv.cleanup();
|
|
} catch {
|
|
// best-effort
|
|
}
|
|
});
|
|
|
|
it('should create a task file from issue reference', () => {
|
|
const scenarioPath = resolve(__dirname, '../fixtures/scenarios/add-task.json');
|
|
|
|
const result = runTakt({
|
|
args: ['add', `#${issueNumber}`],
|
|
cwd: testRepo.path,
|
|
env: {
|
|
...isolatedEnv.env,
|
|
TAKT_MOCK_SCENARIO: scenarioPath,
|
|
},
|
|
input: 'n\n',
|
|
timeout: 240_000,
|
|
});
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
const tasksDir = join(testRepo.path, '.takt', 'tasks');
|
|
const files = readdirSync(tasksDir).filter((file) => file.endsWith('.yaml'));
|
|
expect(files.length).toBe(1);
|
|
|
|
const taskFile = join(tasksDir, files[0] ?? '');
|
|
const content = readFileSync(taskFile, 'utf-8');
|
|
expect(content).toContain('issue:');
|
|
}, 240_000);
|
|
});
|