Files
nexu-io__open-design/apps/daemon/tests/tools-deliverable-syntax-cli.test.ts
lbjzz-hash 92f27d1fc1 fix(daemon): finalize deliverable syntax without agent turns (#7801)
* fix(daemon): add bounded deliverable syntax repair loop

* test(daemon): enable OD Next for branch evals

* fix(daemon): keep syntax gate narrowly scoped

* feat(daemon): report deliverable syntax timing

* fix(daemon): remove evaluation rollout override

* feat(daemon): measure syntax repair windows

* fix(daemon): finalize deliverable syntax without agent turns

* fix(daemon): validate committed syntax recovery and quote repairs

* docs: clarify syntax gate applicability without touched paths

* fix(telemetry): reject partial syntax summaries without version
2026-09-08 07:03:28 +00:00

61 lines
2.0 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { runDeliverableSyntaxToolCli } from '../src/tools-deliverable-syntax-cli.js';
const ORIGINAL_ENV = { ...process.env };
describe('deliverable syntax tool CLI', () => {
let stdoutWrite: { mockRestore: () => void };
let stderrWrite: { mockRestore: () => void };
let stdoutOutput: string[];
let stderrOutput: string[];
let fetchMock: ReturnType<typeof vi.fn>;
beforeEach(() => {
process.env = { ...ORIGINAL_ENV };
stdoutOutput = [];
stderrOutput = [];
stdoutWrite = vi.spyOn(process.stdout, 'write').mockImplementation((chunk) => {
stdoutOutput.push(String(chunk));
return true;
});
stderrWrite = vi.spyOn(process.stderr, 'write').mockImplementation((chunk) => {
stderrOutput.push(String(chunk));
return true;
});
fetchMock = vi.fn(async () => new Response(JSON.stringify({ status: 'pass', diagnostics: [] }), {
headers: { 'Content-Type': 'application/json' },
status: 200,
}));
vi.stubGlobal('fetch', fetchMock);
});
afterEach(() => {
vi.unstubAllGlobals();
stdoutWrite.mockRestore();
stderrWrite.mockRestore();
process.env = ORIGINAL_ENV;
});
it('forwards check with injected daemon credentials and emits JSON', async () => {
process.env.OD_DAEMON_URL = 'http://127.0.0.1:7456/base/';
process.env.OD_TOOL_TOKEN = 'agent-run-token';
const result = await runDeliverableSyntaxToolCli(['check', '--json']);
expect(result.exitCode).toBe(0);
expect(fetchMock).toHaveBeenCalledWith(
'http://127.0.0.1:7456/base/api/tools/deliverable-syntax/check',
expect.objectContaining({
method: 'POST',
headers: expect.objectContaining({
Authorization: 'Bearer agent-run-token',
Accept: 'application/json',
}),
}),
);
expect(JSON.parse(stdoutOutput.join(''))).toEqual({ ok: true, status: 'pass', diagnostics: [] });
expect(stderrOutput.join('')).toBe('');
});
});