mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-01 04:36:26 +00:00
Reproduce synchronous scrolling during chat output
Record the scroll call that runs before the next animation frame when the last message grows. This diagnostic test is expected to fail on main. Co-authored-by: Sergey S. Volkov <16340911+js2me@users.noreply.github.com>
This commit is contained in:
co-authored by
Sergey S. Volkov
parent
8f696db2f2
commit
e8bbaf8bd4
@@ -156,6 +156,8 @@ function mountTimeline(
|
||||
};
|
||||
|
||||
return {
|
||||
rowElement,
|
||||
scrollContainer,
|
||||
render: (
|
||||
segments: Partial<StreamRenderInput["segments"]>,
|
||||
overrides?: Partial<Omit<StreamRenderInput, "segments">>,
|
||||
@@ -193,6 +195,30 @@ function mountTimeline(
|
||||
};
|
||||
}
|
||||
|
||||
it("defers scrolling until layout when output grows inside a message", async () => {
|
||||
const timeline = mountTimeline(Array.from({ length: 8 }, (_, index) => row(index)));
|
||||
await timeline.settle();
|
||||
|
||||
let scrollCalls = 0;
|
||||
timeline.scrollContainer.scrollTo = new Proxy(timeline.scrollContainer.scrollTo, {
|
||||
apply(scrollTo, element, args) {
|
||||
scrollCalls++;
|
||||
return Reflect.apply(scrollTo, element, args);
|
||||
},
|
||||
});
|
||||
|
||||
const extraContent = document.createElement("div");
|
||||
extraContent.style.height = "40px";
|
||||
await act(async () => {
|
||||
timeline.rowElement("message-7").append(extraContent);
|
||||
await Promise.resolve();
|
||||
expect(scrollCalls).toBe(0);
|
||||
});
|
||||
await timeline.settle();
|
||||
expect(scrollCalls).toBeGreaterThan(0);
|
||||
expect(timeline.distanceFromEnd()).toBe(0);
|
||||
});
|
||||
|
||||
describe("web disclosure hold", () => {
|
||||
it.each([{ isMobileBreakpoint: true }, { isMobileBreakpoint: false }])(
|
||||
"keeps the reading position when mounted history becomes virtualized (compact: $isMobileBreakpoint)",
|
||||
|
||||
Reference in New Issue
Block a user