Skip to content

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

1.3 KB
Raw Blame
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, it } from "node:test";
import { fileURLToPath } from "node:url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = path.resolve(__dirname, "../..");
const BROWSER_POOL_PATHS = [
  path.join(REPO_ROOT, "open-sse/services/browserPool.ts"),
  path.join(REPO_ROOT, "packages/browser-pool/src/services/browserPool.ts"),
];

describe("browserPool optional cloakbrowser import", () => {
  it("keeps cloakbrowser out of static dynamic import resolution", () => {
    for (const browserPoolPath of BROWSER_POOL_PATHS) {
      const source = readFileSync(browserPoolPath, "utf8");

      assert.equal(
        /import\(\s*["']cloakbrowser["']\s*\)/.test(source),
        false,
        "cloakbrowser must remain runtime-optional; static dynamic import triggers Turbopack resolution"
      );
      assert.match(
        source,
        /Turbopack resolve it during route compilation/,
        "the computed import rationale should stay documented near the helper"
      );
      assert.match(source, /return \["cloak", "browser"\]\.join\(""\);/);
      assert.match(
        source,
        /\/\* webpackIgnore: true \*\//,
        "Webpack must leave the optional runtime import unresolved"
      );
    }
  });
});