Skip to content

Commit

Permalink
anvil-cmg filter tests (#4068) (#4071)
Browse files Browse the repository at this point in the history
* feat: first draft of anvil-cmg filter tests (#4068)

* fix: refactored and debugged filter tests (#4068)

* fix: added extra check to testFilterPresence (#4068)

* fix: refactored tests (#4068)

* fix: refactored tests (#4068)

* fix: refactored tests (#4068)

* fix: attempted fix for filter test issues (#4068)

* fix: switched setchecked to click action (#4068)

* fix: fixed typo that caused tests to fail, added clear all test (#4068)

* fix: shortened certain tests that would timeout (#4068)

* fix: fixed redundant code and bad timeouts (#4068)

* fix: made all variables camelcase in filter tests (#4068)

* fix: updated variable names and created constants (#4068)

* fix: updated variable names, created constants, fixed bug in persistence test on webkit (#4068)

* fix: updated variable names and tsdocs for e2e tests (#4068)

* fix: fixed filter persistence test errors (#4068)
  • Loading branch information
jpaten authored Aug 23, 2024
1 parent e37768b commit 7657375
Show file tree
Hide file tree
Showing 4 changed files with 529 additions and 24 deletions.
173 changes: 173 additions & 0 deletions explorer/e2e/anvil/anvil-filters.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import { expect, test } from "@playwright/test";
import {
filterRegex,
getFirstRowNthColumnCellLocator,
testClearAll,
testFilterCounts,
testFilterPersistence,
testFilterPresence,
testFilterTags,
} from "../testFunctions";
import {
anvilFilterNames,
anvilTabs,
anvilTabTestOrder,
BIOSAMPLE_TYPE_INDEX,
CONSENT_GROUP_INDEX,
DATASET_INDEX,
DATA_MODALITY_INDEX,
DIAGNOSIS_INDEX,
FILE_FORMAT_INDEX,
REPORTED_ETHNICITY_INDEX,
} from "./anvil-tabs";

const FILTER_INDEX_LIST = [
DATA_MODALITY_INDEX,
DATASET_INDEX,
DIAGNOSIS_INDEX,
REPORTED_ETHNICITY_INDEX,
FILE_FORMAT_INDEX,
CONSENT_GROUP_INDEX,
];
const FILTER_INDEX_LIST_SHORT = [
BIOSAMPLE_TYPE_INDEX,
FILE_FORMAT_INDEX,
DIAGNOSIS_INDEX,
];

test("Check that all filters exist on the Datasets tab and are clickable", async ({
page,
}) => {
await testFilterPresence(page, anvilTabs.datasets, anvilFilterNames);
});

test("Check that all filters exist on the Donors tab and are clickable", async ({
page,
}) => {
await testFilterPresence(page, anvilTabs.donors, anvilFilterNames);
});

test("Check that all filters exist on the BioSamples tab and are clickable", async ({
page,
}) => {
await testFilterPresence(page, anvilTabs.biosamples, anvilFilterNames);
});

test("Check that all filters exist on the Activities tab and are clickable", async ({
page,
}) => {
await testFilterPresence(page, anvilTabs.activities, anvilFilterNames);
});

test("Check that all filters exist on the Files tab and are clickable", async ({
page,
}) => {
await testFilterPresence(page, anvilTabs.files, anvilFilterNames);
});

test("Check that the first filter on the Datasets tab creates at least one checkbox, and that checking up to the first five does not cause an error and does not cause there to be no entries in the table", async ({
page,
}) => {
test.setTimeout(120000);
// Goto the datasets tab
await page.goto(anvilTabs.datasets.url);
await expect(
page.getByRole("tab").getByText(anvilTabs.datasets.tabName)
).toBeVisible();

// Select a filter
await page
.getByRole("button")
.getByText(
filterRegex(
anvilFilterNames[Math.floor(Math.random() * anvilFilterNames.length)]
)
)
.click();
// Expect all checkboxes to be unchecked initially and to work properly
await expect(page.getByRole("checkbox").first()).toBeVisible();
const allCheckboxes = await page.getByRole("checkbox").all();
for (let i = 0; i < allCheckboxes.length && i < 5; i++) {
const checkbox = allCheckboxes[i];
await checkbox.scrollIntoViewIfNeeded();
await expect(checkbox).not.toBeChecked();
await checkbox.click();
await expect(checkbox).toBeChecked();
}
await page.locator("body").click();
await expect(getFirstRowNthColumnCellLocator(page, 0)).toBeVisible();
});

test("Check that filter checkboxes are persistent across pages on an arbitrary filter", async ({
page,
}) => {
test.setTimeout(120000);
const result = await testFilterPersistence(
page,
anvilFilterNames[FILE_FORMAT_INDEX],
anvilTabTestOrder.map((x) => anvilTabs[x])
);
if (!result) {
test.fail();
}
});

test("Check that filter menu counts match actual counts on the Datasets tab", async ({
page,
}) => {
test.setTimeout(120000);
const result = await testFilterCounts(
page,
anvilTabs.datasets,
FILTER_INDEX_LIST.map((x) => anvilFilterNames[x]),
anvilTabs.datasets.maxPages ?? 0
);
if (!result) {
test.fail();
}
});

test("Check that filter menu counts match actual counts on the Activities tab", async ({
page,
}) => {
test.setTimeout(120000);
await testFilterCounts(
page,
anvilTabs.activities,
FILTER_INDEX_LIST.map((x) => anvilFilterNames[x]),
anvilTabs.activities.maxPages ?? 0
);
});

test("Check that the filter tags match the selected filter for an arbitrary filter on the Files tab", async ({
page,
}) => {
test.setTimeout(120000);
await testFilterTags(
page,
anvilTabs.files,
FILTER_INDEX_LIST_SHORT.map((x) => anvilFilterNames[x])
);
});

test("Check that the filter tags match the selected filter for an arbitrary filter on the BioSamples tab", async ({
page,
}) => {
test.setTimeout(120000);
await testFilterTags(
page,
anvilTabs.biosamples,
FILTER_INDEX_LIST_SHORT.map((x) => anvilFilterNames[x])
);
});

test("Check that the clear all button functions on the files tab", async ({
page,
}) => {
test.setTimeout(120000);
await testClearAll(
page,
anvilTabs.files,
FILTER_INDEX_LIST_SHORT.map((x) => anvilFilterNames[x])
);
});
18 changes: 17 additions & 1 deletion explorer/e2e/anvil/anvil-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TabDescription,
} from "../testInterfaces";

export const filters: string[] = [
export const anvilFilterNames: string[] = [
"Anatomical Site",
"BioSample Type",
"Consent Group",
Expand All @@ -18,10 +18,22 @@ export const filters: string[] = [
"Phenotypic Sex",
"Reported Ethnicity",
];
export const ANATOMICAL_SITE_INDEX = 0;
export const BIOSAMPLE_TYPE_INDEX = 1;
export const CONSENT_GROUP_INDEX = 2;
export const DATA_MODALITY_INDEX = 3;
export const DATASET_INDEX = 4;
export const DIAGNOSIS_INDEX = 5;
export const FILE_FORMAT_INDEX = 6;
export const IDENTIFIER_INDEX = 7;
export const ORGANISM_TYPE_INDEX = 8;
export const PHENOTYPIC_SEX_INDEX = 9;
export const REPORTED_ETHNICITY_INDEX = 10;

export const anvilTabs: AnvilCMGTabCollection = {
activities: {
emptyFirstColumn: false,
maxPages: 25,
preselectedColumns: [
{ name: "Document Id", sortable: true },
{ name: "Activity Type", sortable: true },
Expand All @@ -40,6 +52,7 @@ export const anvilTabs: AnvilCMGTabCollection = {
},
biosamples: {
emptyFirstColumn: false,
maxPages: 25,
preselectedColumns: [
{ name: "BioSample Id", sortable: true },
{ name: "Anatomical Site", sortable: true },
Expand All @@ -57,6 +70,7 @@ export const anvilTabs: AnvilCMGTabCollection = {
},
datasets: {
emptyFirstColumn: false,
maxPages: 25,
preselectedColumns: [
{ name: "Dataset", sortable: true },
{ name: "Access", sortable: false },
Expand All @@ -75,6 +89,7 @@ export const anvilTabs: AnvilCMGTabCollection = {
},
donors: {
emptyFirstColumn: false,
maxPages: 25,
preselectedColumns: [
{ name: "Donor Id", sortable: true },
{ name: "Organism Type", sortable: true },
Expand All @@ -89,6 +104,7 @@ export const anvilTabs: AnvilCMGTabCollection = {
},
files: {
emptyFirstColumn: true,
maxPages: 25,
preselectedColumns: [
{ name: "Name", sortable: true },
{ name: "File Format", sortable: true },
Expand Down
Loading

0 comments on commit 7657375

Please sign in to comment.