fix(e2e): align tests with tasks.yaml-based list design

- watch/task-status-persistence: expect completed status instead of deletion
- list-non-interactive: create tasks.yaml records for completed task lookup
This commit is contained in:
nrslib 2026-02-15 06:08:53 +09:00
parent 7493b72c38
commit 7914078484
3 changed files with 33 additions and 3 deletions

View File

@ -1,11 +1,31 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { execFileSync } from 'node:child_process';
import { writeFileSync } from 'node:fs';
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { createIsolatedEnv, type IsolatedEnv } from '../helpers/isolated-env';
import { createTestRepo, type TestRepo } from '../helpers/test-repo';
import { runTakt } from '../helpers/takt-runner';
function writeCompletedTask(repoPath: string, name: string, branch: string): void {
const taktDir = join(repoPath, '.takt');
mkdirSync(taktDir, { recursive: true });
const now = new Date().toISOString();
writeFileSync(
join(taktDir, 'tasks.yaml'),
[
'tasks:',
` - name: ${name}`,
' status: completed',
` content: "E2E test task for ${name}"`,
` branch: "${branch}"`,
` created_at: "${now}"`,
` started_at: "${now}"`,
` completed_at: "${now}"`,
].join('\n'),
'utf-8',
);
}
// E2E更新時は docs/testing/e2e.md も更新すること
describe('E2E: List tasks non-interactive (takt list)', () => {
let isolatedEnv: IsolatedEnv;
@ -38,6 +58,8 @@ describe('E2E: List tasks non-interactive (takt list)', () => {
execFileSync('git', ['commit', '-m', 'takt: list diff e2e'], { cwd: testRepo.path, stdio: 'pipe' });
execFileSync('git', ['checkout', testRepo.branch], { cwd: testRepo.path, stdio: 'pipe' });
writeCompletedTask(testRepo.path, 'e2e-list-diff', branchName);
const result = runTakt({
args: ['list', '--non-interactive', '--action', 'diff', '--branch', branchName],
cwd: testRepo.path,
@ -58,6 +80,8 @@ describe('E2E: List tasks non-interactive (takt list)', () => {
execFileSync('git', ['commit', '-m', 'takt: list try e2e'], { cwd: testRepo.path, stdio: 'pipe' });
execFileSync('git', ['checkout', testRepo.branch], { cwd: testRepo.path, stdio: 'pipe' });
writeCompletedTask(testRepo.path, 'e2e-list-try', branchName);
const result = runTakt({
args: ['list', '--non-interactive', '--action', 'try', '--branch', branchName],
cwd: testRepo.path,
@ -84,6 +108,8 @@ describe('E2E: List tasks non-interactive (takt list)', () => {
execFileSync('git', ['commit', '-m', 'takt: list merge e2e'], { cwd: testRepo.path, stdio: 'pipe' });
execFileSync('git', ['checkout', testRepo.branch], { cwd: testRepo.path, stdio: 'pipe' });
writeCompletedTask(testRepo.path, 'e2e-list-merge', branchName);
const result = runTakt({
args: ['list', '--non-interactive', '--action', 'merge', '--branch', branchName],
cwd: testRepo.path,
@ -110,6 +136,8 @@ describe('E2E: List tasks non-interactive (takt list)', () => {
execFileSync('git', ['commit', '-m', 'takt: list e2e'], { cwd: testRepo.path, stdio: 'pipe' });
execFileSync('git', ['checkout', testRepo.branch], { cwd: testRepo.path, stdio: 'pipe' });
writeCompletedTask(testRepo.path, 'e2e-list-test', branchName);
const result = runTakt({
args: ['list', '--non-interactive', '--action', 'delete', '--branch', branchName, '--yes'],
cwd: testRepo.path,

View File

@ -69,7 +69,8 @@ describe('E2E: Task status persistence in tasks.yaml (mock)', () => {
const tasksContent = readFileSync(join(repo.path, '.takt', 'tasks.yaml'), 'utf-8');
const tasks = parseYaml(tasksContent) as { tasks: Array<Record<string, unknown>> };
expect(Array.isArray(tasks.tasks)).toBe(true);
expect(tasks.tasks.length).toBe(0);
expect(tasks.tasks.length).toBe(1);
expect(tasks.tasks[0]?.status).toBe('completed');
}, 240_000);
it('should persist failed status and failure details on failure', () => {

View File

@ -96,6 +96,7 @@ describe('E2E: Watch tasks (takt watch)', () => {
const tasksRaw = readFileSync(tasksFile, 'utf-8');
const parsed = parseYaml(tasksRaw) as { tasks?: Array<{ name?: string; status?: string }> };
const watchTask = parsed.tasks?.find((task) => task.name === 'watch-task');
expect(watchTask).toBeUndefined();
expect(watchTask).toBeDefined();
expect(watchTask!.status).toBe('completed');
}, 240_000);
});