mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-23 23:52:18 +03:00
⭐5 — Remove 3 webhook events declarados mas nunca emitidos (provider.error/recovered, combo.switched): union 7→4, z.enum com 400 em ghost values (era z.string pass-through). Breaking intencional + testado. TDD 3/3, i18n B-pattern (42 __MISSING__). Base-red #9985 inherited.
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { z } from "zod";
|
|
import {
|
|
EVENT_DESCRIPTIONS,
|
|
WEBHOOK_EVENT_VALUES,
|
|
} from "../../src/lib/webhooks/eventDescriptions.ts";
|
|
|
|
describe("webhook catalogue", () => {
|
|
it("no longer declares provider.error/recovered/combo.switched", () => {
|
|
const keys = Object.keys(EVENT_DESCRIPTIONS);
|
|
assert.equal(keys.includes("provider.error"), false);
|
|
assert.equal(keys.includes("provider.recovered"), false);
|
|
assert.equal(keys.includes("combo.switched"), false);
|
|
assert.equal(keys.length, 4); // completed, failed, quota.exceeded, test.ping
|
|
});
|
|
|
|
it("rejected legacy events via zod (400)", () => {
|
|
const schema = z.enum(WEBHOOK_EVENT_VALUES as unknown as [string, ...string[]]);
|
|
assert.equal(schema.safeParse("provider.error").success, false);
|
|
assert.equal(schema.safeParse("provider.recovered").success, false);
|
|
assert.equal(schema.safeParse("combo.switched").success, false);
|
|
assert.equal(schema.safeParse("request.completed").success, true);
|
|
assert.equal(schema.safeParse("request.failed").success, true);
|
|
assert.equal(schema.safeParse("quota.exceeded").success, true);
|
|
assert.equal(schema.safeParse("test.ping").success, true);
|
|
});
|
|
|
|
it("notifyWebhookEvent still available for remaining events", async () => {
|
|
const { notifyWebhookEvent } = await import("../../src/lib/webhookDispatcher.ts");
|
|
assert.equal(typeof notifyWebhookEvent, "function");
|
|
});
|
|
});
|