@@ -264,12 +264,20 @@ test.describe.only('Diagnostics Queries tab', async () => {
264264 const diagnostics = new Diagnostics ( page ) ;
265265 await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
266266
267- // Get the number of rows and select a row that requires scrolling (should be 100 from mock)
268- const rowCount = await diagnostics . table . getRowCount ( ) ;
269- expect ( rowCount ) . toBe ( 8 ) ; // Verify we have the expected 100 rows from mock
267+ // Get the number of visible rows (should be around 8 due to virtualization)
268+ const visibleRowCount = await diagnostics . table . getRowCount ( ) ;
269+ expect ( visibleRowCount ) . toBeGreaterThan ( 0 ) ;
270+ expect ( visibleRowCount ) . toBeLessThanOrEqual ( 10 ) ; // Due to virtualization
271+
272+ // Target a row that's visible (use row 5 or 6 to ensure it's in the viewport)
273+ const targetRowIndex = Math . min ( 5 , visibleRowCount ) ;
270274
271- // Target a row further down that requires scrolling
272- const targetRowIndex = 8 ;
275+ // Store the query hash of the target row to verify later
276+ const targetQueryHash = await diagnostics . table . getCellValueByHeader (
277+ targetRowIndex ,
278+ 'Query Hash' ,
279+ ) ;
280+ expect ( targetQueryHash ) . toBeTruthy ( ) ;
273281
274282 // Click on the target row to open the drawer
275283 await diagnostics . table . clickRow ( targetRowIndex ) ;
@@ -281,21 +289,32 @@ test.describe.only('Diagnostics Queries tab', async () => {
281289 await expect ( diagnostics . isCopyLinkButtonVisible ( ) ) . resolves . toBe ( true ) ;
282290 await diagnostics . clickCopyLinkButton ( ) ;
283291
292+ // Small wait for clipboard operation
293+ await page . waitForTimeout ( 200 ) ;
294+
284295 // Get the copied URL from clipboard
285296 const clipboardText = await page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
286297 expect ( clipboardText ) . toBeTruthy ( ) ;
287298 expect ( clipboardText ) . toContain ( '/tenant' ) ;
288299
289300 // Navigate to the copied URL
290301 await page . goto ( clipboardText ) ;
291- await page . waitForTimeout ( 1000 ) ;
292302
293- const firstVisibleRowIndex = 4 ;
294- // Verify the row is highlighted/selected (if applicable)
295- await page . waitForTimeout ( 1000 ) ;
296-
297- const hasActiveClass = await diagnostics . isRowActive ( firstVisibleRowIndex ) ;
298-
299- expect ( hasActiveClass ) . toBe ( true ) ;
303+ // Wait for the active row to appear
304+ const hasActiveRow = await diagnostics . waitForActiveRow ( ) ;
305+ expect ( hasActiveRow ) . toBe ( true ) ;
306+
307+ // Get the index of the active row
308+ const activeRowIndex = await diagnostics . getActiveRowIndex ( ) ;
309+ expect ( activeRowIndex ) . not . toBeNull ( ) ;
310+
311+ // Verify the active row has the same query hash as the one we selected
312+ if ( activeRowIndex ) {
313+ const activeRowQueryHash = await diagnostics . table . getCellValueByHeader (
314+ activeRowIndex ,
315+ 'Query Hash' ,
316+ ) ;
317+ expect ( activeRowQueryHash ) . toBe ( targetQueryHash ) ;
318+ }
300319 } ) ;
301320} ) ;
0 commit comments