Skip to content
54 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { routeFor, sitePathOf } from "./links.ts";
5
6test("a g1t:// link names a site path, as on the desktop", () => {
7 assert.equal(sitePathOf("g1t://acme/-/chat/dm/chn_1"), "/acme/-/chat/dm/chn_1");
8 assert.equal(sitePathOf("g1t:///acme/rocket/pull/3?tab=files"), "/acme/rocket/pull/3?tab=files");
9 assert.equal(sitePathOf("https://g1t.sh/acme"), null);
10});
11
12test("Chat's pages open the app's Chat", () => {
13 assert.equal(routeFor("/acme/-/chat"), "/chat?workspace=acme");
14 assert.equal(routeFor("/acme/-/chat/general"), "/chat/general?workspace=acme");
15 assert.equal(routeFor("/acme/-/chat/dm/chn_1"), "/chat/chn_1?workspace=acme");
16 assert.equal(routeFor("/acme/-/chat/browse"), null);
17});
18
19test("Code's pages open the app's Code", () => {
20 assert.equal(routeFor("/acme/rocket"), "/code/acme/rocket");
21 assert.equal(routeFor("/acme/rocket/pull/14"), "/code/acme/rocket/pull/14");
22 assert.equal(routeFor("/acme/rocket/issues/12"), "/code/acme/rocket/issues/12");
23 assert.equal(routeFor("/acme/-/overview"), "/code?workspace=acme");
24 assert.equal(routeFor("/acme/rocket/pull/14/files"), null);
25 assert.equal(routeFor("/acme/rocket/issues/new"), null);
26});
27
28test("Customize's tabs open the app's Customize; its other pages stay on the site", () => {
29 assert.equal(routeFor("/acme/-/customize"), "/customize?workspace=acme");
30 assert.equal(routeFor("/acme/-/customize/plugins"), "/customize/plugins?workspace=acme");
31 assert.equal(routeFor("/acme/-/customize/connectors?view=discover"), "/customize/connectors?workspace=acme");
32 assert.equal(routeFor("/acme/-/customize/plugins/pdf%40anthropic-agent-skills"), null);
33 assert.equal(routeFor("/acme/-/customize/requests"), null);
34});
35
36test("the Marketplace, integrations and the old skill library open Customize", () => {
37 assert.equal(routeFor("/acme/-/marketplace/integrations"), "/customize?workspace=acme");
38 assert.equal(routeFor("/acme/-/agents/skills"), "/customize?workspace=acme");
39 assert.equal(routeFor("/acme/-/agents/skills/pdf"), null, "a skill's own page is the site's");
40});
41
42test("the app's sign-in comes back to its own screen, and the site's own pages stay on the site", () => {
43 assert.equal(routeFor("/oauth/callback?code=c&state=s"), "/oauth/callback?code=c&state=s");
44 assert.equal(routeFor("/settings/tokens"), null);
45 assert.equal(routeFor("/"), "/");
46});
47
48test("a connect link points the app at a g1t", () => {
49 assert.equal(routeFor("/connect?server=https%3A%2F%2Fg1t.example.com"), "/connect?server=https%3A%2F%2Fg1t.example.com");
50 assert.equal(sitePathOf("g1t://connect?server=https%3A%2F%2Fg1t.example.com"), "/connect?server=https%3A%2F%2Fg1t.example.com");
51 // A workspace named connect is still a workspace.
52 assert.equal(routeFor("/connect/-/chat"), "/chat?workspace=connect");
53 assert.equal(routeFor("/connect/web"), "/code/connect/web");
54});