Skip to content

Commit ab38f0c

Browse files
committed
test: bugfix in anvilcatalog filters test, updated testReadme (#4125)
1 parent aa9ac51 commit ab38f0c

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
@@ -504,7 +504,7 @@ export async function testFilterTags(
504504
* those filters to become deselected
505505
* @param page - a Playwright page object
506506
* @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
508508
*/
509509
export async function testClearAll(
510510
page: Page,
@@ -566,6 +566,7 @@ export async function testSelectFiltersThroughSearchBar(
566566
): Promise<void> {
567567
await page.goto(tab.url);
568568
for (const filterName of filterNames) {
569+
// Get the first filter option
569570
await expect(page.getByText(filterRegex(filterName))).toBeVisible();
570571
await page.getByText(filterRegex(filterName)).dispatchEvent("click");
571572
const firstFilterOptionLocator = getFirstFilterOptionLocator(page);
@@ -574,16 +575,18 @@ export async function testSelectFiltersThroughSearchBar(
574575
firstFilterOptionLocator
575576
);
576577
await page.locator("body").click();
577-
578+
// Search for the filter option
578579
const searchFiltersInputLocator = page.getByPlaceholder(
579580
tab.searchFiltersPlaceholderText,
580581
{ exact: true }
581582
);
582583
await expect(searchFiltersInputLocator).toBeVisible();
583584
await searchFiltersInputLocator.fill(filterOptionName);
585+
// Select a filter option with a matching name
584586
await getNamedFilterOptionLocator(page, filterOptionName).first().click();
585587
await page.locator("body").click();
586588
const filterTagLocator = getFilterTagLocator(page, filterOptionName);
589+
// Check the filter tag is selected and click it to reset the filter
587590
await expect(filterTagLocator).toBeVisible();
588591
await filterTagLocator.dispatchEvent("click");
589592
}
@@ -602,32 +605,30 @@ export async function testDeselectFiltersThroughSearchBar(
602605
filterNames: string[]
603606
): Promise<void> {
604607
await page.goto(tab.url);
605-
const filterOptionNames: string[] = [];
606608
for (const filterName of filterNames) {
609+
// Select each filter option
607610
await expect(page.getByText(filterRegex(filterName))).toBeVisible();
608611
await page.getByText(filterRegex(filterName)).dispatchEvent("click");
609612
const firstFilterOptionLocator = getFirstFilterOptionLocator(page);
610613
const filterOptionName = await getFilterOptionName(
611614
page,
612615
firstFilterOptionLocator
613616
);
614-
filterOptionNames.push(filterOptionName);
615617
await firstFilterOptionLocator.click();
616618
await page.locator("body").click();
617-
}
618-
for (let i = 0; i < filterOptionNames.length; i++) {
619+
// Search for and check the selected filter
619620
const searchFiltersInputLocator = page.getByPlaceholder(
620621
tab.searchFiltersPlaceholderText,
621622
{ exact: true }
622623
);
623624
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)
626627
.locator("input[type='checkbox']:checked")
627628
.first()
628629
.click();
629630
await page.locator("body").click();
630-
const filterTagLocator = getFilterTagLocator(page, filterOptionNames[i]);
631+
const filterTagLocator = getFilterTagLocator(page, filterOptionName);
631632
await expect(filterTagLocator).not.toBeVisible();
632633
}
633634
}

explorer/e2e/testReadme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ through the actions taken as part of the test and view the impact on the web pag
8686
- Runs on all tabs
8787
- Check that selecting all checkboxes in the Edit Columns menu adds the correct headets to the table
8888
- Only runs on the "Consortia" tab (other tabs do not have editable columns)
89+
- Filters (`anvilcatalog-filters.spec.ts`)
90+
- Search filters bar
91+
- Check that filters can be selected through the search bar
92+
- Check that filters can be deselected through the search bar
93+
- Both tests run on all tabs
8994
- All tests rely on correct lists of tabs, columns, and filters in `anvilcatalog-tabs.ts`
9095

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

0 commit comments

Comments
 (0)