🎯 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:
Marco Beretta 2026-11-06 18:15:06 +01:00 • committed by GitHub
parent 76c25680ce
commit f6b88bb02b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View file

@ -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();
});

View file

@ -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();
});