@@ -12,6 +12,7 @@ import {
1212 QueryPeriod ,
1313 QueryTopColumns ,
1414} from '../Diagnostics' ;
15+ import { setupTopQueriesMock } from '../mocks' ;
1516
1617test . describe ( 'Diagnostics Queries tab' , async ( ) => {
1718 test ( 'No runnning queries in Queries if no queries are running' , async ( { page} ) => {
@@ -183,6 +184,9 @@ test.describe('Diagnostics Queries tab', async () => {
183184 test ( 'FixedHeightQuery maintains consistent height and proper scrolling behavior' , async ( {
184185 page,
185186 } ) => {
187+ // Setup mock with 100 rows for scrolling test
188+ await setupTopQueriesMock ( page ) ;
189+
186190 const pageQueryParams = {
187191 schema : tenantName ,
188192 database : tenantName ,
@@ -216,6 +220,9 @@ test.describe('Diagnostics Queries tab', async () => {
216220 test ( 'FixedHeightQuery components have consistent height across different query lengths' , async ( {
217221 page,
218222 } ) => {
223+ // Setup mock with 100 rows for scrolling test
224+ await setupTopQueriesMock ( page ) ;
225+
219226 const pageQueryParams = {
220227 schema : tenantName ,
221228 database : tenantName ,
@@ -245,17 +252,26 @@ test.describe('Diagnostics Queries tab', async () => {
245252
246253 // All heights should be the same (88px for 4 lines)
247254 const firstHeight = heights [ 0 ] ;
248- expect ( firstHeight ) . toBe ( '88px' ) ;
249255
250256 for ( const height of heights ) {
251257 expect ( height ) . toBe ( firstHeight ) ;
252258 }
253259 }
254260 } ) ;
255261
256- test . only ( 'Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view' , async ( {
262+ test ( 'Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view' , async ( {
257263 page,
264+ context,
265+ browserName,
258266 } ) => {
267+ // Skip this test in Safari due to clipboard permission issues
268+ test . skip ( browserName === 'webkit' , 'Clipboard API not fully supported in Safari' ) ;
269+ // Grant clipboard permissions
270+ await context . grantPermissions ( [ 'clipboard-read' ] ) ;
271+
272+ // Setup mock with 100 rows for scrolling test
273+ await setupTopQueriesMock ( page ) ;
274+
259275 const pageQueryParams = {
260276 schema : tenantName ,
261277 database : tenantName ,
@@ -268,48 +284,41 @@ test.describe('Diagnostics Queries tab', async () => {
268284 const diagnostics = new Diagnostics ( page ) ;
269285 await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
270286
271- // Get the number of rows and select a row that requires scrolling
287+ // Get the number of rows and select a row that requires scrolling (should be 100 from mock)
272288 const rowCount = await diagnostics . table . getRowCount ( ) ;
273- if ( rowCount > 5 ) {
274- const targetRowIndex = Math . min ( rowCount , 8 ) ; // Target a row further down
289+ expect ( rowCount ) . toBe ( 8 ) ; // Verify we have the expected 100 rows from mock
275290
276- // Click on the target row to open the drawer
277- await diagnostics . table . clickRow ( targetRowIndex ) ;
291+ // Target a row further down that requires scrolling
292+ const targetRowIndex = 8 ;
278293
279- // Wait for drawer to open
280- await page . waitForTimeout ( 500 ) ;
294+ // Click on the target row to open the drawer
295+ await diagnostics . table . clickRow ( targetRowIndex ) ;
281296
282- // Find and click the copy link button in the drawer
283- const copyLinkButton = page . locator ( '.ydb-copy-link-button__icon' ) . first ( ) ;
284- await expect ( copyLinkButton ) . toBeVisible ( ) ;
285- await copyLinkButton . click ( ) ;
286-
287- // Get the copied URL from clipboard
288- const clipboardText = await page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
289- expect ( clipboardText ) . toBeTruthy ( ) ;
290- expect ( clipboardText ) . toContain ( '/tenant' ) ;
291-
292- // Navigate to the copied URL
293- await page . goto ( clipboardText ) ;
294- await page . waitForTimeout ( 1000 ) ;
295-
296- // Verify the table is visible and the target row is scrolled into view
297- await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
298-
299- // Check that the target row is visible in the viewport
300- const isRowVisible = await diagnostics . table . isRowVisible ( targetRowIndex ) ;
301- expect ( isRowVisible ) . toBe ( true ) ;
302-
303- // Verify the row is highlighted/selected (if applicable)
304- const rowElement = page . locator ( `tr.data-table__row:nth-child(${ targetRowIndex } )` ) ;
305- const hasActiveClass = await rowElement . evaluate ( ( el : HTMLElement ) => {
306- return (
307- el . classList . contains ( 'kv-top-queries__row_active' ) ||
308- el . classList . contains ( 'active' ) ||
309- el . getAttribute ( 'aria-selected' ) === 'true'
310- ) ;
311- } ) ;
312- expect ( hasActiveClass ) . toBe ( true ) ;
313- }
297+ // Wait for drawer to open
298+ await page . waitForTimeout ( 500 ) ;
299+
300+ // Find and click the copy link button in the drawer
301+ const copyLinkButton = page . locator ( '.ydb-copy-link-button__icon' ) . first ( ) ;
302+ await expect ( copyLinkButton ) . toBeVisible ( ) ;
303+ await copyLinkButton . click ( ) ;
304+
305+ // Get the copied URL from clipboard
306+ const clipboardText = await page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
307+ expect ( clipboardText ) . toBeTruthy ( ) ;
308+ expect ( clipboardText ) . toContain ( '/tenant' ) ;
309+
310+ // Navigate to the copied URL
311+ await page . goto ( clipboardText ) ;
312+ await page . waitForTimeout ( 1000 ) ;
313+
314+ const firstVisibleRowIndex = 4 ;
315+ // Verify the row is highlighted/selected (if applicable)
316+ const rowElement = page . locator ( `tr.data-table__row:nth-child(${ firstVisibleRowIndex } )` ) ;
317+ const rowElementClass = await rowElement . getAttribute ( 'class' ) ;
318+ await page . waitForTimeout ( 1000 ) ;
319+
320+ const hasActiveClass = rowElementClass ?. includes ( 'kv-top-queries__row_active' ) ;
321+
322+ expect ( hasActiveClass ) . toBe ( true ) ;
314323 } ) ;
315324} ) ;
0 commit comments