Skip to content

Commit 1002efb

Browse files
committed
feat: added first round E2E tests for anvil-catalog (#3598)
1 parent 63415d9 commit 1002efb

13 files changed

+444
-171
lines changed

explorer/e2e/anvil-catalog/anvilcatalog-filters.spec.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { test } from "@playwright/test";
2+
import {
3+
testPreSelectedColumns,
4+
testSelectableColumns,
5+
} from "../testFunctions";
6+
import { anvilcatalogTabs } from "./anvilcatalog-tabs";
7+
8+
test("Expect the checkboxes in the 'Edit Columns' menu to add those columns to the tab in the Consortia tab", async ({
9+
page,
10+
}) => {
11+
const tab = anvilcatalogTabs.consortia;
12+
await testSelectableColumns(page, tab);
13+
});
14+
15+
test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the consortia tab", async ({
16+
page,
17+
}) => {
18+
const tab = anvilcatalogTabs.consortia;
19+
await testPreSelectedColumns(page, tab);
20+
});
21+
22+
test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the studies tab", async ({
23+
page,
24+
}) => {
25+
const tab = anvilcatalogTabs.studies;
26+
await testPreSelectedColumns(page, tab);
27+
});
28+
29+
test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the workspaces tab", async ({
30+
page,
31+
}) => {
32+
const tab = anvilcatalogTabs.workspaces;
33+
await testPreSelectedColumns(page, tab);
34+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test } from "@playwright/test";
2+
import { testSort } from "../testFunctions";
3+
import { anvilcatalogTabs } from "./anvilcatalog-tabs";
4+
5+
test.describe.configure({ mode: "parallel" });
6+
7+
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 ({
8+
page,
9+
}) => {
10+
await testSort(page, anvilcatalogTabs.consortia);
11+
});
12+
13+
test.setTimeout(120000);
14+
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 ({
15+
page,
16+
}) => {
17+
await testSort(page, anvilcatalogTabs.studies);
18+
});
19+
20+
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 ({
21+
page,
22+
}) => {
23+
await testSort(page, anvilcatalogTabs.workspaces);
24+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { test } from "@playwright/test";
2+
import { testTab } from "../testFunctions";
3+
import { anvilcatalogTabs } from "./anvilcatalog-tabs";
4+
5+
test("Expect clicking the consortia tab to go to the correct url and to show all of the relevant columns when selected", async ({
6+
page,
7+
}) => {
8+
const tab = anvilcatalogTabs.consortia;
9+
await page.goto(anvilcatalogTabs.studies.url);
10+
await testTab(page, tab);
11+
});
12+
13+
test("Expect clicking the studies tab to go to the correct url and to show all of the relevant columns when selected", async ({
14+
page,
15+
}) => {
16+
const tab = anvilcatalogTabs.studies;
17+
await page.goto(anvilcatalogTabs.consortia.url);
18+
await testTab(page, tab);
19+
});
20+
21+
test("Expect clicking the workspaces tab to go to the correct url and to show all of the relevant columns when selected", async ({
22+
page,
23+
}) => {
24+
const tab = anvilcatalogTabs.workspaces;
25+
await page.goto(anvilcatalogTabs.workspaces.url);
26+
await testTab(page, tab);
27+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */
2+
3+
import { AnvilCatalogTabCollection, TabDescription } from "../testInterfaces";
4+
5+
export const anvilcatalogTabs: AnvilCatalogTabCollection = {
6+
consortia: {
7+
emptyFirstColumn: false,
8+
preselectedColumns: [
9+
{ name: "Consortium", sortable: true },
10+
{ name: "dbGap Id", sortable: true },
11+
{ name: "Consent Codes", sortable: true },
12+
{ name: "Disease (indication)", sortable: true },
13+
{ name: "Data Type", sortable: true },
14+
{ name: "Study Design", sortable: true },
15+
{ name: "Participants", sortable: true },
16+
{ name: "Size (TB)", sortable: true },
17+
],
18+
selectableColumns: [
19+
{ name: "Study", sortable: true },
20+
{ name: "Workspaces", sortable: true },
21+
],
22+
tabName: "Consortia",
23+
url: "/data/consortia",
24+
},
25+
studies: {
26+
emptyFirstColumn: false,
27+
preselectedColumns: [
28+
{ name: "Study", sortable: true },
29+
{ name: "dbGap Id", sortable: true },
30+
{ name: "Consortium", sortable: true },
31+
{ name: "Consent Codes", sortable: true },
32+
{ name: "Disease (indication)", sortable: true },
33+
{ name: "Data Type", sortable: true },
34+
{ name: "Study Design", sortable: true },
35+
{ name: "Workspaces", sortable: true },
36+
{ name: "Participants", sortable: true },
37+
{ name: "Size (TB)", sortable: true },
38+
],
39+
selectableColumns: [],
40+
tabName: "Studies",
41+
url: "/data/studies",
42+
},
43+
workspaces: {
44+
emptyFirstColumn: false,
45+
preselectedColumns: [
46+
{ name: "Consortium", sortable: true },
47+
{ name: "Terra Workspace", sortable: true },
48+
{ name: "Study", sortable: true },
49+
{ name: "dbGap Id", sortable: true },
50+
{ name: "Consent Code", sortable: true },
51+
{ name: "Disease (indication)", sortable: true },
52+
{ name: "Data Type", sortable: true },
53+
{ name: "Study Design", sortable: true },
54+
{ name: "Participants", sortable: true },
55+
{ name: "Size (TB)", sortable: true },
56+
],
57+
selectableColumns: [],
58+
tabName: "Workspaces",
59+
url: "/data/workspaces",
60+
},
61+
};
62+
63+
export const anvilCatalogTabList: TabDescription[] = [
64+
anvilcatalogTabs.consortia,
65+
anvilcatalogTabs.studies,
66+
anvilcatalogTabs.workspaces,
67+
];
68+
69+
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/
Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
import { expect, test } from "@playwright/test";
2-
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */
1+
import { test } from "@playwright/test";
2+
import { testUrl } from "../testFunctions";
3+
import { anvilCatalogTabList, anvilcatalogTabs } from "./anvilcatalog-tabs";
34

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

14-
test("Expect studies url to go to studies tab", async ({ page }) => {
15-
await page.goto("/explore/studies");
16-
await expect(
17-
page.locator("_react=Tabs >> button >> text='Studies'")
18-
).toHaveAttribute("aria-selected", "true");
19-
await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible();
12+
test("Expect the studies tab to appear as selected when the corresponding url is accessedb", async ({
13+
page,
14+
}) => {
15+
const tab = anvilcatalogTabs.studies;
16+
await testUrl(page, tab, anvilCatalogTabList);
2017
});
2118

22-
test("Expect consortia url to go to consortia tab", async ({ page }) => {
23-
await page.goto("/explore/consortia");
24-
await expect(
25-
page.locator("_react=Tabs >> button >> text='Consortia'")
26-
).toHaveAttribute("aria-selected", "true");
27-
await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible();
19+
test("Expect the workspaces tab to appear as selected when the corresponding url is accessed", async ({
20+
page,
21+
}) => {
22+
const tab = anvilcatalogTabs.workspaces;
23+
await testUrl(page, tab, anvilCatalogTabList);
2824
});
29-
30-
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/
Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
11
import { expect, test } from "@playwright/test";
22

33
const PaginationSelector = "_react=Pagination";
4-
const BackButtonSelector = "data-testid=WestRoundedIcon";
5-
const ForwardButtonSelector = "data-testid=EastRoundedIcon";
4+
const BackButtonTestID = "WestRoundedIcon";
5+
const ForwardButtonTestID = "EastRoundedIcon";
66

77
test.setTimeout(90000);
8-
test("Check forward and backwards pagination causes values to change", async ({
8+
test("Check forward and backwards pagination causes the page content to change on the biosamples apge", async ({
99
page,
1010
}) => {
1111
// Navigate to the BioSamples page
12-
await page.goto("/explore/");
13-
await page.locator("text=BioSamples").click();
14-
await expect(page).toHaveURL("/explore/biosamples", { timeout: 10000 });
12+
await page.goto("/explore/biosamples");
1513
await expect(page.locator("text=Biosample Id")).toBeVisible();
1614

17-
const TestThreePageText = await page.locator(PaginationSelector).innerText();
15+
const firstElementTextLocator = page
16+
.getByRole("rowgroup")
17+
.nth(1)
18+
.getByRole("row")
19+
.nth(0)
20+
.getByRole("cell")
21+
.nth(0);
22+
1823
// Should start on first page
1924
await expect(page.locator(PaginationSelector)).toContainText("Page 1 of ");
20-
const SplitStartingPageText = TestThreePageText.split(" ");
21-
const max_pages = parseInt(
22-
SplitStartingPageText[SplitStartingPageText.length - 1]
23-
);
24-
25+
const max_pages = 5;
2526
const FirstTableEntries = [];
2627

2728
// Paginate forwards
28-
const FirstTableEntrySelector = "_react=TableComponent >> td >> nth=0";
2929
for (let i = 2; i < max_pages + 1; i++) {
30-
const OriginalFirstTableEntry = await page
31-
.locator(FirstTableEntrySelector)
32-
.innerText();
30+
const OriginalFirstTableEntry = await firstElementTextLocator.innerText();
3331
// Click the next button
34-
await page.locator(ForwardButtonSelector).click();
32+
await page
33+
.getByRole("button")
34+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
35+
.click();
3536
// Expect the page count to have incremented
3637
await expect(page.locator(PaginationSelector)).toContainText(
37-
`Page ${i} of ${max_pages}`
38+
`Page ${i} of `
3839
);
3940
// Expect the back button to be enabled
40-
await expect
41-
.soft(page.locator(BackButtonSelector).locator(".."))
42-
.toBeEnabled();
41+
await expect(
42+
page
43+
.getByRole("button")
44+
.filter({ has: page.getByTestId(BackButtonTestID) })
45+
).toBeEnabled();
4346
// Expect the forwards button to be enabled
4447
if (i != max_pages) {
4548
await expect(
46-
page.locator(ForwardButtonSelector).locator("..")
49+
page
50+
.getByRole("button")
51+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
4752
).toBeEnabled();
4853
}
4954
// Expect the first entry to have changed on the new page
50-
await expect(page.locator(FirstTableEntrySelector)).not.toHaveText(
55+
await expect(firstElementTextLocator).not.toHaveText(
5156
OriginalFirstTableEntry
5257
);
5358
// Remember the first entry
@@ -57,14 +62,15 @@ test("Check forward and backwards pagination causes values to change", async ({
5762
// Paginate backwards
5863
for (let i = 0; i < max_pages - 1; i++) {
5964
const OldFirstTableEntry = FirstTableEntries[max_pages - i - 2];
60-
await page.locator(BackButtonSelector).click();
65+
await page
66+
.getByRole("button")
67+
.filter({ has: page.getByTestId(BackButtonTestID) })
68+
.click();
6169
// Expect page number to be correct
6270
await expect(page.locator(PaginationSelector)).toContainText(
63-
`Page ${max_pages - i - 1} of ${max_pages}`
71+
`Page ${max_pages - i - 1} of `
6472
);
6573
// Expect page entry to be consistent with forward pagination
66-
await expect(page.locator(FirstTableEntrySelector)).toHaveText(
67-
OldFirstTableEntry
68-
);
74+
await expect(firstElementTextLocator).toHaveText(OldFirstTableEntry);
6975
}
7076
});

0 commit comments

Comments
 (0)