mirror of
https://github.com/sinanyuntu/trade-message-center.git
synced 2026-09-17 13:22:11 +08:00
* feat: add OneTalk quote reply support * chore(task): archive 09-17-onetalk-quote-reply-protocol * chore: record journal * docs: format OneTalk DOM card collection plan * chore: release 0.8.29 * chore: release 0.8.30
63 lines
2.0 KiB
JavaScript
63 lines
2.0 KiB
JavaScript
// 验证 Service Worker 将经 contract 验证的引用目标原样路由给 MAIN。
|
|
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { ONETALK_PROTOCOL_VERSION } from "@trade-message-center/onetalk-contract";
|
|
|
|
import { createOneTalkSendCommandFlow } from "../src/onetalk/service-worker/flows/send-command-flow.ts";
|
|
|
|
const pluginScope = { channelAccountId: "account-1", deviceId: "device-1" };
|
|
|
|
test("forwards replyToMessageId only as the explicit page send command field", async () => {
|
|
const routes = [];
|
|
const frames = [];
|
|
const flow = createOneTalkSendCommandFlow({
|
|
scope: pluginScope,
|
|
bright: { send: (frame) => (frames.push(frame), true) },
|
|
pageRuntime: {
|
|
routePageCommand: async (route) => {
|
|
routes.push(route);
|
|
return { status: "delivery_unknown", reason: "send_state_lost" };
|
|
},
|
|
},
|
|
createRequestId: () => "confirmation-1",
|
|
onError: (error) => {
|
|
throw error;
|
|
},
|
|
});
|
|
|
|
flow.handle({
|
|
protocolVersion: ONETALK_PROTOCOL_VERSION,
|
|
connectionType: "plugin",
|
|
type: "send.command",
|
|
requestId: "command-1",
|
|
sendRequestId: "send-1",
|
|
scope: pluginScope,
|
|
payload: {
|
|
conversationId: "conversation-1",
|
|
content: { kind: "text", text: "reply" },
|
|
replyToMessageId: "123456",
|
|
},
|
|
});
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
|
|
assert.deepEqual(routes, [
|
|
{
|
|
channelAccountId: "account-1",
|
|
conversationId: "conversation-1",
|
|
requestId: "command-1",
|
|
command: {
|
|
action: "onetalk.send",
|
|
conversationId: "conversation-1",
|
|
content: { kind: "text", text: "reply" },
|
|
replyToMessageId: "123456",
|
|
},
|
|
},
|
|
]);
|
|
assert.deepEqual(frames[0].payload, {
|
|
status: "delivery_unknown",
|
|
reason: "send_state_lost",
|
|
});
|
|
});
|