From 391351e051a22868eb0e05521d6ab9f42af11240 Mon Sep 17 00:00:00 2001 From: Fusion Date: Thu, 14 May 2026 08:54:13 -0700 Subject: [PATCH] =?UTF-8?q?test(FN-4477):=20complete=20Step=202=20?= =?UTF-8?q?=E2=80=94=20add=20reopen=20restore=20regressions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fusion-Task-Id: FN-4477 Fusion-Task-Lineage: 1001fb48-1eed-493c-9067-8234f462ac49 --- .../__tests__/QuickChatFAB.test.tsx | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/packages/dashboard/app/components/__tests__/QuickChatFAB.test.tsx b/packages/dashboard/app/components/__tests__/QuickChatFAB.test.tsx index fe3943a8c..539c52cc0 100644 --- a/packages/dashboard/app/components/__tests__/QuickChatFAB.test.tsx +++ b/packages/dashboard/app/components/__tests__/QuickChatFAB.test.tsx @@ -221,6 +221,91 @@ describe("QuickChatFAB session-first UX", () => { expect(screen.getByRole("option", { name: /Claude thread/i })).toBeInTheDocument(); }); + it("reopen restores the newest active session by max(lastMessageAt, updatedAt)", async () => { + mockFetchChatSessions.mockResolvedValueOnce({ + sessions: [ + { + ...modelSession, + id: "older-updated", + updatedAt: "2026-05-13T10:00:00.000Z", + lastMessageAt: "2026-05-13T10:00:00.000Z", + }, + { + ...agentTwoSession, + id: "newer-last-message", + updatedAt: "2026-05-13T09:00:00.000Z", + lastMessageAt: "2026-05-13T11:00:00.000Z", + }, + ], + }); + + render(); + const fab = screen.getByTestId("quick-chat-fab"); + fireEvent.click(fab); + + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("newer-last-message"); + }); + + fireEvent.change(screen.getByTestId("quick-chat-session-dropdown"), { target: { value: "older-updated" } }); + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("older-updated"); + }); + + fireEvent.click(screen.getByTestId("quick-chat-close")); + fireEvent.click(fab); + + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("newer-last-message"); + }); + }); + + it("reopen still skips archived newest sessions", async () => { + mockFetchChatSessions.mockResolvedValueOnce({ + sessions: [ + { + ...modelSessionAnthropic, + id: "archived-newest", + status: "archived", + updatedAt: "2026-05-13T12:00:00.000Z", + lastMessageAt: "2026-05-13T12:00:00.000Z", + }, + { + ...agentTwoSession, + id: "active-latest", + updatedAt: "2026-05-13T11:00:00.000Z", + lastMessageAt: "2026-05-13T11:00:00.000Z", + }, + { + ...modelSession, + id: "active-older", + updatedAt: "2026-05-13T10:00:00.000Z", + lastMessageAt: "2026-05-13T10:00:00.000Z", + }, + ], + }); + + render(); + const fab = screen.getByTestId("quick-chat-fab"); + fireEvent.click(fab); + + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("active-latest"); + }); + + fireEvent.change(screen.getByTestId("quick-chat-session-dropdown"), { target: { value: "active-older" } }); + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("active-older"); + }); + + fireEvent.click(screen.getByTestId("quick-chat-close")); + fireEvent.click(fab); + + await waitFor(() => { + expect(screen.getByTestId("quick-chat-session-dropdown")).toHaveValue("active-latest"); + }); + }); + it("falls back to the existing default target when there are no prior sessions", async () => { mockFetchChatSessions.mockResolvedValueOnce({ sessions: [] });