Files
OmniRoute/tests/unit/audit-activity-icons.test.ts
diegosouzapw 33d826f625 test(audit): update allowlist+icons tests for new actions + add real-actions coverage (B/G3)
- audit-high-level-actions.test.ts: replace old provider.added/combo/apikey assertions
  with new provider.credentials.*, auth.login.*, sync.token.* and settings assertions.
  Count still 26.
- audit-activity-icons.test.ts: replace provider.added spec check with
  provider.credentials.created + auth.login.success spot checks.
- audit-allowlist-real-actions.test.ts (new): strict 1:1 HIGH_LEVEL_ACTIONS <->
  ACTIVITY_ICONS, all 26 real repo actions present, isHighLevelAction/getActivityIcon
  spot assertions.
2026-05-28 12:31:39 -03:00

56 lines
2.0 KiB
TypeScript

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";
// B/G3: updated to reflect real action names aligned with logAuditEvent emitters.
test("getActivityIcon('provider.credentials.created') returns correct spec", () => {
assert.deepEqual(getActivityIcon("provider.credentials.created"), {
icon: "extension",
i18nKeyVerb: "providerCredentialsCreated",
});
});
test("getActivityIcon('auth.login.success') returns correct spec", () => {
assert.deepEqual(getActivityIcon("auth.login.success"), {
icon: "login",
i18nKeyVerb: "authLoginSuccess",
});
});
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);
});