| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { CONNECTORS } from "@g1t/contracts/connectors"; |
| 5 | |
| 6 | import { AI_PROVIDER_GROUPS, AI_PROVIDERS, aiProvidersIn, isEndpoint } from "./ai-providers.ts"; |
| 7 | import { integrationsSection, sectionKind } from "./integration-sections.ts"; |
| 8 | |
| 9 | test("every AI provider is in the catalogue, once, in a group", () => { |
| 10 | // The integrations directory's AI models, each an AI provider's connection. |
| 11 | const models = CONNECTORS.flatMap((connector) => (connector.category === "ai" && connector.provider ? [connector.provider] : [])); |
| 12 | assert.ok(models.length > 0); |
| 13 | assert.deepEqual(Object.keys(AI_PROVIDERS).sort(), [...models].sort()); |
| 14 | const grouped = AI_PROVIDER_GROUPS.flatMap(({ group }) => aiProvidersIn(group)); |
| 15 | assert.deepEqual([...grouped].sort(), [...models].sort()); |
| 16 | for (const provider of models) { |
| 17 | const entry = AI_PROVIDERS[provider]!; |
| 18 | assert.ok(entry.blurb.length > 0, provider); |
| 19 | if (entry.keyUrl) assert.ok(entry.keyUrl.startsWith("https://"), provider); |
| 20 | // Only the endpoints show an icon in place of initials. |
| 21 | assert.equal(entry.mark === "", isEndpoint(provider), provider); |
| 22 | } |
| 23 | }); |
| 24 | |
| 25 | test("AI providers are set up on their own page", () => { |
| 26 | assert.equal(integrationsSection("models"), "models"); |
| 27 | assert.equal(sectionKind("models"), "models"); |
| 28 | assert.equal(sectionKind("alerts"), "alerts"); |
| 29 | assert.equal(sectionKind("trackers"), "tracker"); |
| 30 | assert.equal(sectionKind("gateway"), null); |
| 31 | }); |