@@ -125,15 +125,15 @@ describe('ExplorerPanel', () => {
125125 } ) ;
126126
127127 describe ( 'Feature Flag and Organization Checks' , ( ) => {
128- it ( 'renders when feature flag and open membership are enabled' , ( ) => {
128+ it ( 'renders when feature flag and open membership are enabled' , async ( ) => {
129129 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
130130
131131 expect (
132- screen . getByText ( / A s k S e e r a n y t h i n g a b o u t y o u r a p p l i c a t i o n ./ )
132+ await screen . findByText ( / A s k S e e r a n y t h i n g a b o u t y o u r a p p l i c a t i o n ./ )
133133 ) . toBeInTheDocument ( ) ;
134134 } ) ;
135135
136- it ( 'does not render when feature flag is disabled' , ( ) => {
136+ it ( 'does not render when feature flag is disabled' , async ( ) => {
137137 const disabledOrg = OrganizationFixture ( {
138138 features : [ ] ,
139139 hideAiFeatures : false ,
@@ -144,10 +144,10 @@ describe('ExplorerPanel', () => {
144144 organization : disabledOrg ,
145145 } ) ;
146146
147- expect ( container ) . toBeEmptyDOMElement ( ) ;
147+ await waitFor ( ( ) => expect ( container ) . toBeEmptyDOMElement ( ) ) ;
148148 } ) ;
149149
150- it ( 'does not render when AI features are hidden' , ( ) => {
150+ it ( 'does not render when AI features are hidden' , async ( ) => {
151151 const disabledOrg = OrganizationFixture ( {
152152 features : [ 'seer-explorer' ] ,
153153 hideAiFeatures : true ,
@@ -158,10 +158,10 @@ describe('ExplorerPanel', () => {
158158 organization : disabledOrg ,
159159 } ) ;
160160
161- expect ( container ) . toBeEmptyDOMElement ( ) ;
161+ await waitFor ( ( ) => expect ( container ) . toBeEmptyDOMElement ( ) ) ;
162162 } ) ;
163163
164- it ( 'does not render when open membership is disabled' , ( ) => {
164+ it ( 'does not render when open membership is disabled' , async ( ) => {
165165 const disabledOrg = OrganizationFixture ( {
166166 features : [ 'seer-explorer' ] ,
167167 hideAiFeatures : false ,
@@ -172,28 +172,30 @@ describe('ExplorerPanel', () => {
172172 organization : disabledOrg ,
173173 } ) ;
174174
175- expect ( container ) . toBeEmptyDOMElement ( ) ;
175+ await waitFor ( ( ) => expect ( container ) . toBeEmptyDOMElement ( ) ) ;
176176 } ) ;
177177 } ) ;
178178
179179 describe ( 'Empty State' , ( ) => {
180- it ( 'shows empty state when no messages exist' , ( ) => {
180+ it ( 'shows empty state when no messages exist' , async ( ) => {
181181 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
182182
183183 expect (
184- screen . getByText ( / A s k S e e r a n y t h i n g a b o u t y o u r a p p l i c a t i o n ./ )
184+ await screen . findByText ( / A s k S e e r a n y t h i n g a b o u t y o u r a p p l i c a t i o n ./ )
185185 ) . toBeInTheDocument ( ) ;
186186 } ) ;
187187
188- it ( 'shows input section in empty state' , ( ) => {
188+ it ( 'shows input section in empty state' , async ( ) => {
189189 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
190190
191191 expect (
192- screen . getByPlaceholderText ( 'Type your message or / command and press Enter ↵' )
192+ await screen . findByPlaceholderText (
193+ 'Type your message or / command and press Enter ↵'
194+ )
193195 ) . toBeInTheDocument ( ) ;
194196 } ) ;
195197
196- it ( 'shows error when hook returns isError=true' , ( ) => {
198+ it ( 'shows error when hook returns isError=true' , async ( ) => {
197199 const useSeerExplorerSpy = jest
198200 . spyOn ( useSeerExplorerModule , 'useSeerExplorer' )
199201 . mockReturnValue ( {
@@ -220,7 +222,7 @@ describe('ExplorerPanel', () => {
220222 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
221223
222224 expect (
223- screen . getByText ( 'Error loading this session (ID=123).' )
225+ await screen . findByText ( 'Error loading this session (ID=123).' )
224226 ) . toBeInTheDocument ( ) ;
225227 expect (
226228 screen . queryByText ( / A s k S e e r a n y t h i n g a b o u t y o u r a p p l i c a t i o n ./ )
@@ -231,7 +233,7 @@ describe('ExplorerPanel', () => {
231233 } ) ;
232234
233235 describe ( 'Messages Display' , ( ) => {
234- it ( 'renders messages when session data exists' , ( ) => {
236+ it ( 'renders messages when session data exists' , async ( ) => {
235237 const mockSessionData = {
236238 blocks : [
237239 {
@@ -283,7 +285,7 @@ describe('ExplorerPanel', () => {
283285
284286 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
285287
286- expect ( screen . getByText ( 'What is this error?' ) ) . toBeInTheDocument ( ) ;
288+ expect ( await screen . findByText ( 'What is this error?' ) ) . toBeInTheDocument ( ) ;
287289 expect (
288290 screen . getByText ( 'This error indicates a null pointer exception.' )
289291 ) . toBeInTheDocument ( ) ;
@@ -533,19 +535,21 @@ describe('ExplorerPanel', () => {
533535 openMembership : true ,
534536 } ) ;
535537
536- it ( 'does not render the toggle when the feature flag is disabled' , ( ) => {
538+ it ( 'does not render the toggle when the feature flag is disabled' , async ( ) => {
537539 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
538540
541+ // Wait for effects to settle before asserting absence
542+ await screen . findByTestId ( 'seer-explorer-input' ) ;
539543 expect (
540544 screen . queryByRole ( 'checkbox' , { name : 'Toggle context engine' } )
541545 ) . not . toBeInTheDocument ( ) ;
542546 } ) ;
543547
544- it ( 'renders the toggle when the feature flag is enabled' , ( ) => {
548+ it ( 'renders the toggle when the feature flag is enabled' , async ( ) => {
545549 renderWithPanelContext ( < ExplorerPanel /> , true , { organization : orgWithFlag } ) ;
546550
547551 expect (
548- screen . getByRole ( 'checkbox' , { name : 'Toggle context engine' } )
552+ await screen . findByRole ( 'checkbox' , { name : 'Toggle context engine' } )
549553 ) . toBeInTheDocument ( ) ;
550554 } ) ;
551555
@@ -623,20 +627,20 @@ describe('ExplorerPanel', () => {
623627 } ) ;
624628
625629 describe ( 'Visibility Control' , ( ) => {
626- it ( 'renders when isVisible=true' , ( ) => {
630+ it ( 'renders when isVisible=true' , async ( ) => {
627631 renderWithPanelContext ( < ExplorerPanel /> , true , { organization} ) ;
628632
629- expect ( screen . getByTestId ( 'seer-explorer-input' ) ) . toBeInTheDocument ( ) ;
633+ expect ( await screen . findByTestId ( 'seer-explorer-input' ) ) . toBeInTheDocument ( ) ;
630634 } ) ;
631635
632- it ( 'can handle visibility changes' , ( ) => {
636+ it ( 'can handle visibility changes' , async ( ) => {
633637 const { rerenderWithOpen} = renderWithPanelContext ( < ExplorerPanel /> , false , {
634638 organization,
635639 } ) ;
636640
637641 rerenderWithOpen ( true ) ;
638642
639- expect ( screen . getByTestId ( 'seer-explorer-input' ) ) . toBeInTheDocument ( ) ;
643+ expect ( await screen . findByTestId ( 'seer-explorer-input' ) ) . toBeInTheDocument ( ) ;
640644 } ) ;
641645 } ) ;
642646} ) ;
0 commit comments