43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
|
|
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\)/);
|
||
|
|
});
|