mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-17 12:20:46 +08:00
fix(weixin): report safe delivery diagnostics
This commit is contained in:
parent
64587b3b61
commit
91e2d5962a
6 changed files with 390 additions and 201 deletions
|
|
@ -208,6 +208,32 @@ test('sendText emits the iLink message envelope without reflecting the token in
|
|||
assert.doesNotMatch(calls[0].init.body, /host-only-token/);
|
||||
});
|
||||
|
||||
test('sendText preserves safe iLink business rejection codes', async (t) => {
|
||||
for (const scenario of [
|
||||
{ response: { ret: -2 }, providerCode: '-2' },
|
||||
{ response: { errcode: 45009 }, providerCode: '45009' },
|
||||
]) {
|
||||
await t.test(scenario.providerCode, async () => {
|
||||
const api = createWeixinApi({
|
||||
fetchImpl: async () => jsonResponse(scenario.response),
|
||||
});
|
||||
|
||||
await assert.rejects(
|
||||
api.sendText({
|
||||
baseUrl: 'https://ilinkai.wechat.com',
|
||||
token: 'host-only-token',
|
||||
toUserId: 'wx-user',
|
||||
text: 'Harness reply',
|
||||
contextToken: 'message-context',
|
||||
}),
|
||||
(error) => error instanceof WeixinApiError
|
||||
&& error.code === 'send-rejected'
|
||||
&& error.providerCode === scenario.providerCode,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test('getConfig requests a typing ticket for the current Weixin conversation', async () => {
|
||||
const calls = [];
|
||||
const api = createWeixinApi({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue