@@ -504,7 +504,7 @@ export async function testFilterTags(
504
504
* those filters to become deselected
505
505
* @param page - a Playwright page object
506
506
* @param tab - the tab object to test on
507
- * @param filterNames - the names of the fitlers to check
507
+ * @param filterNames - the names of the filters to check
508
508
*/
509
509
export async function testClearAll (
510
510
page : Page ,
@@ -566,6 +566,7 @@ export async function testSelectFiltersThroughSearchBar(
566
566
) : Promise < void > {
567
567
await page . goto ( tab . url ) ;
568
568
for ( const filterName of filterNames ) {
569
+ // Get the first filter option
569
570
await expect ( page . getByText ( filterRegex ( filterName ) ) ) . toBeVisible ( ) ;
570
571
await page . getByText ( filterRegex ( filterName ) ) . dispatchEvent ( "click" ) ;
571
572
const firstFilterOptionLocator = getFirstFilterOptionLocator ( page ) ;
@@ -574,16 +575,18 @@ export async function testSelectFiltersThroughSearchBar(
574
575
firstFilterOptionLocator
575
576
) ;
576
577
await page . locator ( "body" ) . click ( ) ;
577
-
578
+ // Search for the filter option
578
579
const searchFiltersInputLocator = page . getByPlaceholder (
579
580
tab . searchFiltersPlaceholderText ,
580
581
{ exact : true }
581
582
) ;
582
583
await expect ( searchFiltersInputLocator ) . toBeVisible ( ) ;
583
584
await searchFiltersInputLocator . fill ( filterOptionName ) ;
585
+ // Select a filter option with a matching name
584
586
await getNamedFilterOptionLocator ( page , filterOptionName ) . first ( ) . click ( ) ;
585
587
await page . locator ( "body" ) . click ( ) ;
586
588
const filterTagLocator = getFilterTagLocator ( page , filterOptionName ) ;
589
+ // Check the filter tag is selected and click it to reset the filter
587
590
await expect ( filterTagLocator ) . toBeVisible ( ) ;
588
591
await filterTagLocator . dispatchEvent ( "click" ) ;
589
592
}
@@ -602,32 +605,30 @@ export async function testDeselectFiltersThroughSearchBar(
602
605
filterNames : string [ ]
603
606
) : Promise < void > {
604
607
await page . goto ( tab . url ) ;
605
- const filterOptionNames : string [ ] = [ ] ;
606
608
for ( const filterName of filterNames ) {
609
+ // Select each filter option
607
610
await expect ( page . getByText ( filterRegex ( filterName ) ) ) . toBeVisible ( ) ;
608
611
await page . getByText ( filterRegex ( filterName ) ) . dispatchEvent ( "click" ) ;
609
612
const firstFilterOptionLocator = getFirstFilterOptionLocator ( page ) ;
610
613
const filterOptionName = await getFilterOptionName (
611
614
page ,
612
615
firstFilterOptionLocator
613
616
) ;
614
- filterOptionNames . push ( filterOptionName ) ;
615
617
await firstFilterOptionLocator . click ( ) ;
616
618
await page . locator ( "body" ) . click ( ) ;
617
- }
618
- for ( let i = 0 ; i < filterOptionNames . length ; i ++ ) {
619
+ // Search for and check the selected filter
619
620
const searchFiltersInputLocator = page . getByPlaceholder (
620
621
tab . searchFiltersPlaceholderText ,
621
622
{ exact : true }
622
623
) ;
623
624
await expect ( searchFiltersInputLocator ) . toBeVisible ( ) ;
624
- await searchFiltersInputLocator . fill ( filterOptionNames [ i ] ) ;
625
- await getNamedFilterOptionLocator ( page , filterOptionNames [ i ] )
625
+ await searchFiltersInputLocator . fill ( filterOptionName ) ;
626
+ await getNamedFilterOptionLocator ( page , filterOptionName )
626
627
. locator ( "input[type='checkbox']:checked" )
627
628
. first ( )
628
629
. click ( ) ;
629
630
await page . locator ( "body" ) . click ( ) ;
630
- const filterTagLocator = getFilterTagLocator ( page , filterOptionNames [ i ] ) ;
631
+ const filterTagLocator = getFilterTagLocator ( page , filterOptionName ) ;
631
632
await expect ( filterTagLocator ) . not . toBeVisible ( ) ;
632
633
}
633
634
}
0 commit comments