Skip to content

Commit 74589b3

Browse files
authored
feat: added first round E2E tests for anvil-catalog (#3598) (#3639)
1 parent 6481537 commit 74589b3

File tree

8 files changed

+227
-59
lines changed

8 files changed

+227
-59
lines changed
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("/data/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("/data/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("/data/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*/

explorer/e2e/anvil/anvil-pagination-content.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const BackButtonTestID = "WestRoundedIcon";
55
const ForwardButtonTestID = "EastRoundedIcon";
66

77
test.setTimeout(90000);
8-
test("Check forward and backwards pagination causes the page content 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

explorer/e2e/general/tabs.spec.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

explorer/e2e/testFunctions.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,58 @@ export async function testSort(page: Page, tab: TabDescription): Promise<void> {
128128
}
129129
}
130130

131+
export async function testSelectableColumns(
132+
page: Page,
133+
tab: TabDescription
134+
): Promise<void> {
135+
await page.goto(tab.url);
136+
await page.getByRole("button").getByText("Edit Columns").click();
137+
await expect(page.getByRole("menu")).toBeVisible();
138+
for (const column of tab.selectableColumns) {
139+
const checkboxLocator = page
140+
.getByRole("menu")
141+
.locator("*")
142+
//.getByText(column.name, {exact: true});
143+
.filter({
144+
has: page
145+
.locator("*")
146+
.filter({ has: page.getByText(column.name, { exact: true }) }),
147+
})
148+
.getByRole("checkbox");
149+
//await checkboxLocator.click();
150+
await expect(checkboxLocator).toBeEnabled();
151+
await expect(checkboxLocator).not.toBeChecked();
152+
await checkboxLocator.click();
153+
await expect(checkboxLocator).toBeChecked();
154+
}
155+
await page.getByRole("document").click();
156+
await expect(page.getByRole("menu")).not.toBeVisible();
157+
await expect(page.getByRole("columnheader")).toContainText(
158+
tab.selectableColumns.map((x) => x.name)
159+
);
160+
}
161+
162+
export async function testPreSelectedColumns(
163+
page: Page,
164+
tab: TabDescription
165+
): Promise<void> {
166+
await page.goto(tab.url);
167+
await page.getByRole("button").getByText("Edit Columns").click();
168+
await expect(page.getByRole("menu")).toBeVisible();
169+
for (const column of tab.preselectedColumns) {
170+
const checkboxLocator = page
171+
.getByRole("menu")
172+
.locator("*")
173+
//.getByText(column.name, {exact: true});
174+
.filter({
175+
has: page
176+
.locator("*")
177+
.filter({ has: page.getByText(column.name, { exact: true }) }),
178+
})
179+
.getByRole("checkbox");
180+
await expect(checkboxLocator).toBeDisabled();
181+
await expect(checkboxLocator).toBeChecked();
182+
}
183+
}
184+
131185
/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/

0 commit comments

Comments
 (0)