Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: first draft of anvil-cmg filter tests (#4068) #4071

Merged
merged 16 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
MillenniumFalconMechanic marked this conversation as resolved.
Show resolved Hide resolved
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
Loading