feat: 任务领取/找回支持企微身份票据,领取自动绑定催办通道
This commit is contained in:
42
tests/partner-wecom-claim.test.mjs
Normal file
42
tests/partner-wecom-claim.test.mjs
Normal file
@@ -0,0 +1,42 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const routeSource = readFileSync(
|
||||
new URL("../app/api/partner/route.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("partner route accepts identityTicket for wecom-backed claim", () => {
|
||||
assert.match(routeSource, /identityTicket\?: string/);
|
||||
assert.match(routeSource, /verifyWecomIdentityTicket/);
|
||||
assert.match(routeSource, /resolveWecomClaimant/);
|
||||
});
|
||||
|
||||
test("claim keeps manual wechat/phone path untouched when no ticket", () => {
|
||||
assert.match(
|
||||
routeSource,
|
||||
/请输入正确的微信号或手机号/,
|
||||
"manual validation message preserved",
|
||||
);
|
||||
assert.match(
|
||||
routeSource,
|
||||
/VALUES \(\?, \?, \?, '外部KOC', 0, 0\)\s*\n\s*ON CONFLICT\(id\) DO UPDATE SET\s*\n\s*name = excluded\.name,\s*\n\s*wecom_name = excluded\.wecom_name`/,
|
||||
"manual partner upsert statement preserved",
|
||||
);
|
||||
});
|
||||
|
||||
test("claim with ticket upserts wecom_external_user_id for reminders", () => {
|
||||
assert.match(
|
||||
routeSource,
|
||||
/wecom_external_user_id = excluded\.wecom_external_user_id/,
|
||||
);
|
||||
});
|
||||
|
||||
test("recover builds dynamic partner candidates including wecom identity", () => {
|
||||
assert.match(
|
||||
routeSource,
|
||||
/wecomPartnerId \? \[wecomPartnerId\] : \[partnerId, legacyPartnerId\]/,
|
||||
);
|
||||
assert.match(routeSource, /\.bind\(task\.task_type, task\.task_type, task\.id, \.\.\.partnerCandidates\)/);
|
||||
});
|
||||
Reference in New Issue
Block a user