Files
OmniRoute/tests/unit/webhook-edit-wizard-regression.test.ts
Khoa Võ a4d79c81aa fix(dashboard): open webhook wizard in edit mode (#9272)
Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log
2026-08-05 21:45:34 -03:00

36 lines
1.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const pageClientSource = readFileSync(
"src/app/(dashboard)/dashboard/webhooks/WebhooksPageClient.tsx",
"utf8"
);
const wizardSource = readFileSync(
"src/app/(dashboard)/dashboard/webhooks/components/AddWebhookWizard.tsx",
"utf8"
);
test("webhook edit action opens the wizard in edit mode", () => {
assert.match(pageClientSource, /const \[editingWebhook, setEditingWebhook\]/);
assert.match(pageClientSource, /const handleEditWebhook = \(webhook: WebhookItem\) => \{/);
assert.match(pageClientSource, /setEditingWebhook\(webhook\);/);
assert.match(pageClientSource, /onEdit=\{handleEditWebhook\}/);
assert.match(pageClientSource, /editingWebhook=\{editingWebhook\}/);
assert.doesNotMatch(pageClientSource, /onEdit=\{\(\) => setWizardOpen\(true\)\}/);
});
test("webhook wizard title reflects add versus edit mode", () => {
assert.match(wizardSource, /editingWebhook\?: WebhookItem \| null;/);
assert.match(wizardSource, /const isEditing = Boolean\(editingWebhook\);/);
assert.match(wizardSource, /title=\{`\$\{t\(isEditing \? "editWebhook" : "addWebhook"\)\}/);
});
test("editing an existing webhook reuses the current webhook payload", () => {
assert.match(wizardSource, /function stateFromWebhook\(webhook: WebhookItem \| null \| undefined\)/);
assert.match(wizardSource, /setState\(stateFromWebhook\(editingWebhook\)\);/);
assert.match(wizardSource, /setCreatedId\(editingWebhook\?\.id \?\? null\);/);
assert.match(wizardSource, /\.\.\.buildConfigPayload\(\),/);
assert.match(wizardSource, /step2Valid\(state, isEditing\)/);
});