Skip to content

Commit c7b4b78

Browse files
mrtopsytjpaten
authored and
jpaten
committed
test: bugfix in anvilcatalog filters test, updated testReadme (#4125)
1 parent 0ada36e commit c7b4b78

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

explorer/e2e/testFunctions.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ export async function testFilterTags(
616616
* those filters to become deselected
617617
* @param page - a Playwright page object
618618
* @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
620620
*/
621621
export async function testClearAll(
622622
page: Page,
@@ -669,6 +669,7 @@ export async function testSelectFiltersThroughSearchBar(
669669
): Promise<void> {
670670
await page.goto(tab.url);
671671
for (const filterName of filterNames) {
672+
// Get the first filter option
672673
await expect(page.getByText(filterRegex(filterName))).toBeVisible();
673674
await page.getByText(filterRegex(filterName)).dispatchEvent("click");
674675
const firstFilterOptionLocator = getFirstFilterOptionLocator(page);
@@ -677,16 +678,18 @@ export async function testSelectFiltersThroughSearchBar(
677678
firstFilterOptionLocator
678679
);
679680
await page.locator("body").click();
680-
681+
// Search for the filter option
681682
const searchFiltersInputLocator = page.getByPlaceholder(
682683
tab.searchFiltersPlaceholderText,
683684
{ exact: true }
684685
);
685686
await expect(searchFiltersInputLocator).toBeVisible();
686687
await searchFiltersInputLocator.fill(filterOptionName);
688+
// Select a filter option with a matching name
687689
await getNamedFilterOptionLocator(page, filterOptionName).first().click();
688690
await page.locator("body").click();
689691
const filterTagLocator = getFilterTagLocator(page, filterOptionName);
692+
// Check the filter tag is selected and click it to reset the filter
690693
await expect(filterTagLocator).toBeVisible();
691694
await filterTagLocator.dispatchEvent("click");
692695
}
@@ -705,32 +708,30 @@ export async function testDeselectFiltersThroughSearchBar(
705708
filterNames: string[]
706709
): Promise<void> {
707710
await page.goto(tab.url);
708-
const filterOptionNames: string[] = [];
709711
for (const filterName of filterNames) {
712+
// Select each filter option
710713
await expect(page.getByText(filterRegex(filterName))).toBeVisible();
711714
await page.getByText(filterRegex(filterName)).dispatchEvent("click");
712715
const firstFilterOptionLocator = getFirstFilterOptionLocator(page);
713716
const filterOptionName = await getFilterOptionName(
714717
page,
715718
firstFilterOptionLocator
716719
);
717-
filterOptionNames.push(filterOptionName);
718720
await firstFilterOptionLocator.click();
719721
await page.locator("body").click();
720-
}
721-
for (let i = 0; i < filterOptionNames.length; i++) {
722+
// Search for and check the selected filter
722723
const searchFiltersInputLocator = page.getByPlaceholder(
723724
tab.searchFiltersPlaceholderText,
724725
{ exact: true }
725726
);
726727
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)
729730
.locator("input[type='checkbox']:checked")
730731
.first()
731732
.click();
732733
await page.locator("body").click();
733-
const filterTagLocator = getFilterTagLocator(page, filterOptionNames[i]);
734+
const filterTagLocator = getFilterTagLocator(page, filterOptionName);
734735
await expect(filterTagLocator).not.toBeVisible();
735736
}
736737
}

explorer/e2e/testReadme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ through the actions taken as part of the test and view the impact on the web pag
9999
- Runs on all tabs
100100
- Check that selecting all checkboxes in the Edit Columns menu adds the correct headers to the table
101101
- Only runs on the "Consortia" tab (other tabs do not have editable columns)
102+
- Filters (`anvilcatalog-filters.spec.ts`)
103+
- Search filters bar
104+
- Check that filters can be selected through the search bar
105+
- Check that filters can be deselected through the search bar
106+
- Both tests run on all tabs
102107
- All tests rely on correct lists of tabs, columns, and filters in `anvilcatalog-tabs.ts`
103108

104109
### Candidate Additional Tests (anvil-cmg):

0 commit comments

Comments
 (0)