fix(frontend): deduplicate live workflow activity
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { act, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { http, HttpResponse, delay } from "msw";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
@@ -45,7 +45,7 @@ test("New session starts prewarm without delaying composer focus", async () => {
|
||||
expect(composer).toHaveClass("thot-awaiting-input");
|
||||
});
|
||||
|
||||
test("shows the question and creation timer before POST /sessions resolves, then opens SSE", async () => {
|
||||
test("records the prompt without central duplication, then opens the live log", async () => {
|
||||
let releaseCreate!: () => void;
|
||||
const createMayFinish = new Promise<void>((resolve) => { releaseCreate = resolve; });
|
||||
server.use(
|
||||
@@ -60,20 +60,20 @@ test("shows the question and creation timer before POST /sessions resolves, then
|
||||
await userEvent.type(composer, "How many patients?");
|
||||
await userEvent.click(screen.getByRole("button", { name: /send/i }));
|
||||
|
||||
expect(await screen.findByText("How many patients?", { selector: "p" })).toBeInTheDocument();
|
||||
expect(screen.getByText("Creating session…")).toBeInTheDocument();
|
||||
expect(screen.getByText(/\d+s/)).toBeInTheDocument();
|
||||
expect(screen.queryByText("How many patients?", { selector: "p" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Creating session…")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/\d+s/)).not.toBeInTheDocument();
|
||||
expect(useSessionStore.getState().activityLog[0]).toEqual({
|
||||
kind: "prompt",
|
||||
phase: "F1",
|
||||
text: "How many patients?",
|
||||
});
|
||||
expect(FakeEventSource.instances).toHaveLength(0);
|
||||
|
||||
releaseCreate();
|
||||
await waitFor(() => expect(FakeEventSource.instances).toHaveLength(1));
|
||||
expect(screen.getByText("How many patients?", { selector: "p" })).toBeInTheDocument();
|
||||
expect(screen.getByText("Analyzing question…")).toBeInTheDocument();
|
||||
act(() => FakeEventSource.instances[0].emit({ type: "text_delta", text: "Inspecting cohort" }));
|
||||
expect(await screen.findByRole("log", { name: "Live model activity" }))
|
||||
.toHaveTextContent("Inspecting cohort");
|
||||
expect(screen.queryByText("Analyzing question…")).not.toBeInTheDocument();
|
||||
expect(useSessionStore.getState().currentPhase).toBe("F1");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user