fix e2e
This commit is contained in:
parent
0c0519eeb4
commit
55aeeab4ec
@ -1,8 +1,9 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join, dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
import { createIsolatedEnv, type IsolatedEnv } from '../helpers/isolated-env';
|
||||
import { createTestRepo, type TestRepo } from '../helpers/test-repo';
|
||||
import { runTakt } from '../helpers/takt-runner';
|
||||
@ -84,12 +85,10 @@ describe('E2E: Add task from GitHub issue (takt add)', () => {
|
||||
|
||||
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:');
|
||||
const tasksFile = join(testRepo.path, '.takt', 'tasks.yaml');
|
||||
const content = readFileSync(tasksFile, 'utf-8');
|
||||
const parsed = parseYaml(content) as { tasks?: Array<{ issue?: number }> };
|
||||
expect(parsed.tasks?.length).toBe(1);
|
||||
expect(parsed.tasks?.[0]?.issue).toBe(Number(issueNumber));
|
||||
}, 240_000);
|
||||
});
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join, resolve, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
import { createIsolatedEnv, type IsolatedEnv } from '../helpers/isolated-env';
|
||||
import { createTestRepo, type TestRepo } from '../helpers/test-repo';
|
||||
|
||||
@ -51,16 +52,21 @@ describe('E2E: Watch tasks (takt watch)', () => {
|
||||
stdout += chunk.toString();
|
||||
});
|
||||
|
||||
const tasksDir = join(testRepo.path, '.takt', 'tasks');
|
||||
mkdirSync(tasksDir, { recursive: true });
|
||||
|
||||
const taktDir = join(testRepo.path, '.takt');
|
||||
mkdirSync(taktDir, { recursive: true });
|
||||
const tasksFile = join(taktDir, 'tasks.yaml');
|
||||
const createdAt = new Date().toISOString();
|
||||
const taskYaml = [
|
||||
'task: "Add a single line \\\"watch test\\\" to README.md"',
|
||||
'tasks:',
|
||||
' - name: watch-task',
|
||||
' status: pending',
|
||||
' content: "Add a single line \\"watch test\\" to README.md"',
|
||||
` piece: "${piecePath}"`,
|
||||
` created_at: "${createdAt}"`,
|
||||
' started_at: null',
|
||||
' completed_at: null',
|
||||
].join('\n');
|
||||
|
||||
const taskPath = join(tasksDir, 'watch-task.yaml');
|
||||
writeFileSync(taskPath, taskYaml, 'utf-8');
|
||||
writeFileSync(tasksFile, taskYaml, 'utf-8');
|
||||
|
||||
const completed = await new Promise<boolean>((resolvePromise) => {
|
||||
const timeout = setTimeout(() => resolvePromise(false), 240_000);
|
||||
@ -87,6 +93,9 @@ describe('E2E: Watch tasks (takt watch)', () => {
|
||||
});
|
||||
|
||||
expect(completed).toBe(true);
|
||||
expect(existsSync(taskPath)).toBe(false);
|
||||
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?.status).toBe('completed');
|
||||
}, 240_000);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user