perf(test): remove fixed waits in node invoke bypass e2e

This commit is contained in:
Peter Steinberger 2026-02-18 21:52:55 +00:00
parent 48b0b55fa4
commit f3b7b51132
1 changed files with 11 additions and 8 deletions

View File

@ -19,6 +19,13 @@ import {
installGatewayTestHooks({ scope: "suite" });
async function expectNoForwardedInvoke(hasInvoke: () => boolean): Promise<void> {
// Yield a couple of macrotasks so any accidental async forwarding would fire.
await sleep(0);
await sleep(0);
expect(hasInvoke()).toBe(false);
}
async function getConnectedNodeId(ws: WebSocket): Promise<string> {
const nodes = await rpcReq<{ nodes?: Array<{ nodeId: string; connected?: boolean }> }>(
ws,
@ -171,8 +178,7 @@ describe("node.invoke approval bypass", () => {
expect(res.ok).toBe(false);
expect(res.error?.message ?? "").toContain("rawCommand does not match command");
await sleep(50);
expect(sawInvoke).toBe(false);
await expectNoForwardedInvoke(() => sawInvoke);
ws.close();
node.stop();
@ -201,8 +207,7 @@ describe("node.invoke approval bypass", () => {
expect(res.error?.message ?? "").toContain("params.runId");
// Ensure the node didn't receive the invoke (gateway should fail early).
await sleep(50);
expect(sawInvoke).toBe(false);
await expectNoForwardedInvoke(() => sawInvoke);
ws.close();
node.stop();
@ -225,8 +230,7 @@ describe("node.invoke approval bypass", () => {
expect(res.ok).toBe(false);
expect(res.error?.message ?? "").toContain("exec.approvals.node");
await sleep(50);
expect(sawInvoke).toBe(false);
await expectNoForwardedInvoke(() => sawInvoke);
ws.close();
node.stop();
@ -305,8 +309,7 @@ describe("node.invoke approval bypass", () => {
});
expect(invoke.ok).toBe(false);
expect(invoke.error?.message ?? "").toContain("not valid for this device");
await sleep(50);
expect(sawInvoke).toBe(false);
await expectNoForwardedInvoke(() => sawInvoke);
ws.close();
wsOtherDevice.close();