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

test(audit): cover high-level actions and activity icons

diegosouzapw1b0282ed3295
diff --git a/tests/unit/audit-activity-icons.test.ts b/tests/unit/audit-activity-icons.test.ts
new file mode 100644
index 0000000000..62501c1e98
--- /dev/null
+++ b/tests/unit/audit-activity-icons.test.ts
@@ -0,0 +1,47 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { ACTIVITY_ICONS, getActivityIcon } from "../../src/lib/audit/activityIcons";
+import { HIGH_LEVEL_ACTIONS } from "../../src/lib/audit/highLevelActions";
+
+test("getActivityIcon('provider.added') returns correct spec", () => {
+ assert.deepEqual(getActivityIcon("provider.added"), {
+ icon: "extension",
+ i18nKeyVerb: "providerAdded",
+ });
+});
+
+test("getActivityIcon('quota.pool.created') returns correct spec", () => {
+ assert.deepEqual(getActivityIcon("quota.pool.created"), {
+ icon: "pie_chart",
+ i18nKeyVerb: "quotaPoolCreated",
+ });
+});
+
+test("getActivityIcon returns fallback for unknown action", () => {
+ assert.deepEqual(getActivityIcon("some.unknown"), {
+ icon: "info",
+ i18nKeyVerb: "genericEvent",
+ });
+});
+
+test("getActivityIcon returns fallback for empty string", () => {
+ assert.deepEqual(getActivityIcon(""), { icon: "info", i18nKeyVerb: "genericEvent" });
+});
+
+test("ACTIVITY_ICONS has entry for every HIGH_LEVEL_ACTION (1:1 coverage)", () => {
+ for (const a of HIGH_LEVEL_ACTIONS as readonly string[]) {
+ assert.ok(a in ACTIVITY_ICONS, `ACTIVITY_ICONS missing entry for '${a}'`);
+ }
+});
+
+test("every ACTIVITY_ICONS entry has non-empty icon and i18nKeyVerb", () => {
+ for (const [action, spec] of Object.entries(ACTIVITY_ICONS)) {
+ assert.ok(spec.icon.length > 0, `${action}.icon empty`);
+ assert.ok(spec.i18nKeyVerb.length > 0, `${action}.i18nKeyVerb empty`);
+ }
+});
+
+test("ACTIVITY_ICONS count equals HIGH_LEVEL_ACTIONS count", () => {
+ assert.equal(Object.keys(ACTIVITY_ICONS).length, (HIGH_LEVEL_ACTIONS as readonly string[]).length);
+});
diff --git a/tests/unit/audit-high-level-actions.test.ts b/tests/unit/audit-high-level-actions.test.ts
new file mode 100644
index 0000000000..d1831963a1
--- /dev/null
+++ b/tests/unit/audit-high-level-actions.test.ts
@@ -0,0 +1,62 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { HIGH_LEVEL_ACTIONS, isHighLevelAction } from "../../src/lib/audit/highLevelActions";
+
+const ALL = HIGH_LEVEL_ACTIONS as readonly string[];
+
+test("HIGH_LEVEL_ACTIONS has exactly 26 entries", () => {
+ assert.equal(ALL.length, 26);
+});
+
+test("HIGH_LEVEL_ACTIONS has no duplicates", () => {
+ assert.equal(new Set(ALL).size, ALL.length);
+});
+
+test("isHighLevelAction true for every entry in allowlist", () => {
+ for (const a of ALL) {
+ assert.ok(isHighLevelAction(a), `Expected true for '${a}'`);
+ }
+});
+
+test("isHighLevelAction false for 'random.event'", () => {
+ assert.equal(isHighLevelAction("random.event"), false);
+});
+
+test("isHighLevelAction false for empty string", () => {
+ assert.equal(isHighLevelAction(""), false);
+});
+
+test("isHighLevelAction false for partial 'provider'", () => {
+ assert.equal(isHighLevelAction("provider"), false);
+});
+
+test("includes all 5 quota.* actions from B26", () => {
+ for (const a of [
+ "quota.pool.created",
+ "quota.pool.updated",
+ "quota.pool.deleted",
+ "quota.plan.updated",
+ "quota.store.driver_changed",
+ ]) {
+ assert.ok(ALL.includes(a), `Missing ${a}`);
+ }
+});
+
+test("includes provider lifecycle actions", () => {
+ for (const a of ["provider.added", "provider.removed", "provider.tested"]) {
+ assert.ok(ALL.includes(a));
+ }
+});
+
+test("includes combo lifecycle actions", () => {
+ for (const a of ["combo.created", "combo.updated", "combo.deleted"]) {
+ assert.ok(ALL.includes(a));
+ }
+});
+
+test("includes apikey lifecycle actions", () => {
+ for (const a of ["apikey.created", "apikey.revoked", "apikey.rotated"]) {
+ assert.ok(ALL.includes(a));
+ }
+});