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.1 KB
Raw Blame
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";

const analyticsFiles = [
  "src/shared/components/analytics/charts.tsx",
  "src/shared/components/analytics/index.tsx",
  "src/shared/components/analytics/rechartsDonuts.tsx",
  "src/shared/components/analytics/rechartsUsageCharts.tsx",
];

test("usage analytics keeps Recharts behind the lazy loader boundary", () => {
  const coreSource = readFileSync("src/shared/components/analytics/rechartsCore.tsx", "utf8");

  assert.match(coreSource, /import\("recharts"\)/);
  assert.match(coreSource, /rechartsPromise = null;/);

  for (const filePath of analyticsFiles) {
    const source = readFileSync(filePath, "utf8");

    assert.doesNotMatch(source, /from\s+["']recharts["']/);
    assert.doesNotMatch(source, /import\("recharts"\)/);
  }
});

test("usage analytics bars use the defined primary color token", () => {
  const chartSource = readFileSync(
    "src/shared/components/analytics/rechartsUsageCharts.tsx",
    "utf8"
  );

  assert.match(chartSource, /fill="var\(--color-primary\)"/);
  assert.doesNotMatch(chartSource, /fill="var\(--primary\)"/);
});