test: avoid real waits in cdp and outbound tests

This commit is contained in:
Peter Steinberger
2026-05-06 05:43:44 +01:00
parent cbaf999bd2
commit 6da5eda488
2 changed files with 38 additions and 1 deletions

View File

@@ -963,6 +963,22 @@ describe("cdp internal", () => {
const msg = JSON.parse(rawDataToString(raw)) as { id?: number; method?: string };
if (msg.method === "Target.createTarget") {
socket.send(JSON.stringify({ id: msg.id, result: { targetId: "T_BARE_WS" } }));
return;
}
if (msg.method === "Target.attachToTarget") {
socket.send(JSON.stringify({ id: msg.id, result: { sessionId: "S_BARE_WS" } }));
return;
}
if (
msg.method === "Page.enable" ||
msg.method === "Runtime.enable" ||
msg.method === "Network.enable" ||
msg.method === "DOM.enable" ||
msg.method === "Accessibility.enable" ||
msg.method === "Runtime.runIfWaitingForDebugger" ||
msg.method === "Target.detachFromTarget"
) {
socket.send(JSON.stringify({ id: msg.id, result: {} }));
}
});
});

View File

@@ -125,7 +125,28 @@ describe("runMessageAction core send routing", () => {
});
it("accepts Telegram numeric forum topic targets through plugin-owned grammar", async () => {
setActivePluginRegistry(createTestRegistry([]));
setActivePluginRegistry(
createTestRegistry([
{
pluginId: "telegram",
source: "test",
plugin: createOutboundTestPlugin({
id: "telegram",
outbound: {
deliveryMode: "direct",
sendText: vi.fn(),
},
messaging: {
normalizeTarget: (raw) =>
raw === "-1001234567890:topic:42" ? "telegram:-1001234567890:topic:42" : undefined,
targetResolver: {
looksLikeId: (raw) => raw === "-1001234567890:topic:42",
},
},
}),
},
]),
);
const result = await runMessageAction({
cfg: {