From f6b88bb02bf27a326cfea76ed46b3b2db9110000 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Fri, 6 Nov 2026 18:15:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AF=20test:=20Restore=20the=20Ask-User?= =?UTF-8?q?=20Arrival=20Focus=20Specs=20(#17869)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../Content/__tests__/AskUserQuestion.test.tsx | 10 ++++++++++ .../Content/__tests__/AskUserQuestions.test.tsx | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestion.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestion.test.tsx index f8b248de78..c8986a3d2f 100644 --- a/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestion.test.tsx +++ b/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestion.test.tsx @@ -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(); }); diff --git a/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestions.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestions.test.tsx index 94f2ce1b11..9b5623c4cc 100644 --- a/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestions.test.tsx +++ b/client/src/components/Chat/Messages/Content/__tests__/AskUserQuestions.test.tsx @@ -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(); });