mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Coverage 83.6 to 87.36% lines, 81.63 to 84.14% branches. Mutation testing across five packages: image-engine 85, media-engine 92, doc-engine 87, shared+enterprise 86, apps/api security and jobs slice. Runs all five lanes weekly. Fixes the silently-broken mutation CI (babel pin), a redact-pdf envelope-shape test bug, an untested enterprise license valid-signature path, and an audit test that only exercised a hand-copied reproduction. Test and config only, no product code changes beyond the babel pin and one test-only oidc export. Full suite: 16,712 pass, 0 fail.
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
ALL_AUDIT_EVENTS,
|
|
registerAuditEvents,
|
|
} from "../../../packages/shared/src/audit-events.js";
|
|
|
|
// registerAuditEvents appends only events not already present. Pins the
|
|
// `!includes` dedup guard, the push, and the loop.
|
|
describe("registerAuditEvents", () => {
|
|
it("appends a genuinely new event", () => {
|
|
const novel = "CUSTOM_EVENT_ONE";
|
|
expect(ALL_AUDIT_EVENTS).not.toContain(novel);
|
|
registerAuditEvents([novel]);
|
|
expect(ALL_AUDIT_EVENTS).toContain(novel);
|
|
});
|
|
|
|
it("does not duplicate an already-registered core event (kills the !includes guard)", () => {
|
|
const before = ALL_AUDIT_EVENTS.filter((e) => e === "LOGIN_SUCCESS").length;
|
|
registerAuditEvents(["LOGIN_SUCCESS"]);
|
|
const after = ALL_AUDIT_EVENTS.filter((e) => e === "LOGIN_SUCCESS").length;
|
|
expect(before).toBe(1);
|
|
expect(after).toBe(1);
|
|
});
|
|
|
|
it("adds only the new entries from a mixed list, iterating every element", () => {
|
|
registerAuditEvents(["LOGOUT", "CUSTOM_EVENT_TWO"]);
|
|
expect(ALL_AUDIT_EVENTS.filter((e) => e === "LOGOUT").length).toBe(1);
|
|
expect(ALL_AUDIT_EVENTS).toContain("CUSTOM_EVENT_TWO");
|
|
});
|
|
|
|
it("an empty list is a no-op", () => {
|
|
const len = ALL_AUDIT_EVENTS.length;
|
|
registerAuditEvents([]);
|
|
expect(ALL_AUDIT_EVENTS.length).toBe(len);
|
|
});
|
|
});
|