File size: 1,595 Bytes
5cb63c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { execFile } from "node:child_process";
import { promisify } from "node:util";
import { afterEach, describe, expect, it } from "vitest";
import { useAutoCleanupTempDirTracker } from "../../../test/helpers/temp-dir.js";

const execFileAsync = promisify(execFile);
const tempDirs = useAutoCleanupTempDirTracker(afterEach);

// Node CI shards do not provision Bun; selecting BUN_BIN requires real runtime proof.
describe.runIf(Boolean(process.env.BUN_BIN))("Bun desktop WebSocket transport", () => {
  it.each(["observer-close", "observer-backpressure", "observer-payload", "desktop", "portal"])(
    "preserves %s through the registered upgrade handler",
    async (mode) => {
      const root = tempDirs.make("desktop-websocket-runtime-");
      const fixture = new URL("./websocket-runtime.test-support.ts", import.meta.url).href;
      const { stdout } = await execFileAsync(
        process.env.BUN_BIN!,
        [
          "--no-env-file",
          "--no-install",
          "--eval",
          `import assert from "node:assert/strict";
import { runDesktopWebSocketRuntimeProbe } from ${JSON.stringify(fixture)};
assert.ok(process.versions.bun, "This regression requires the real Bun runtime");
await runDesktopWebSocketRuntimeProbe(${JSON.stringify(mode)});
console.log(${JSON.stringify(`desktop-runtime-ok:${mode}`)});`,
        ],
        {
          cwd: root,
          env: { PATH: process.env.PATH, HOME: root, OPENCLAW_STATE_DIR: root },
          timeout: 10_000,
        },
      );
      expect(stdout).toContain(`desktop-runtime-ok:${mode}`);
    },
    15_000,
  );
});