feat(FN-4590): add initial-open scroll-anchor regression test for QuickChat
Adds a regression test for scroll anchoring behavior on initial open of the QuickChatFAB component. Fusion-Task-Id: FN-4590
This commit is contained in:
@@ -1030,4 +1030,30 @@ describe("QuickChatFAB session-first UX", () => {
|
||||
expect(scrollTopValue).toBe(scrollHeightValue);
|
||||
});
|
||||
});
|
||||
|
||||
it("FN-4590: snaps to bottom on controlled initial open by overwriting a non-zero starting scrollTop", async () => {
|
||||
mockFetchChatMessages.mockResolvedValueOnce({
|
||||
messages: [{ id: "msg-open", sessionId: "session-model", role: "assistant", content: "Loaded", createdAt: new Date().toISOString() }],
|
||||
});
|
||||
|
||||
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 = 200;
|
||||
const scrollHeightValue = 1600;
|
||||
Object.defineProperty(messages, "scrollHeight", { configurable: true, get: () => scrollHeightValue });
|
||||
Object.defineProperty(messages, "scrollTop", {
|
||||
configurable: true,
|
||||
get: () => scrollTopValue,
|
||||
set: (value: number) => {
|
||||
scrollTopValue = value;
|
||||
},
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(scrollTopValue).toBe(scrollHeightValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user