@@ -313,6 +313,17 @@ const assert = (condition, message) => {
313313 if ( ! condition ) throw new Error ( message )
314314}
315315
316+ const getRect = async ( page , selector ) =>
317+ page . $eval ( selector , ( element ) => {
318+ const rect = element . getBoundingClientRect ( )
319+ return {
320+ left : rect . left ,
321+ top : rect . top ,
322+ width : rect . width ,
323+ height : rect . height ,
324+ }
325+ } )
326+
316327const getVisibleRowKeys = async ( page ) =>
317328 page . $$eval ( 'tbody.ant-table-tbody tr[data-row-key]' , ( rows ) =>
318329 rows . map ( ( row ) => row . getAttribute ( 'data-row-key' ) || '' )
@@ -395,6 +406,7 @@ const run = async () => {
395406 } )
396407
397408 const page = await browser . newPage ( )
409+ await page . setViewport ( { width : 1440 , height : 960 } )
398410 const consoleErrors = [ ]
399411 page . on ( 'console' , ( msg ) => {
400412 if ( msg . type ( ) === 'error' ) {
@@ -476,9 +488,40 @@ const run = async () => {
476488 // Select-all should only affect filtered rows, and batch delete should only delete within scope.
477489 await page . click ( '[data-testid="nodes-select-all"]' )
478490 await page . waitForSelector ( '[data-testid="nodes-batch-delete"]' , { timeout : 10000 } )
491+ await page . waitForSelector ( '[data-testid="dashboard-toolbar-selection"]' , { timeout : 10000 } )
492+ await sleep ( 300 )
493+
494+ const primaryToolbarRect = await getRect ( page , '[data-testid="dashboard-toolbar-primary"]' )
495+ const selectionToolbarRect = await getRect ( page , '[data-testid="dashboard-toolbar-selection"]' )
496+ assert (
497+ selectionToolbarRect . top > primaryToolbarRect . top + 4 ,
498+ `Expected batch toolbar to render below primary toolbar, got primary=${ JSON . stringify ( primaryToolbarRect ) } selection=${ JSON . stringify ( selectionToolbarRect ) } `
499+ )
500+ assert (
501+ Math . abs ( selectionToolbarRect . left - primaryToolbarRect . left ) <= 1.5 ,
502+ `Expected batch toolbar to align left with primary toolbar, got primary=${ JSON . stringify ( primaryToolbarRect ) } selection=${ JSON . stringify ( selectionToolbarRect ) } `
503+ )
504+
479505 await page . click ( '[data-testid="nodes-batch-delete"]' )
480506 await page . waitForSelector ( '.ant-popconfirm' , { timeout : 10000 } )
481- await page . click ( '.ant-popconfirm-buttons button.ant-btn-primary' )
507+ await page . waitForSelector ( '.ant-popconfirm-buttons button.ant-btn-primary:not([disabled])' , {
508+ timeout : 10000 ,
509+ } )
510+ await page . evaluate ( ( ) => {
511+ const confirmButtons = Array . from (
512+ document . querySelectorAll ( '.ant-popconfirm-buttons button.ant-btn-primary:not([disabled])' )
513+ ) . filter ( ( button ) => {
514+ if ( ! ( button instanceof HTMLElement ) ) {
515+ return false
516+ }
517+ return button . offsetParent !== null
518+ } )
519+ const target = confirmButtons [ confirmButtons . length - 1 ]
520+ if ( ! target ) {
521+ throw new Error ( 'popconfirm primary button not found' )
522+ }
523+ target . click ( )
524+ } )
482525 await sleep ( 1200 )
483526
484527 const stateAfterBatchDelete = mockApi . getState ( )
0 commit comments