fix(frontend): reconnect stream on same-session resume

This commit is contained in:
User
2026-07-14 20:53:19 +02:00
parent b1d1284cc8
commit 1393c6358e
5 changed files with 90 additions and 47 deletions
@@ -96,6 +96,26 @@ test("Resume paints the re-entry phase from the manifest (optimistic, before the
await waitFor(() => expect(useSessionStore.getState().currentPhase).toBe("F4"));
});
test("resuming the active session reconnects its EventSource", async () => {
server.use(
http.post("http://localhost:8787/sessions/:id/resume", () =>
new HttpResponse(null, { status: 204 })),
http.get("http://localhost:8787/sessions/:id", () =>
HttpResponse.json({ id: "s1", status: "open", phase: 1 })),
);
wrap();
await userEvent.click(await screen.findByText("Attiva uno"));
await userEvent.click(await screen.findByRole("button", { name: /resume/i }));
await waitFor(() => expect(FakeEventSource.instances).toHaveLength(1));
const first = FakeEventSource.instances[0];
await userEvent.click(screen.getByText("Attiva uno"));
await userEvent.click(await screen.findByRole("button", { name: /resume/i }));
await waitFor(() => expect(FakeEventSource.instances).toHaveLength(2));
expect(first.closed).toBe(true);
});
test("a failed resume keeps the panel open and does not activate the session", async () => {
server.use(http.post("http://localhost:8787/sessions/:id/resume", () => new HttpResponse(null, { status: 409 })));
wrap();