Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
// Source-level contract tests for the #7610 Grok Build paste-import UX.
// The modal must refuse bare JWT pastes and require full auth.json with refresh_token.
const here = dirname(fileURLToPath(import.meta.url));
const modalSource = readFileSync(join(here, "../../src/shared/components/OAuthModal.tsx"), "utf8");
const pasteCopySource = readFileSync(
join(here, "../../src/shared/components/oauthModal/pasteTokenCopy.ts"),
"utf8"
);
const parserSource = readFileSync(
join(here, "../../src/lib/oauth/utils/grokCliAuthJson.ts"),
"utf8"
);
test("#7610: OAuthModal rejects bare Grok JWT paste instructions", () => {
assert.match(modalSource, /parseGrokCliPasteToken/);
assert.match(parserSource, /Do not paste only the JWT/);
assert.match(parserSource, /full ~\/\.grok\/auth\.json/);
assert.doesNotMatch(
modalSource,
/Paste your Grok Build JWT token from ~\/\.grok\/auth\.json \(the "key" field value\)/
);
});
test("#7610: OAuthModal paste UI is auth.json-oriented for grok-cli", () => {
// #9245 localized the hardcoded copy: the modal now renders i18n keys and the
// English source strings live in oauthModal.* inside en.json.
// The per-provider tab/description keys live in the modal's paste-copy table.
assert.match(modalSource, /getPasteTokenCopyKeys/);
assert.match(pasteCopySource, /"grok-cli": "tabImportAuthJson"/);
assert.match(pasteCopySource, /"grok-cli": "grokAuthJsonDescription"/);
assert.match(modalSource, /grokAuthJsonPlaceholder/);
assert.match(modalSource, /grokAuthJsonLabel/);
const enMessages = readFileSync(join(here, "../../src/i18n/messages/en.json"), "utf8");
const oauthModal = (JSON.parse(enMessages) as { oauthModal: Record<string, string> }).oauthModal;
assert.equal(oauthModal.tabImportAuthJson, "Import auth.json");
assert.equal(oauthModal.grokAuthJsonLabel, "Grok Build auth.json");
assert.match(oauthModal.grokAuthJsonDescription, /refresh_token/);
assert.match(oauthModal.grokAuthJsonPlaceholder, /refresh_token/);
});