mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:58:25 +00:00
perf(test): remove fixed waits in node invoke bypass e2e
This commit is contained in:
@@ -19,6 +19,13 @@ import {
|
|||||||
|
|
||||||
installGatewayTestHooks({ scope: "suite" });
|
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> {
|
async function getConnectedNodeId(ws: WebSocket): Promise<string> {
|
||||||
const nodes = await rpcReq<{ nodes?: Array<{ nodeId: string; connected?: boolean }> }>(
|
const nodes = await rpcReq<{ nodes?: Array<{ nodeId: string; connected?: boolean }> }>(
|
||||||
ws,
|
ws,
|
||||||
@@ -171,8 +178,7 @@ describe("node.invoke approval bypass", () => {
|
|||||||
expect(res.ok).toBe(false);
|
expect(res.ok).toBe(false);
|
||||||
expect(res.error?.message ?? "").toContain("rawCommand does not match command");
|
expect(res.error?.message ?? "").toContain("rawCommand does not match command");
|
||||||
|
|
||||||
await sleep(50);
|
await expectNoForwardedInvoke(() => sawInvoke);
|
||||||
expect(sawInvoke).toBe(false);
|
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
node.stop();
|
node.stop();
|
||||||
@@ -201,8 +207,7 @@ describe("node.invoke approval bypass", () => {
|
|||||||
expect(res.error?.message ?? "").toContain("params.runId");
|
expect(res.error?.message ?? "").toContain("params.runId");
|
||||||
|
|
||||||
// Ensure the node didn't receive the invoke (gateway should fail early).
|
// Ensure the node didn't receive the invoke (gateway should fail early).
|
||||||
await sleep(50);
|
await expectNoForwardedInvoke(() => sawInvoke);
|
||||||
expect(sawInvoke).toBe(false);
|
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
node.stop();
|
node.stop();
|
||||||
@@ -225,8 +230,7 @@ describe("node.invoke approval bypass", () => {
|
|||||||
expect(res.ok).toBe(false);
|
expect(res.ok).toBe(false);
|
||||||
expect(res.error?.message ?? "").toContain("exec.approvals.node");
|
expect(res.error?.message ?? "").toContain("exec.approvals.node");
|
||||||
|
|
||||||
await sleep(50);
|
await expectNoForwardedInvoke(() => sawInvoke);
|
||||||
expect(sawInvoke).toBe(false);
|
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
node.stop();
|
node.stop();
|
||||||
@@ -305,8 +309,7 @@ describe("node.invoke approval bypass", () => {
|
|||||||
});
|
});
|
||||||
expect(invoke.ok).toBe(false);
|
expect(invoke.ok).toBe(false);
|
||||||
expect(invoke.error?.message ?? "").toContain("not valid for this device");
|
expect(invoke.error?.message ?? "").toContain("not valid for this device");
|
||||||
await sleep(50);
|
await expectNoForwardedInvoke(() => sawInvoke);
|
||||||
expect(sawInvoke).toBe(false);
|
|
||||||
|
|
||||||
ws.close();
|
ws.close();
|
||||||
wsOtherDevice.close();
|
wsOtherDevice.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user