@@ -616,7 +616,7 @@ export async function testFilterTags(
616
616
* those filters to become deselected
617
617
* @param page - a Playwright page object
618
618
* @param tab - the tab object to test on
619
- * @param filterNames - the names of the fitlers to check
619
+ * @param filterNames - the names of the filters to check
620
620
*/
621
621
export async function testClearAll (
622
622
page : Page ,
@@ -669,6 +669,7 @@ export async function testSelectFiltersThroughSearchBar(
669
669
) : Promise < void > {
670
670
await page . goto ( tab . url ) ;
671
671
for ( const filterName of filterNames ) {
672
+ // Get the first filter option
672
673
await expect ( page . getByText ( filterRegex ( filterName ) ) ) . toBeVisible ( ) ;
673
674
await page . getByText ( filterRegex ( filterName ) ) . dispatchEvent ( "click" ) ;
674
675
const firstFilterOptionLocator = getFirstFilterOptionLocator ( page ) ;
@@ -677,16 +678,18 @@ export async function testSelectFiltersThroughSearchBar(
677
678
firstFilterOptionLocator
678
679
) ;
679
680
await page . locator ( "body" ) . click ( ) ;
680
-
681
+ // Search for the filter option
681
682
const searchFiltersInputLocator = page . getByPlaceholder (
682
683
tab . searchFiltersPlaceholderText ,
683
684
{ exact : true }
684
685
) ;
685
686
await expect ( searchFiltersInputLocator ) . toBeVisible ( ) ;
686
687
await searchFiltersInputLocator . fill ( filterOptionName ) ;
688
+ // Select a filter option with a matching name
687
689
await getNamedFilterOptionLocator ( page , filterOptionName ) . first ( ) . click ( ) ;
688
690
await page . locator ( "body" ) . click ( ) ;
689
691
const filterTagLocator = getFilterTagLocator ( page , filterOptionName ) ;
692
+ // Check the filter tag is selected and click it to reset the filter
690
693
await expect ( filterTagLocator ) . toBeVisible ( ) ;
691
694
await filterTagLocator . dispatchEvent ( "click" ) ;
692
695
}
@@ -705,32 +708,30 @@ export async function testDeselectFiltersThroughSearchBar(
705
708
filterNames : string [ ]
706
709
) : Promise < void > {
707
710
await page . goto ( tab . url ) ;
708
- const filterOptionNames : string [ ] = [ ] ;
709
711
for ( const filterName of filterNames ) {
712
+ // Select each filter option
710
713
await expect ( page . getByText ( filterRegex ( filterName ) ) ) . toBeVisible ( ) ;
711
714
await page . getByText ( filterRegex ( filterName ) ) . dispatchEvent ( "click" ) ;
712
715
const firstFilterOptionLocator = getFirstFilterOptionLocator ( page ) ;
713
716
const filterOptionName = await getFilterOptionName (
714
717
page ,
715
718
firstFilterOptionLocator
716
719
) ;
717
- filterOptionNames . push ( filterOptionName ) ;
718
720
await firstFilterOptionLocator . click ( ) ;
719
721
await page . locator ( "body" ) . click ( ) ;
720
- }
721
- for ( let i = 0 ; i < filterOptionNames . length ; i ++ ) {
722
+ // Search for and check the selected filter
722
723
const searchFiltersInputLocator = page . getByPlaceholder (
723
724
tab . searchFiltersPlaceholderText ,
724
725
{ exact : true }
725
726
) ;
726
727
await expect ( searchFiltersInputLocator ) . toBeVisible ( ) ;
727
- await searchFiltersInputLocator . fill ( filterOptionNames [ i ] ) ;
728
- await getNamedFilterOptionLocator ( page , filterOptionNames [ i ] )
728
+ await searchFiltersInputLocator . fill ( filterOptionName ) ;
729
+ await getNamedFilterOptionLocator ( page , filterOptionName )
729
730
. locator ( "input[type='checkbox']:checked" )
730
731
. first ( )
731
732
. click ( ) ;
732
733
await page . locator ( "body" ) . click ( ) ;
733
- const filterTagLocator = getFilterTagLocator ( page , filterOptionNames [ i ] ) ;
734
+ const filterTagLocator = getFilterTagLocator ( page , filterOptionName ) ;
734
735
await expect ( filterTagLocator ) . not . toBeVisible ( ) ;
735
736
}
736
737
}
0 commit comments