Skip to content

Commit aaf544d

Browse files
test(server): queue the late recording stop behind the click
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent be1cdd6 commit aaf544d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎apps/server/src/preview/ServerBrowser.test.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,11 @@ it.effect("a queued action whose timeout passes while it waits never runs", () =
27322732
const { broker, tabId } = yield* ready;
27332733
const page = contexts[0]!.page;
27342734
yield* broker.invoke({ scope, tabId, operation: "recordingStart", input: {} });
2735+
const stopRan = Promise.withResolvers<void>();
2736+
contexts[0]!.sessions.at(-1)!.detach.mockImplementationOnce(() => {
2737+
stopRan.resolve();
2738+
return new Promise<void>(() => {});
2739+
});
27352740
const started = Promise.withResolvers<void>();
27362741
const finish = Promise.withResolvers<void>();
27372742
page.emulateMedia.mockImplementationOnce(() => {
@@ -2751,20 +2756,20 @@ it.effect("a queued action whose timeout passes while it waits never runs", () =
27512756
const queued = yield* broker
27522757
.invoke<void>({ scope, tabId, operation: "click", input: { ref: "e1" }, timeoutMs: 1_000 })
27532758
.pipe(Effect.flip, Effect.forkScoped);
2754-
const stop = yield* broker
2755-
.invoke({ scope, tabId, operation: "recordingStop", input: {}, timeoutMs: 1_000 })
2756-
.pipe(Effect.exit, Effect.forkScoped);
27572759
// The host answers in arrival order, so the click is queued once this answers.
27582760
yield* broker.invoke({ scope, tabId, operation: "status", input: {} });
2761+
yield* broker
2762+
.invoke({ scope, tabId, operation: "recordingStop", input: {}, timeoutMs: 1_000 })
2763+
.pipe(Effect.ignore, Effect.forkScoped);
2764+
yield* broker.invoke({ scope, tabId, operation: "status", input: {} });
27592765
// Past the click's timeout but before the server answers it.
27602766
yield* TestClock.adjust("1200 millis");
27612767
finish.resolve();
27622768
yield* Fiber.join(slow);
27632769
expect(yield* Fiber.join(queued)).toMatchObject({ _tag: "PreviewAutomationTimeoutError" });
27642770
expect(page.locator).not.toHaveBeenCalled();
27652771
// A late stop still runs, or capture would keep going with no recording to stop.
2766-
yield* Fiber.join(stop);
2767-
expect(contexts[0]!.sessions.at(-1)!.detach).toHaveBeenCalled();
2772+
yield* Effect.promise(() => stopRan.promise);
27682773
}),
27692774
).pipe(Effect.provide(layer)),
27702775
);

0 commit comments

Comments
 (0)