Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions __tests__/fixtures/published-guide/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Published command fixture

`cli.mdx` is the complete, unmodified Marketing guide at the immutable source in
`provenance.json`. The test extracts its email/song examples and chat-link flag,
`provenance.json`. The test extracts its email/song/cost-estimate examples and chat-link flag,
then runs the built CLI with synthetic credentials and intercepted native fetch.
No endpoint is contacted. Request records omit headers.
No endpoint is contacted. Request records preserve query strings and omit headers.
Estimate checks require GET without a body and exact default/explicit query flags;
they do not verify pricing or invoke content creation.

Run `pnpm build` then `pnpm exec vitest run __tests__/publishedCommands.test.ts`.
Documentation owners can set `RECOUP_CLI_REFERENCE_PATH` to an absolute candidate
Expand All @@ -12,5 +14,5 @@ Markdown path to run the same parser/request assertions before publishing.
When these examples intentionally change, copy the complete guide from its owning
commit, update provenance and SHA256, and review the expected requests together.
The default check protects this pinned guide; it does not monitor future live docs
or establish installed npm package behavior. Coverage is limited to email/song
examples and the retired email flag, not every CLI command or authorization rule.
or establish installed npm package behavior. Coverage is limited to email/song/
cost-estimate examples and the retired email flag, not every CLI command or authorization rule.
4 changes: 3 additions & 1 deletion __tests__/fixtures/published-guide/intercept.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ globalThis.fetch = async (input, options = {}) => {
}
appendFileSync(process.env.CLI_FIXTURE_REQUEST_LOG, JSON.stringify({
method: options.method,
path: url.pathname,
path: url.pathname + url.search,
body: options.body ? JSON.parse(options.body) : null,
}) + "\n");
return new Response(JSON.stringify({
message: "Synthetic email response",
response: "Synthetic analysis response",
elapsed_seconds: 0,
presets: [],
per_video_estimate_usd: 1,
total_estimate_usd: 2,
}), { status: 200, headers: { "Content-Type": "application/json" } });
};
20 changes: 20 additions & 0 deletions __tests__/publishedCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,24 @@ describe("published command contract (built CLI, intercepted requests)", () => {
expect(result.requests).toEqual([expected[index]]);
});
});

it("runs every cost estimate example as GET with the documented query flags", () => {
const commands = examples("Estimate cost");
expect(commands).toHaveLength(2);
const expectedQueries = [
{ lipsync: "false", batch: "1", compare: "false" },
{ lipsync: "true", batch: "2", compare: "true" },
];
commands.forEach((command, index) => {
const result = run(command);
expect(result.status).toBe(0);
expect(result.requests).toHaveLength(1);
const request = result.requests[0];
expect(request).toMatchObject({ method: "GET", body: null });
const url = new URL(request.path, "https://cli-fixture.invalid");
expect(url.pathname).toBe("/api/content/estimate");
expect([...url.searchParams]).toHaveLength(3);
expect(Object.fromEntries(url.searchParams)).toEqual(expectedQueries[index]);
});
});
});
Loading