@@ -59,6 +59,17 @@ async function withEnv<T>(env: Record<string, string>, callback: () => Promise<T
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
| 62 | +async function waitUntil(matches: () => boolean, label: string): Promise<void> { |
| 63 | +const startedAt = Date.now(); |
| 64 | +while (Date.now() - startedAt < 1000) { |
| 65 | +if (matches()) { |
| 66 | +return; |
| 67 | +} |
| 68 | +await new Promise((resolve) => setTimeout(resolve, 20)); |
| 69 | +} |
| 70 | +throw new Error(`timed out waiting for ${label}`); |
| 71 | +} |
| 72 | + |
62 | 73 | async function startTcpFixtureServer(handler: (socket: Socket) => void): Promise<{ |
63 | 74 | port: number; |
64 | 75 | stop: () => Promise<void>; |
@@ -303,6 +314,33 @@ describe("release user journey assertions", () => {
|
303 | 314 | } |
304 | 315 | }); |
305 | 316 | |
| 317 | +it("cancels successful ClickClack inbound response bodies", async () => { |
| 318 | +const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-")); |
| 319 | +const home = path.join(root, "home"); |
| 320 | +let socketClosed = false; |
| 321 | +const server = await startTcpFixtureServer((socket) => { |
| 322 | +socket.on("close", () => { |
| 323 | +socketClosed = true; |
| 324 | +}); |
| 325 | +socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nleft-open"); |
| 326 | +}); |
| 327 | + |
| 328 | +try { |
| 329 | +await expect( |
| 330 | +withEnv({ HOME: home, OPENCLAW_RELEASE_USER_JOURNEY_HTTP_TIMEOUT_MS: "1000" }, () => |
| 331 | +runReleaseUserJourneyAssertion("post-clickclack-inbound", [ |
| 332 | +`http://127.0.0.1:${server.port}`, |
| 333 | +"hello", |
| 334 | +]), |
| 335 | +), |
| 336 | +).resolves.toBeUndefined(); |
| 337 | +await waitUntil(() => socketClosed, "ClickClack inbound socket close"); |
| 338 | +} finally { |
| 339 | +await server.stop(); |
| 340 | +rmSync(root, { force: true, recursive: true }); |
| 341 | +} |
| 342 | +}); |
| 343 | + |
306 | 344 | it("bounds stalled ClickClack fixture HTTP probes", async () => { |
307 | 345 | const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-")); |
308 | 346 | const home = path.join(root, "home"); |
|