Add formal to test enterprise webhook replay capability
This commit is contained in:
1 parent
ce066206df
commit
35720fa36a
14 files changed
+1305
-263
No files matched your search
@@ -792,6 +792,73 @@ describe("corps list & current", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("corps replay-test", () => {
|
||||
test("fails if production corp has no bound test corp", async () => {
|
||||
setupTestEnv();
|
||||
const result = await runCli(["corps", "replay-test", "corp-test"]);
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.stderr).toContain("has no bound test enterprise");
|
||||
expect(result.stderr).toContain("seal-use corps bind-test");
|
||||
});
|
||||
|
||||
test("pulls production record and executes dry-run to bound test enterprise", async () => {
|
||||
setupTestEnv();
|
||||
await runCli(["corps", "bind-test", "corp-prod", "corp-test", "--confirm"]);
|
||||
|
||||
const mockRun = {
|
||||
id: "run-prod-001",
|
||||
sourceSystem: "hosecloud",
|
||||
sourceDocumentSN: "BX-PROD-001",
|
||||
sourceDocumentId: "DOC-PROD-001",
|
||||
document: {
|
||||
id: "DOC-PROD-001",
|
||||
sn: "BX-PROD-001",
|
||||
fields: [{ key: "f1", label: "项目", type: "TEXT", value: "团建" }]
|
||||
}
|
||||
};
|
||||
|
||||
globalThis.fetch = (async (input: RequestInfo | URL) => {
|
||||
const requestUrl =
|
||||
typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
||||
|
||||
if (requestUrl.includes("/api/v1/approvals")) {
|
||||
return jsonResponse({ data: { records: [mockRun] } });
|
||||
}
|
||||
if (requestUrl.includes("api/v1/system/preferences/approval-style")) {
|
||||
return jsonResponse({
|
||||
data: {
|
||||
integrations: [
|
||||
{
|
||||
type: "webhook",
|
||||
id: "wh-1",
|
||||
name: "测试通道",
|
||||
mode: "assisted",
|
||||
incomingDocumentWebhook: { id: "wh-1", url: "https://test.example/wh" },
|
||||
outgoingResultWebhook: "https://test.example/out",
|
||||
incomingManualResultWebhook: { id: "wh-1", url: "https://test.example/manual" },
|
||||
secret: "sec"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
return jsonResponse({ error: "not found" }, 404);
|
||||
}) as any;
|
||||
|
||||
const result = await runCli(["corps", "replay-test", "corp-prod", "--dry-run"]);
|
||||
expect(result.isError).toBe(false);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stderr).toContain("正式企业「Acme Production」");
|
||||
expect(result.stderr).toContain("测试企业「Acme Staging Test」");
|
||||
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
expect(parsed.dryRun).toBe(true);
|
||||
expect(parsed.sourceCorp.id).toBe("corp-prod");
|
||||
expect(parsed.targetCorp.id).toBe("corp-test");
|
||||
expect(parsed.document.documentSN).toBe("BX-PROD-001");
|
||||
});
|
||||
});
|
||||
|
||||
function mockSealSyncRequests(options: {
|
||||
onMutation?: (method: string, path: string, body?: unknown) => void;
|
||||
} = {}) {
|
||||
|
||||
Reference in new issue
Block a user