const container = {
scrollHeight,
scrollTop,
clientHeight,
style: { overflowY } as unknown as CSSStyleDeclaration,
};
// Make getComputedStyle return the overflowY value
vi.spyOn(window, "getComputedStyle").mockReturnValue({
overflowY,
} as unknown as CSSStyleDeclaration);
const host = {
updateComplete: Promise.resolve(),
querySelector: vi.fn().mockReturnValue(container),
style: { setProperty: vi.fn() } as unknown as CSSStyleDeclaration,
chatScrollFrame: null as number | null,
chatScrollTimeout: null as number | null,
chatHasAutoScrolled: false,
chatUserNearBottom: true,
chatNewMessagesBelow: false,
logsScrollFrame: null as number | null,
logsAtBottom: true,
topbarObserver: null as ResizeObserver | null,
};
return { host, container };
}
function createScrollEvent(scrollHeight: number, scrollTop: number, clientHeight: number) { return {
currentTarget: { scrollHeight, scrollTop, clientHeight },
} as unknown as Event;
}
it("sets chatUserNearBottom=false when user scrolled up past one long message (>200px <450px)", () => { const { host } = createScrollHost({}); // distanceFromBottom = 2000 - 1250 - 400 = 350 → old threshold would say "near", new says "near" // distanceFromBottom = 2000 - 1100 - 400 = 500 → old threshold would say "not near", new also "not near" const event = createScrollEvent(2000, 1100, 400);
handleChatScroll(host, event);
expect(host.chatUserNearBottom).toBe(false);
});
});
/* ------------------------------------------------------------------ */ /* scheduleChatScroll – respects user scroll position */ /* ------------------------------------------------------------------ */
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.18Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.