@@ -599,46 +599,33 @@ test.describe('Display Layout', () => {
599
599
600
600
// Verify filtering is working correctly
601
601
602
- // Create a promise that resolves when we've seen enough new rows added
603
- const rowsMutationPromise = page . evaluate ( ( ) => {
604
- return new Promise ( ( resolve ) => {
605
- const targetTable = document . querySelector (
606
- 'table[aria-label="Table Filter Off Value table content"]'
607
- ) ;
608
- const config = { childList : true , subtree : true } ;
609
- let changeCount = 0 ;
610
- const requiredChanges = 20 ; // Number of changes to wait for
611
-
612
- const observer = new MutationObserver ( ( mutations ) => {
613
- mutations . forEach ( ( mutation ) => {
614
- if ( mutation . type === 'childList' ) {
615
- // Count added nodes
616
- changeCount += mutation . addedNodes . length ;
617
- }
618
- } ) ;
619
-
620
- // Check if the required number of changes has been met
621
- if ( changeCount >= requiredChanges ) {
622
- observer . disconnect ( ) ; // Disconnect observer after the required changes
623
- resolve ( ) ;
624
- }
625
- } ) ;
626
-
627
- observer . observe ( targetTable , config ) ;
628
- } ) ;
629
- } ) ;
630
-
631
- await rowsMutationPromise ;
632
-
633
- // Check ON table doesn't have any OFF values
634
- await expect ( tableFilterOn . locator ( 'td[title="OFF"]' ) ) . toHaveCount ( 0 ) ;
635
- const onCount = await tableFilterOn . locator ( 'td[title="ON"]' ) . count ( ) ;
636
- await expect ( onCount ) . toBeGreaterThan ( 0 ) ;
637
-
638
- // Check OFF table doesn't have any ON values
639
- await expect ( tableFilterOff . locator ( 'td[title="ON"]' ) ) . toHaveCount ( 0 ) ;
640
- const offCount = await tableFilterOff . locator ( 'td[title="OFF"]' ) . count ( ) ;
641
- await expect ( offCount ) . toBeGreaterThan ( 0 ) ;
602
+ // Check that no filtered values appear for at least 2 seconds
603
+ const VERIFICATION_TIME = 2000 ; // 2 seconds
604
+ const CHECK_INTERVAL = 100 ; // Check every 100ms
605
+
606
+ // Create a promise that will check for filtered values periodically
607
+ const checkForCorrectValues = new Promise ( ( resolve , reject ) => {
608
+ const interval = setInterval ( async ( ) => {
609
+ const offCount = await tableFilterOn . locator ( 'td[title="OFF"]' ) . count ( ) ;
610
+ const onCount = await tableFilterOff . locator ( 'td[title="ON"]' ) . count ( ) ;
611
+ if ( offCount > 0 || onCount > 0 ) {
612
+ clearInterval ( interval ) ;
613
+ reject (
614
+ new Error (
615
+ `Found ${ offCount } OFF and ${ onCount } ON values when expecting 0 OFF and 0 ON`
616
+ )
617
+ ) ;
618
+ }
619
+ } , CHECK_INTERVAL ) ;
620
+
621
+ // After VERIFICATION_TIME, if no filtered values were found, resolve successfully
622
+ setTimeout ( ( ) => {
623
+ clearInterval ( interval ) ;
624
+ resolve ( ) ;
625
+ } , VERIFICATION_TIME ) ;
626
+ } ) ;
627
+
628
+ await expect ( checkForCorrectValues ) . resolves . toBeUndefined ( ) ;
642
629
} ) ;
643
630
} ) ;
644
631
0 commit comments