mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 14:33:38 +00:00
🎯 test: Restore the Ask-User Arrival Focus Specs (#17869)
The shared client setup gained an inert IntersectionObserver in #17753. It never reports, so useArrivalFocus no longer arrived in jsdom: the positive cases failed and the negative ones passed without testing anything. Remove it inside the arrival focus blocks so the hook takes its no-observer path, and restore it afterward. Scroll-dependent cases keep their own observer.
This commit is contained in:
parent
76c25680ce
commit
f6b88bb02b
2 changed files with 20 additions and 0 deletions
|
|
@ -246,7 +246,17 @@ describe('AskUserQuestion', () => {
|
|||
});
|
||||
|
||||
describe('arrival focus', () => {
|
||||
/* jsdom has no layout, so without an observer `useArrivalFocus` arrives at once. The shared
|
||||
inert observer never reports, so nothing would arrive and the negative cases would pass
|
||||
without testing anything. */
|
||||
const inertObserver = window.IntersectionObserver;
|
||||
|
||||
beforeEach(() => {
|
||||
Reflect.deleteProperty(window, 'IntersectionObserver');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
window.IntersectionObserver = inertObserver;
|
||||
document.getElementById('prompt-textarea')?.remove();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,17 @@ describe('AskUserQuestions', () => {
|
|||
});
|
||||
|
||||
describe('focus on arrival', () => {
|
||||
/* jsdom has no layout, so without an observer `useArrivalFocus` arrives at once. The shared
|
||||
inert observer never reports, so nothing would arrive and the negative cases would pass
|
||||
without testing anything. */
|
||||
const inertObserver = window.IntersectionObserver;
|
||||
|
||||
beforeEach(() => {
|
||||
Reflect.deleteProperty(window, 'IntersectionObserver');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
window.IntersectionObserver = inertObserver;
|
||||
document.getElementById('prompt-textarea')?.remove();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue