Skip to content

Commit 8d535fb

Browse files
authored
test(qa): cover Crabline Zalo transport (#99303)
1 parent 59b08b4 commit 8d535fb

4 files changed

Lines changed: 86 additions & 7 deletions

File tree

extensions/qa-lab/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@openclaw/plugin-sdk": "workspace:*",
1717
"@openclaw/slack": "workspace:*",
1818
"@openclaw/whatsapp": "workspace:*",
19-
"@openclaw/crabline": "0.1.7",
19+
"@openclaw/crabline": "0.1.8",
2020
"openclaw": "workspace:*"
2121
},
2222
"peerDependencies": {

extensions/qa-lab/src/crabline-transport.test.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,85 @@ describe("crabline transport", () => {
617617
});
618618
});
619619

620+
it("configures Zalo and normalizes native message sends", async () => {
621+
await withTempDir("qa-crabline-transport-", async (outputDir) => {
622+
const transport = await createQaCrablineTransportAdapter({
623+
outputDir,
624+
selection: createSelection("zalo"),
625+
state: createQaBusState(),
626+
});
627+
628+
try {
629+
expect(transport.requiredPluginIds).toEqual(["zalo"]);
630+
expect(transport.createGatewayConfig({ baseUrl: "http://127.0.0.1:1" })).toMatchObject({
631+
channels: {
632+
zalo: {
633+
allowFrom: ["*"],
634+
botToken: "crabline-zalo-bot-token",
635+
dmPolicy: "open",
636+
enabled: true,
637+
groupAllowFrom: ["*"],
638+
groupPolicy: "open",
639+
},
640+
},
641+
});
642+
expect(transport.createRuntimeEnvPatch?.()).toMatchObject({
643+
ZALO_API_URL: expect.stringMatching(/^http:\/\/127\.0\.0\.1:\d+$/u),
644+
ZALO_BOT_TOKEN: "crabline-zalo-bot-token",
645+
});
646+
647+
await transport.state.addInboundMessage({
648+
conversation: { id: "qa-group", kind: "group" },
649+
senderId: "alice",
650+
senderName: "Alice",
651+
text: "Zalo baseline marker check.",
652+
});
653+
const delivery = transport.buildAgentDelivery({ target: "group:qa-group" });
654+
expect(delivery).toEqual({
655+
channel: "zalo",
656+
replyChannel: "zalo",
657+
replyTo: "qa-group",
658+
to: "qa-group",
659+
});
660+
661+
const manifest = JSON.parse(
662+
await fs.readFile(path.join(outputDir, OPENCLAW_CRABLINE_MANIFEST_PATH), "utf8"),
663+
) as {
664+
botToken: string;
665+
endpoints: { apiRoot: string };
666+
};
667+
const { response, release } = await fetchWithSsrFGuard({
668+
url: `${manifest.endpoints.apiRoot}/bot${manifest.botToken}/sendMessage`,
669+
init: {
670+
body: JSON.stringify({
671+
chat_id: delivery.to,
672+
text: "assistant via fake zalo",
673+
}),
674+
headers: { "content-type": "application/json" },
675+
method: "POST",
676+
},
677+
policy: { allowPrivateNetwork: true },
678+
auditContext: "qa-lab-crabline-zalo-transport-test",
679+
});
680+
await release();
681+
expect(response.ok).toBe(true);
682+
683+
await expect(
684+
transport.waitForOutbound({
685+
conversation: { id: "qa-group", kind: "group" },
686+
textIncludes: "assistant via fake zalo",
687+
timeoutMs: 1_000,
688+
}),
689+
).resolves.toMatchObject({
690+
conversation: { id: "qa-group", kind: "group" },
691+
text: "assistant via fake zalo",
692+
});
693+
} finally {
694+
await transport.cleanup?.();
695+
}
696+
});
697+
});
698+
620699
it("injects inbound messages through Crabline and mirrors Telegram sends into normalized state", async () => {
621700
await withTempDir("qa-crabline-transport-", async (outputDir) => {
622701
const transport = await createQaCrablineTransportAdapter({

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
minimumReleaseAge: 2880
88

99
minimumReleaseAgeExclude:
10-
- "@openclaw/[email protected].7"
10+
- "@openclaw/[email protected].8"
1111
- "@openclaw/[email protected]"
1212
- "@openclaw/[email protected]"
1313
- "acpx"

0 commit comments

Comments
 (0)