// What the create-agent form sends for the initial AGENTS.md, and which error // it shows beside the box. Run by `npm test`, which Node runs with its // built-in test runner and type stripping, so the `.ts` module is imported as // it is. import assert from "node:assert/strict"; import { test } from "node:test"; import { agentsMdBody, agentsMdRefusal, } from "../src/pages/CreateAgentAgentsMd.ts"; test("an empty or whitespace-only box sends no agents_md", () => { assert.deepEqual(agentsMdBody(""), {}); assert.deepEqual(agentsMdBody(" \n\t \n"), {}); }); test("text is sent as typed, whitespace and all", () => { assert.deepEqual(agentsMdBody("# me\n\nDo the thing.\n"), { agents_md: "# me\n\nDo the thing.\n", }); assert.deepEqual(agentsMdBody(" indented"), { agents_md: " indented" }); }); test("the size refusal shows beside the box", () => { const detail = "agents_md is 70000 bytes; the limit is 65536"; assert.equal(agentsMdRefusal({ status: 400, detail }), detail); }); test("other failures stay with the general error", () => { assert.equal( agentsMdRefusal({ status: 400, detail: "name is not a valid identifier" }), null, ); assert.equal( agentsMdRefusal({ status: 500, detail: "agents_md is 70000 bytes; the limit is 65536", }), null, ); assert.equal(agentsMdRefusal({ status: 400 }), null); assert.equal(agentsMdRefusal({ detail: "agents_md is too long" }), null); });