forge
Explore
Log in

Don't you dare go Hollow

🤝 align the ai contract assertions with the documented receipts

Browse files at this commit

45f3d410a767a5d8804ff01be339c2e69eef4b6eAhmet Kaan GümüşParent: a3eb98c
  • test
    • 🤝 align the ai contract assertions with the documented receipts
Show full message
test: 🤝 align the ai contract assertions with the documented receipts

- /insights/refresh 202 carries {status: "accepted"} only — the run's
  record is ZEKA's, no message row id is minted
- POST /podcast/jobs for an unnarratable source is the documented
  409 source_missing, not a 404
src/api/__tests__/contract/ai.contract.test.tsmodified+8 -5
@@ -42,9 +42,10 @@ describe.skipIf(!isLive)(`ai contract @ ${contractBaseUrl}`, () => {
42 const response = await api("/insights/refresh", { method: "POST", body: {} });42 const response = await api("/insights/refresh", { method: "POST", body: {} });
43 expect([202, 503]).toContain(response.status);43 expect([202, 503]).toContain(response.status);
44 if (response.status === 202) {44 if (response.status === 202) {
45+ // Documented receipt is `{status: "accepted"}` only: the work's own
46+ // record is ZEKA's (zeka_run), so no message row id is minted here.
45 const receipt = (await response.json()) as Record<string, unknown>;47 const receipt = (await response.json()) as Record<string, unknown>;
46- expect(typeof receipt.message_id).toBe("string");48+ expect(receipt.status).toBe("accepted");
47- expect(receipt.status).toBe("pending");
48 }49 }
49 });50 });
50 51
@@ -53,9 +54,11 @@ describe.skipIf(!isLive)(`ai contract @ ${contractBaseUrl}`, () => {
53 method: "POST",54 method: "POST",
54 body: { source_id: "00000000-0000-0000-0000-000000000000" },55 body: { source_id: "00000000-0000-0000-0000-000000000000" },
55 });56 });
56- // 503 with no service, 400/404 for the missing course note once there is57+ // 503 with no service, 400/404 for a malformed or unresolvable id, and the
57- // one. A 202 here would mean the backend minted a job for nothing.58+ // backend's documented 409 `source_missing` when the note has no narratable
58- expect([400, 404, 503]).toContain(response.status);59+ // PDF on this host (a nonexistent note lands there too, by design). A 202
60+ // here would mean the backend minted a job for nothing.
61+ expect([400, 404, 409, 503]).toContain(response.status);
59 });62 });
60 63
61 it("answers nothing for an audio job id that is not the caller's", async () => {64 it("answers nothing for an audio job id that is not the caller's", async () => {