feat(FN-3910): strengthen QuickChatFAB initial-open scroll regression test

Strengthens the QuickChatFAB initial-open scroll regression test with additional assertions covering the scroll behavior that was previously fixed.

Fusion-Task-Id: FN-3910
This commit is contained in:
Fusion
2026-05-10 00:21:08 -07:00
committed by gsxdsm
parent 8ee6dd9f84
commit ea6ef14b5e

View File

@@ -475,14 +475,15 @@ describe("QuickChatFAB session-first UX", () => {
});
});
it("FN-3884: snaps to bottom when first opened", async () => {
it("FN-3910: anchors to live tail on initial controlled open", async () => {
const deferredMessages = createDeferredPromise<{
messages: Array<{ id: string; sessionId: string; role: "assistant"; content: string; createdAt: string }>;
}>();
mockFetchChatMessages.mockImplementationOnce(() => deferredMessages.promise);
render(<QuickChatFAB addToast={vi.fn()} projectId="proj-1" />);
fireEvent.click(screen.getByTestId("quick-chat-fab"));
const { rerender } = render(<QuickChatFAB addToast={vi.fn()} projectId="proj-1" open={false} onOpenChange={vi.fn()} />);
rerender(<QuickChatFAB addToast={vi.fn()} projectId="proj-1" open onOpenChange={vi.fn()} />);
const messages = await screen.findByTestId("quick-chat-messages");
let scrollTopValue = 0;
@@ -496,7 +497,10 @@ describe("QuickChatFAB session-first UX", () => {
},
});
// FN-3814: install descriptors before initial messages resolve so the first-open isOpen path writes into this captured scrollTop.
// FN-3910: install descriptors before initial messages resolve so the initial-open
// useLayoutEffect branch (openingNow from isOpen false->true) writes to this scrollTop.
expect(scrollTopValue).toBe(0);
deferredMessages.resolve({
messages: [
{