fix(webhooks): followup ghost-event dispatcher tests + vi i18n (#11050) (#11130)

Validated on the combined batch board over release/v3.8.50 tip d91238b7: static gates clean, typecheck:core clean, focused tests green.

Closes the two #11050 blockers: dispatcher tests now derive from WEBHOOK_EVENT_VALUES (no more TypeError on removed events) and vi.json carries a real translation. Thank you @maxmad64bis!
This commit is contained in:
Dizzle
2026-08-22 19:39:01 +02:00
committed by GitHub
parent 02a078e95f
commit b44f22a949
5 changed files with 22 additions and 31 deletions

View File

@@ -12207,7 +12207,7 @@
},
"omni-webhooks": {
"name": "Webhook",
"description": "__MISSING__:Register, list, test, and remove webhook endpoints. Configure event subscriptions (request.completed, request.failed, quota.exceeded, etc.) and manage delivery retries."
"description": "Đăng ký, liệt kê, kiểm thử và xoá các endpoint webhook. Cấu hình đăng ký sự kiện (request.completed, request.failed, quota.exceeded, v.v.) và quản lý thử lại giao hàng."
},
"omni-mcp": {
"name": "Máy chủ MCP",

View File

@@ -1,5 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
import { WEBHOOK_EVENT_VALUES } from "../../src/lib/webhooks/eventDescriptions.ts";
const { buildDiscordPayload } = await import("../../src/lib/webhooks/integrations/discord.ts");
@@ -14,15 +15,7 @@ test("buildDiscordPayload — request.failed produces embed with model", () => {
});
test("buildDiscordPayload — all WEBHOOK_EVENTS return object with content or embeds", () => {
const events = [
"request.completed",
"request.failed",
"provider.error",
"provider.recovered",
"quota.exceeded",
"combo.switched",
"test.ping",
] as const;
const events = WEBHOOK_EVENT_VALUES;
for (const event of events) {
const payload = buildDiscordPayload(event, {});
assert.ok(
@@ -33,7 +26,7 @@ test("buildDiscordPayload — all WEBHOOK_EVENTS return object with content or e
});
test("buildDiscordPayload — embeds have title and color fields", () => {
const payload = buildDiscordPayload("provider.error", { provider: "openai" });
const payload = buildDiscordPayload("request.failed", { provider: "openai" });
assert.ok(Array.isArray(payload.embeds) && payload.embeds.length > 0, "should have embeds");
const embed = payload.embeds![0];
assert.ok(typeof embed.title === "string" && embed.title.length > 0, "embed must have title");

View File

@@ -1,5 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
import { WEBHOOK_EVENT_VALUES } from "../../src/lib/webhooks/eventDescriptions.ts";
const { buildSlackPayload } = await import("../../src/lib/webhooks/integrations/slack.ts");
@@ -30,8 +31,8 @@ test("buildSlackPayload — test.ping produces a ping/test message", () => {
);
});
test("buildSlackPayload — provider.error includes provider context", () => {
const payload = buildSlackPayload("provider.error", { provider: "openai", model: "gpt-4" });
test("buildSlackPayload — request.failed includes provider context", () => {
const payload = buildSlackPayload("request.failed", { provider: "openai" });
const combined = JSON.stringify(payload);
assert.ok(
combined.includes("Provider") ||
@@ -43,15 +44,7 @@ test("buildSlackPayload — provider.error includes provider context", () => {
});
test("buildSlackPayload — all WEBHOOK_EVENTS produce valid payloads with text field", () => {
const events = [
"request.completed",
"request.failed",
"provider.error",
"provider.recovered",
"quota.exceeded",
"combo.switched",
"test.ping",
] as const;
const events = WEBHOOK_EVENT_VALUES;
for (const event of events) {
const payload = buildSlackPayload(event, {});
assert.ok(

View File

@@ -1,5 +1,6 @@
import test from "node:test";
import assert from "node:assert/strict";
import { WEBHOOK_EVENT_VALUES } from "../../src/lib/webhooks/eventDescriptions.ts";
const { buildTelegramPayload, buildTelegramUrl } =
await import("../../src/lib/webhooks/integrations/telegram.ts");
@@ -77,15 +78,7 @@ test("buildTelegramPayload — chat_id matches provided value for groups", () =>
});
test("buildTelegramPayload — all WEBHOOK_EVENTS produce valid payloads with chat_id", () => {
const events = [
"request.completed",
"request.failed",
"provider.error",
"provider.recovered",
"quota.exceeded",
"combo.switched",
"test.ping",
] as const;
const events = WEBHOOK_EVENT_VALUES;
for (const event of events) {
const payload = buildTelegramPayload(event, {}, "99999");
assert.equal(payload.chat_id, "99999");

View File

@@ -30,4 +30,16 @@ describe("webhook catalogue", () => {
const { notifyWebhookEvent } = await import("../../src/lib/webhookDispatcher.ts");
assert.equal(typeof notifyWebhookEvent, "function");
});
it("every builder accepts every value in WEBHOOK_EVENT_VALUES without throwing", async () => {
const { buildDiscordPayload } = await import("../../src/lib/webhooks/integrations/discord.ts");
const { buildSlackPayload } = await import("../../src/lib/webhooks/integrations/slack.ts");
const { buildTelegramPayload } =
await import("../../src/lib/webhooks/integrations/telegram.ts");
for (const event of WEBHOOK_EVENT_VALUES) {
assert.doesNotThrow(() => buildDiscordPayload(event, {}));
assert.doesNotThrow(() => buildSlackPayload(event, {}));
assert.doesNotThrow(() => buildTelegramPayload(event, {}, "99999"));
}
});
});