Files
OmniRoute/tests/unit/listCapabilities-a2a.test.ts
Diego Rodrigues de Sa e Souza ecc89eef14 feat(providers): integrate audited free-tier gateways (#9210)
* feat(providers): add Zylo UnoRouter and Poolside registries

* feat(providers): integrate audited free-tier gateways

* feat: add wave2 free-tier provider registries

* feat(providers): add Mixlayer Speka and TokenReply registries

* feat: add wave 2 free-tier provider registries

* fix: align meganova provider slug

* feat(providers): integrate wave2 free-tier gateways

* feat(providers): add Wave 3-A free-tier registries

* feat(providers): add HelyxAI Auriko and Poixe registries

* feat(providers): add Naga AI and Chat Oripe registries

* feat(providers): integrate wave3 free-tier gateways

* feat(providers): add FreeInference registry

* feat(providers): add Free.ai registry

* feat(providers): integrate wave4 free-tier gateways

* docs: synchronize provider and free-tier inventories

* refactor(providers): split audited gateway catalog

* feat(providers): add audited Void AI and HelixMind gateways

* feat(providers): finalize audited free-tier integration

* test(providers): update APIKEY split count to 229 after rebase onto release/v3.8.50

The rebase merged the release catalog (201 APIKEY providers) with the PR's
28 free-tier additions, yielding 229 total. Correct the characterization
count so the partition assertion reflects the true merged state.

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: backryun <bakryun0718@proton.me>
2026-08-12 16:19:25 -03:00

96 lines
3.9 KiB
TypeScript

/**
* Unit tests for the A2A list-capabilities skill.
*
* Verifies:
* - Return shape matches §3.7 contract
* - Markdown table contains all 45 skill IDs
* - Coverage bounds are within declared totals
* - metadata.source === "agent-skills-catalog"
* - metadata.generatedAt is an ISO datetime string
*/
import assert from "node:assert/strict";
import { test } from "node:test";
import type { A2ATask } from "../../src/lib/a2a/taskManager.js";
import { executeListCapabilities } from "../../src/lib/a2a/skills/listCapabilities.js";
import {
API_SKILL_IDS,
CLI_SKILL_IDS,
CONFIG_SKILL_IDS,
} from "../../src/lib/agentSkills/catalog.js";
// Minimal stub — executeListCapabilities only receives the task arg but does not use it
const stubTask = {} as A2ATask;
test("executeListCapabilities returns shape matching §3.7 contract", async () => {
const result = await executeListCapabilities(stubTask);
// artifacts array with exactly 1 text artifact
assert.ok(Array.isArray(result.artifacts), "artifacts is an array");
assert.equal(result.artifacts.length, 1, "exactly 1 artifact");
assert.equal(result.artifacts[0].type, "text", "artifact type is 'text'");
assert.ok(typeof result.artifacts[0].content === "string", "artifact content is a string");
// metadata shape
const { metadata } = result;
assert.ok(metadata, "metadata exists");
assert.equal(metadata.source, "agent-skills-catalog", "metadata.source matches");
assert.equal(metadata.totalSkills, 45, "metadata.totalSkills === 45");
assert.ok(metadata.coverage, "metadata.coverage exists");
assert.ok(metadata.coverage.api, "metadata.coverage.api exists");
assert.ok(metadata.coverage.cli, "metadata.coverage.cli exists");
assert.equal(metadata.coverage.api.total, 23, "api.total === 23");
assert.equal(metadata.coverage.cli.total, 21, "cli.total === 21");
assert.equal(metadata.coverage.config.total, 1, "config.total === 1");
});
test("executeListCapabilities markdown table contains all 45 skill IDs", async () => {
const result = await executeListCapabilities(stubTask);
const content = result.artifacts[0].content;
const allIds = [...API_SKILL_IDS, ...CLI_SKILL_IDS, ...CONFIG_SKILL_IDS] as string[];
assert.equal(allIds.length, 45, "catalog declares 45 skill IDs");
for (const id of allIds) {
assert.ok(content.includes(id), `Markdown table missing skill ID: ${id}`);
}
});
test("metadata.coverage.api.have is within [0, 23]", async () => {
const result = await executeListCapabilities(stubTask);
const { api } = result.metadata.coverage;
assert.ok(api.have >= 0, "api.have >= 0");
assert.ok(api.have <= 23, "api.have <= 23");
});
test("metadata.coverage.cli.have is within [0, 21]", async () => {
const result = await executeListCapabilities(stubTask);
const { cli } = result.metadata.coverage;
assert.ok(cli.have >= 0, "cli.have >= 0");
assert.ok(cli.have <= 21, "cli.have <= 21");
});
test("metadata.coverage.config.have is within [0, 1]", async () => {
const result = await executeListCapabilities(stubTask);
const { config } = result.metadata.coverage;
assert.ok(config.have >= 0, "config.have >= 0");
assert.ok(config.have <= 1, "config.have <= 1");
});
test("metadata.generatedAt is a valid ISO datetime", async () => {
const result = await executeListCapabilities(stubTask);
const { generatedAt } = result.metadata;
assert.ok(typeof generatedAt === "string", "generatedAt is a string");
const parsed = new Date(generatedAt);
assert.ok(!isNaN(parsed.getTime()), `generatedAt is not a valid date: ${generatedAt}`);
assert.ok(generatedAt.includes("T"), "generatedAt contains 'T' (ISO format)");
});
test("list-capabilities is registered in A2A_SKILL_HANDLERS", async () => {
const { A2A_SKILL_HANDLERS } = await import("../../src/lib/a2a/taskExecution.js");
assert.ok(
"list-capabilities" in A2A_SKILL_HANDLERS,
"list-capabilities must be in A2A_SKILL_HANDLERS"
);
});