story-kit: merge 117_story_show_startup_reconciliation_progress_in_ui

This commit is contained in:
Dave
2026-02-23 22:50:57 +00:00
parent e3d9813707
commit 85fddcb71a
7 changed files with 341 additions and 8 deletions

View File

@@ -18,6 +18,11 @@ type WsHandlers = {
onUpdate: (history: Message[]) => void;
onSessionId: (sessionId: string) => void;
onError: (message: string) => void;
onReconciliationProgress: (
storyId: string,
status: string,
message: string,
) => void;
};
let capturedWsHandlers: WsHandlers | null = null;
@@ -310,3 +315,81 @@ describe("Chat input Shift+Enter behavior", () => {
expect((input as HTMLTextAreaElement).value).toBe("Hello");
});
});
describe("Chat reconciliation banner", () => {
beforeEach(() => {
capturedWsHandlers = null;
setupMocks();
});
it("shows banner when a non-done reconciliation event is received", async () => {
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
await waitFor(() => expect(capturedWsHandlers).not.toBeNull());
act(() => {
capturedWsHandlers?.onReconciliationProgress(
"42_story_test",
"checking",
"Checking for committed work in 2_current/",
);
});
expect(
await screen.findByTestId("reconciliation-banner"),
).toBeInTheDocument();
expect(
await screen.findByText("Reconciling startup state..."),
).toBeInTheDocument();
});
it("shows event message in the banner", async () => {
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
await waitFor(() => expect(capturedWsHandlers).not.toBeNull());
act(() => {
capturedWsHandlers?.onReconciliationProgress(
"42_story_test",
"gates_running",
"Running acceptance gates…",
);
});
expect(
await screen.findByText(/Running acceptance gates/),
).toBeInTheDocument();
});
it("dismisses banner when done event is received", async () => {
render(<Chat projectPath="/tmp/project" onCloseProject={vi.fn()} />);
await waitFor(() => expect(capturedWsHandlers).not.toBeNull());
act(() => {
capturedWsHandlers?.onReconciliationProgress(
"42_story_test",
"checking",
"Checking for committed work",
);
});
expect(
await screen.findByTestId("reconciliation-banner"),
).toBeInTheDocument();
act(() => {
capturedWsHandlers?.onReconciliationProgress(
"",
"done",
"Startup reconciliation complete.",
);
});
await waitFor(() => {
expect(
screen.queryByTestId("reconciliation-banner"),
).not.toBeInTheDocument();
});
});
});