LibreChat/client/test/intersectionObserver.mock
Marco Beretta 62cc2ffc19
🧵 refactor: Render the Package Message List by Default in ChatScreen (#17753)
* refactor: Move the Messages View Provider Into @librechat/chat

* refactor: Render the Package Message List by Default in ChatScreen

* fix: Drop the Rail's IntersectionObserver Guard for a Package Spec Stub

Nothing renders the rail without a browser: its observer starts in an effect, which never runs in a server render. The guard existed only because jsdom lacks the API, so jsdom now gets inert observers and matchMedia from the package's jest setup, and the spec's own stubs, which no longer matched the DOM lib's IntersectionObserver type, are gone.

* test: Scroll a Sidebar Row Into View Before Dragging It

A row under the fold has no pixel the mouse can press, so the drag selected text instead. Whether a run hit it depended on which earlier specs shared its shard and left chats in the Running and Finished sections.

* test: Give the Client Specs an Inert IntersectionObserver

With the rail's guard gone, a client spec that renders the message list reaches the observer jsdom lacks. The shared setup provides an inert one, as the package's jest setup does, and the child-thread spec's partial client mock gains the rem scale hook the rail reads.

* chore: Retest Against Current Dev

* test: Give the Test Messages Host the Row Hook Members

The messages host gained the assistant, added-conversation, streamed-attachment and feedback hooks when the row hooks moved into the package, so the shared test host supplies them too.
2026-11-05 22:35:15 +01:00

16 lines
429 B
Text

/** jsdom has no layout and ships no IntersectionObserver; the message rail and scroll control
* need one to mount. A spec about what they report installs its own. */
class InertIntersectionObserver {
observe() {}
unobserve() {}
disconnect() {}
takeRecords() {
return [];
}
}
Object.defineProperty(window, 'IntersectionObserver', {
writable: true,
configurable: true,
value: InertIntersectionObserver,
});