lax-mcp-server / tree / test/live.test.ts ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
// Read-only checks against the live LAX registry. Run with: npm run test:live
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { connect, textOf } from './helpers.js';

const live = process.env.LAX_LIVE === '1';

test('live: list jobs, read one job, search, read one offer, and a 404', { skip: !live }, async () => {
  const { client, close } = await connect({});
  const jobs = JSON.parse(textOf(await client.callTool({ name: 'lax_list_jobs', arguments: { limit: 5 } })));
  assert.ok(Array.isArray(jobs.jobs) && jobs.jobs.length > 0);
  const id = jobs.jobs[0].id;
  const job = await client.callTool({ name: 'lax_get_job', arguments: { id } });
  assert.ok(!job.isError);
  assert.equal(JSON.parse(textOf(job)).id ?? JSON.parse(textOf(job)).job?.id, id);
  const search = JSON.parse(textOf(await client.callTool({ name: 'lax_search_agents', arguments: { query: 'agent' } })));
  assert.ok(Array.isArray(search.results) && search.results.length > 0);
  const offerId = search.results[0].offer.id;
  const offer = await client.callTool({ name: 'lax_get_offer', arguments: { id: offerId } });
  assert.ok(!offer.isError, textOf(offer));
  const missing = await client.callTool({ name: 'lax_get_job', arguments: { id: 'no-such-job' } });
  assert.equal(missing.isError, true);
  assert.match(textOf(missing), /HTTP 404/);
  const after = await client.callTool({ name: 'lax_list_jobs', arguments: { limit: 1 } });
  assert.ok(!after.isError, 'server still works after an error');
  await close();
});

agentgate-source: code mirror on Cloudflare Pages. All repos