Skip to content

Commit

Permalink
feat: added first round E2E tests for anvil-catalog (#3598) (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaten authored Sep 5, 2023
1 parent 6481537 commit 74589b3
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 59 deletions.
34 changes: 34 additions & 0 deletions explorer/e2e/anvil-catalog/anvilcatalog-select-tabs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test } from "@playwright/test";
import {
testPreSelectedColumns,
testSelectableColumns,
} from "../testFunctions";
import { anvilcatalogTabs } from "./anvilcatalog-tabs";

test("Expect the checkboxes in the 'Edit Columns' menu to add those columns to the tab in the Consortia tab", async ({
page,
}) => {
const tab = anvilcatalogTabs.consortia;
await testSelectableColumns(page, tab);
});

test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the consortia tab", async ({
page,
}) => {
const tab = anvilcatalogTabs.consortia;
await testPreSelectedColumns(page, tab);
});

test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the studies tab", async ({
page,
}) => {
const tab = anvilcatalogTabs.studies;
await testPreSelectedColumns(page, tab);
});

test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the workspaces tab", async ({
page,
}) => {
const tab = anvilcatalogTabs.workspaces;
await testPreSelectedColumns(page, tab);
});
24 changes: 24 additions & 0 deletions explorer/e2e/anvil-catalog/anvilcatalog-sort.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test } from "@playwright/test";
import { testSort } from "../testFunctions";
import { anvilcatalogTabs } from "./anvilcatalog-tabs";

test.describe.configure({ mode: "parallel" });

test("Expect clicking the column header to change the first displayed entry in each column on the consortia tab, except where all tabs have the same values", async ({
page,
}) => {
await testSort(page, anvilcatalogTabs.consortia);
});

test.setTimeout(120000);
test("Expect clicking the column header to change the first displayed entry in each column on the studies tab, except where all tabs have the same values", async ({
page,
}) => {
await testSort(page, anvilcatalogTabs.studies);
});

test("Expect clicking the column header to change the first displayed entry in each column on the workspaces tab, except where all tabs have the same values", async ({
page,
}) => {
await testSort(page, anvilcatalogTabs.workspaces);
});
27 changes: 27 additions & 0 deletions explorer/e2e/anvil-catalog/anvilcatalog-tabs-buttons.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test } from "@playwright/test";
import { testTab } from "../testFunctions";
import { anvilcatalogTabs } from "./anvilcatalog-tabs";

test("Expect clicking the consortia tab to go to the correct url and to show all of the relevant columns when selected", async ({
page,
}) => {
const tab = anvilcatalogTabs.consortia;
await page.goto(anvilcatalogTabs.studies.url);
await testTab(page, tab);
});

test("Expect clicking the studies tab to go to the correct url and to show all of the relevant columns when selected", async ({
page,
}) => {
const tab = anvilcatalogTabs.studies;
await page.goto(anvilcatalogTabs.consortia.url);
await testTab(page, tab);
});

test("Expect clicking the workspaces tab to go to the correct url and to show all of the relevant columns when selected", async ({
page,
}) => {
const tab = anvilcatalogTabs.workspaces;
await page.goto(anvilcatalogTabs.workspaces.url);
await testTab(page, tab);
});
69 changes: 69 additions & 0 deletions explorer/e2e/anvil-catalog/anvilcatalog-tabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */

import { AnvilCatalogTabCollection, TabDescription } from "../testInterfaces";

export const anvilcatalogTabs: AnvilCatalogTabCollection = {
consortia: {
emptyFirstColumn: false,
preselectedColumns: [
{ name: "Consortium", sortable: true },
{ name: "dbGap Id", sortable: true },
{ name: "Consent Codes", sortable: true },
{ name: "Disease (indication)", sortable: true },
{ name: "Data Type", sortable: true },
{ name: "Study Design", sortable: true },
{ name: "Participants", sortable: true },
{ name: "Size (TB)", sortable: true },
],
selectableColumns: [
{ name: "Study", sortable: true },
{ name: "Workspaces", sortable: true },
],
tabName: "Consortia",
url: "/data/consortia",
},
studies: {
emptyFirstColumn: false,
preselectedColumns: [
{ name: "Study", sortable: true },
{ name: "dbGap Id", sortable: true },
{ name: "Consortium", sortable: true },
{ name: "Consent Codes", sortable: true },
{ name: "Disease (indication)", sortable: true },
{ name: "Data Type", sortable: true },
{ name: "Study Design", sortable: true },
{ name: "Workspaces", sortable: true },
{ name: "Participants", sortable: true },
{ name: "Size (TB)", sortable: true },
],
selectableColumns: [],
tabName: "Studies",
url: "/data/studies",
},
workspaces: {
emptyFirstColumn: false,
preselectedColumns: [
{ name: "Consortium", sortable: true },
{ name: "Terra Workspace", sortable: true },
{ name: "Study", sortable: true },
{ name: "dbGap Id", sortable: true },
{ name: "Consent Code", sortable: true },
{ name: "Disease (indication)", sortable: true },
{ name: "Data Type", sortable: true },
{ name: "Study Design", sortable: true },
{ name: "Participants", sortable: true },
{ name: "Size (TB)", sortable: true },
],
selectableColumns: [],
tabName: "Workspaces",
url: "/data/workspaces",
},
};

export const anvilCatalogTabList: TabDescription[] = [
anvilcatalogTabs.consortia,
anvilcatalogTabs.studies,
anvilcatalogTabs.workspaces,
];

/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/
42 changes: 18 additions & 24 deletions explorer/e2e/anvil-catalog/anvilcatalog-url.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import { expect, test } from "@playwright/test";
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */
import { test } from "@playwright/test";
import { testUrl } from "../testFunctions";
import { anvilCatalogTabList, anvilcatalogTabs } from "./anvilcatalog-tabs";

test("Expect workspaces url to go to workspaces tab", async ({ page }) => {
await page.goto("/data/workspaces");
await expect(
page.locator("_react=Tabs >> button >> text='Workspaces'")
).toHaveAttribute("aria-selected", "true");
await expect(
page.locator("text='Terra Workspace Name' >> nth=0")
).toBeVisible();
test("Expect the consortia tab to appear as selected when the corresponding url is accessed", async ({
page,
}) => {
const tab = anvilcatalogTabs.consortia;
await testUrl(page, tab, anvilCatalogTabList);
});

test("Expect studies url to go to studies tab", async ({ page }) => {
await page.goto("/data/studies");
await expect(
page.locator("_react=Tabs >> button >> text='Studies'")
).toHaveAttribute("aria-selected", "true");
await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible();
test("Expect the studies tab to appear as selected when the corresponding url is accessedb", async ({
page,
}) => {
const tab = anvilcatalogTabs.studies;
await testUrl(page, tab, anvilCatalogTabList);
});

test("Expect consortia url to go to consortia tab", async ({ page }) => {
await page.goto("/data/consortia");
await expect(
page.locator("_react=Tabs >> button >> text='Consortia'")
).toHaveAttribute("aria-selected", "true");
await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible();
test("Expect the workspaces tab to appear as selected when the corresponding url is accessed", async ({
page,
}) => {
const tab = anvilcatalogTabs.workspaces;
await testUrl(page, tab, anvilCatalogTabList);
});

/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/
2 changes: 1 addition & 1 deletion explorer/e2e/anvil/anvil-pagination-content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const BackButtonTestID = "WestRoundedIcon";
const ForwardButtonTestID = "EastRoundedIcon";

test.setTimeout(90000);
test("Check forward and backwards pagination causes the page content to change", async ({
test("Check forward and backwards pagination causes the page content to change on the biosamples apge", async ({
page,
}) => {
// Navigate to the BioSamples page
Expand Down
34 changes: 0 additions & 34 deletions explorer/e2e/general/tabs.spec.ts

This file was deleted.

54 changes: 54 additions & 0 deletions explorer/e2e/testFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,58 @@ export async function testSort(page: Page, tab: TabDescription): Promise<void> {
}
}

export async function testSelectableColumns(
page: Page,
tab: TabDescription
): Promise<void> {
await page.goto(tab.url);
await page.getByRole("button").getByText("Edit Columns").click();
await expect(page.getByRole("menu")).toBeVisible();
for (const column of tab.selectableColumns) {
const checkboxLocator = page
.getByRole("menu")
.locator("*")
//.getByText(column.name, {exact: true});
.filter({
has: page
.locator("*")
.filter({ has: page.getByText(column.name, { exact: true }) }),
})
.getByRole("checkbox");
//await checkboxLocator.click();
await expect(checkboxLocator).toBeEnabled();
await expect(checkboxLocator).not.toBeChecked();
await checkboxLocator.click();
await expect(checkboxLocator).toBeChecked();
}
await page.getByRole("document").click();
await expect(page.getByRole("menu")).not.toBeVisible();
await expect(page.getByRole("columnheader")).toContainText(
tab.selectableColumns.map((x) => x.name)
);
}

export async function testPreSelectedColumns(
page: Page,
tab: TabDescription
): Promise<void> {
await page.goto(tab.url);
await page.getByRole("button").getByText("Edit Columns").click();
await expect(page.getByRole("menu")).toBeVisible();
for (const column of tab.preselectedColumns) {
const checkboxLocator = page
.getByRole("menu")
.locator("*")
//.getByText(column.name, {exact: true});
.filter({
has: page
.locator("*")
.filter({ has: page.getByText(column.name, { exact: true }) }),
})
.getByRole("checkbox");
await expect(checkboxLocator).toBeDisabled();
await expect(checkboxLocator).toBeChecked();
}
}

/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/

0 comments on commit 74589b3

Please sign in to comment.