import { test } from 'node:test';
import assert from 'node:assert/strict';
import { TOOLS } from '../functions/tools.js';
import { NEEDS, whichApiHtml, whichApiMd, llmsFullTxt, NFA } from '../functions/docs.js';
import { llmsTxt } from '../functions/root.js';
import { onRequest } from '../functions/[[path]].js';
const env = { PUBLIC_HOST: 'api.youraitools.co' };
const call = (p) => onRequest({ request: new Request(`https://api.youraitools.co${p}`), env });
test('every live tool appears in the decision guide; every row points at a real paid route', () => {
for (const t of TOOLS) assert.ok(NEEDS.some((n) => n.tool === t.prefix), `missing ${t.prefix}`);
for (const n of NEEDS) { const t = TOOLS.find((x) => x.prefix === n.tool); assert.ok(t.paid.includes(n.route), `${n.tool} ${n.route}`); }
const md = whichApiMd(env);
for (const t of TOOLS) assert.ok(md.includes(`https://api.youraitools.co/${t.prefix}/`), t.prefix);
});
test('trader rows carry the NFA line; safety rows say safety check only; no profit claims', () => {
for (const p of ['perpradar', 'tasignal', 'smartperps']) assert.ok(NEEDS.find((n) => n.tool === p).note.includes(NFA), p);
for (const p of ['counterpartycheck', 'signcheck', 'tokenverdict', 'solverdict', 'injectscan', 'leakguard', 'pkgguard', 'domaincheck']) assert.match(NEEDS.find((n) => n.tool === p).note, /Safety check only\./, p);
const all = whichApiMd(env) + whichApiHtml(env);
assert.doesNotMatch(all, /guaranteed (profit|return)|make money|passive income/i);
});
test('routes: /docs/which-api html, .md markdown, /llms-full.txt text, /docs redirects, llms.txt links the guide', async () => {
let r = await call('/docs/which-api'); assert.equal(r.status, 200); assert.match(r.headers.get('content-type'), /^text\/html/); assert.match(await r.text(), /<h1>Which API should I use\?<\/h1>/);
r = await call('/docs/which-api.md'); assert.equal(r.status, 200); assert.match(r.headers.get('content-type'), /^text\/markdown/);
r = await call('/llms-full.txt'); assert.equal(r.status, 200); assert.match(r.headers.get('content-type'), /^text\/plain/);
const full = await r.text(); assert.ok(full.startsWith('# YourAITools API\n')); assert.match(full, /# YourAITools API: Which API should I use\?/);
r = await call('/docs'); assert.equal(r.status, 301); assert.equal(r.headers.get('location'), '/docs/which-api');
assert.match(llmsTxt(env), /\[Which API should I use\? \(decision guide\)\]\(https:\/\/api\.youraitools\.co\/docs\/which-api\.md\)/);
assert.equal(llmsFullTxt(env).length > llmsTxt(env).length, true);
});
test('PerpCheck row carries the exchange-decides NFA line', () => {
assert.match(NEEDS.find((n) => n.tool === 'perpcheck').note, /Not financial advice; the exchange decides whether an order is accepted\./);
});
agentgate-source: code mirror on Cloudflare Pages. All repos