mirror of
https://github.com/coder/registry.git
synced 2026-06-02 20:48:14 +00:00
0a8930d60d
## Description <!-- Briefly describe what this PR does and why --> Adds a module to open coder workspaces in Antigravity. ## Type of Change - [X] New module - [ ] New template - [ ] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder/modules/antigravity` **New version:** `v1.0.0` **Breaking change:** [ ] Yes [ ] No ## Testing & Validation - [ ] Tests pass (`bun test`) - [ ] Code formatted (`bun fmt`) - [ ] Changes tested locally ## Related Issues <!-- Link related issues or write "None" if not applicable --> --------- Co-authored-by: Atif Ali <atif@coder.com>
131 lines
4.0 KiB
TypeScript
131 lines
4.0 KiB
TypeScript
import { describe, it, expect } from "bun:test";
|
|
import {
|
|
runTerraformApply,
|
|
runTerraformInit,
|
|
testRequiredVariables,
|
|
runContainer,
|
|
execContainer,
|
|
removeContainer,
|
|
findResourceInstance,
|
|
readFileContainer,
|
|
} from "~test";
|
|
|
|
describe("antigravity", async () => {
|
|
await runTerraformInit(import.meta.dir);
|
|
|
|
testRequiredVariables(import.meta.dir, {
|
|
agent_id: "foo",
|
|
});
|
|
|
|
it("default output", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
});
|
|
expect(state.outputs.antigravity_url.value).toBe(
|
|
"antigravity://coder.coder-remote/open?owner=default&workspace=default&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
|
|
);
|
|
|
|
const coder_app = state.resources.find(
|
|
(res) =>
|
|
res.type === "coder_app" &&
|
|
res.module === "module.vscode-desktop-core" &&
|
|
res.name === "vscode-desktop",
|
|
);
|
|
|
|
expect(coder_app).not.toBeNull();
|
|
expect(coder_app?.instances.length).toBe(1);
|
|
expect(coder_app?.instances[0].attributes.order).toBeNull();
|
|
});
|
|
|
|
it("adds folder", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
folder: "/foo/bar",
|
|
});
|
|
expect(state.outputs.antigravity_url.value).toBe(
|
|
"antigravity://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
|
|
);
|
|
});
|
|
|
|
it("adds folder and open_recent", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
folder: "/foo/bar",
|
|
open_recent: "true",
|
|
});
|
|
expect(state.outputs.antigravity_url.value).toBe(
|
|
"antigravity://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
|
|
);
|
|
});
|
|
|
|
it("adds folder but not open_recent", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
folder: "/foo/bar",
|
|
openRecent: "false",
|
|
});
|
|
expect(state.outputs.antigravity_url.value).toBe(
|
|
"antigravity://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
|
|
);
|
|
});
|
|
|
|
it("adds open_recent", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
open_recent: "true",
|
|
});
|
|
expect(state.outputs.antigravity_url.value).toBe(
|
|
"antigravity://coder.coder-remote/open?owner=default&workspace=default&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN",
|
|
);
|
|
});
|
|
|
|
it("expect order to be set", async () => {
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
order: "22",
|
|
});
|
|
|
|
const coder_app = state.resources.find(
|
|
(res) =>
|
|
res.type === "coder_app" &&
|
|
res.module === "module.vscode-desktop-core" &&
|
|
res.name === "vscode-desktop",
|
|
);
|
|
|
|
expect(coder_app).not.toBeNull();
|
|
expect(coder_app?.instances.length).toBe(1);
|
|
expect(coder_app?.instances[0].attributes.order).toBe(22);
|
|
});
|
|
|
|
it("writes ~/.gemini/antigravity/mcp_config.json when mcp provided", async () => {
|
|
const id = await runContainer("alpine");
|
|
try {
|
|
const mcp = JSON.stringify({
|
|
servers: { demo: { url: "http://localhost:1234" } },
|
|
});
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
agent_id: "foo",
|
|
mcp,
|
|
});
|
|
const script = findResourceInstance(
|
|
state,
|
|
"coder_script",
|
|
"antigravity_mcp",
|
|
).script;
|
|
const resp = await execContainer(id, ["sh", "-c", script]);
|
|
if (resp.exitCode !== 0) {
|
|
console.log(resp.stdout);
|
|
console.log(resp.stderr);
|
|
}
|
|
expect(resp.exitCode).toBe(0);
|
|
const content = await readFileContainer(
|
|
id,
|
|
"/root/.gemini/antigravity/mcp_config.json",
|
|
);
|
|
expect(content).toBe(mcp);
|
|
} finally {
|
|
await removeContainer(id);
|
|
}
|
|
}, 10000);
|
|
});
|