beadboard/skills/beadboard-driver/tests/ensure-project-context.contract.test.mjs
zenchantlive 18fbafdce4 refactor: extract agent bounded context + fix SSE comments + cleanup unused
- Extract src/lib/agent/ bounded context with types, registry, messaging
- Add comments_count to BeadIssue for SSE comment detection
- Create batch endpoints for mail/reservations APIs
- Add memory validation to session-preflight
- Remove unused empty dirs (mockup, sessions, timeline)
- Move stashes to docs/references, gitignore them
2026-03-04 22:06:40 -08:00

47 lines
1.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
import { fileURLToPath } from 'node:url';
const execFileAsync = promisify(execFile);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const scriptPath = path.resolve(__dirname, '..', 'scripts', 'ensure-project-context.mjs');
test('ensure-project-context creates project.md when missing', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'bb-skill-project-context-'));
try {
const { stdout } = await execFileAsync(process.execPath, [scriptPath, '--project-root', root]);
const result = JSON.parse(stdout);
const content = await fs.readFile(path.join(root, 'project.md'), 'utf8');
assert.equal(result.ok, true);
assert.equal(result.created, true);
assert.match(content, /Environment Status Cache/);
} finally {
await fs.rm(root, { recursive: true, force: true });
}
});
test('ensure-project-context preserves existing project.md', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'bb-skill-project-context-'));
try {
const target = path.join(root, 'project.md');
await fs.writeFile(target, '# existing\n', 'utf8');
const { stdout } = await execFileAsync(process.execPath, [scriptPath, '--project-root', root]);
const result = JSON.parse(stdout);
const content = await fs.readFile(target, 'utf8');
assert.equal(result.ok, true);
assert.equal(result.created, false);
assert.equal(result.used_existing, true);
assert.equal(content, '# existing\n');
} finally {
await fs.rm(root, { recursive: true, force: true });
}
});