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