Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

43 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { type AiProvider, AI_PROVIDERS } from "@g1t/contracts/ai";
5import { CONNECTORS } from "@g1t/contracts/connectors";
6
7import { AI_PROVIDER_GROUPS, AI_PROVIDER_LOOKS, aiProvidersIn, isEndpoint } from "./ai-providers.ts";
8import { aiPagePath, providerPage, sectionKind } from "./integration-sections.ts";
9
10test("every AI provider is shown, once, in a group", () => {
11 const providers = Object.keys(AI_PROVIDERS) as AiProvider[];
12 assert.equal(providers.length, 14);
13 assert.deepEqual(Object.keys(AI_PROVIDER_LOOKS).sort(), [...providers].sort());
14 const grouped = AI_PROVIDER_GROUPS.flatMap(({ group }) => aiProvidersIn(group));
15 assert.deepEqual(grouped, providers);
16 for (const provider of providers) {
17 const look = AI_PROVIDER_LOOKS[provider];
18 assert.ok(look.blurb.length > 0, provider);
19 if (look.keyUrl) assert.ok(look.keyUrl.startsWith("https://"), provider);
20 // Every provider that takes a key says where to get one, and how.
21 assert.equal(Boolean(look.keyUrl && look.keyHow), !isEndpoint(provider), provider);
22 // Only the endpoints show an icon in place of initials.
23 assert.equal(look.mark === "", isEndpoint(provider), provider);
24 }
25});
26
27test("AI providers are the workspace's AI settings, not integrations", () => {
28 // None is in the integrations directory.
29 const ai = new Set<string>(Object.keys(AI_PROVIDERS));
30 assert.deepEqual(CONNECTORS.filter((connector) => connector.provider && ai.has(connector.provider)), []);
31 assert.equal(providerPage("alerts"), "integrations/alerts");
32 assert.equal(providerPage("tracker"), "integrations/trackers");
33 assert.equal(sectionKind("models"), null);
34 assert.equal(sectionKind("alerts"), "alerts");
35 assert.equal(sectionKind("trackers"), "tracker");
36 assert.equal(sectionKind("gateway"), null);
37});
38
39test("older links to the AI providers' page open the AI page", () => {
40 assert.equal(aiPagePath("acme", ""), "/acme/-/ai");
41 assert.equal(aiPagePath("acme", "?add=openai"), "/acme/-/ai?add=openai#add");
42 assert.equal(aiPagePath("acme", "?_routes=root&add=openai"), "/acme/-/ai?add=openai#add");
43});