Skip to content

Commit ca35785

Browse files
committed
feat: first pass of tests for AnVIL-CMG (#3626)
1 parent 638dfbb commit ca35785

13 files changed

+370
-248
lines changed

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

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from "@playwright/test";
22
/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */
33

44
test("Expect workspaces url to go to workspaces tab", async ({ page }) => {
5-
await page.goto("/explore/workspaces");
5+
await page.goto("/data/workspaces");
66
await expect(
77
page.locator("_react=Tabs >> button >> text='Workspaces'")
88
).toHaveAttribute("aria-selected", "true");
@@ -12,15 +12,15 @@ test("Expect workspaces url to go to workspaces tab", async ({ page }) => {
1212
});
1313

1414
test("Expect studies url to go to studies tab", async ({ page }) => {
15-
await page.goto("/explore/studies");
15+
await page.goto("/data/studies");
1616
await expect(
1717
page.locator("_react=Tabs >> button >> text='Studies'")
1818
).toHaveAttribute("aria-selected", "true");
1919
await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible();
2020
});
2121

2222
test("Expect consortia url to go to consortia tab", async ({ page }) => {
23-
await page.goto("/explore/consortia");
23+
await page.goto("/data/consortia");
2424
await expect(
2525
page.locator("_react=Tabs >> button >> text='Consortia'")
2626
).toHaveAttribute("aria-selected", "true");

explorer/e2e/anvil/anvil-misc.spec.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.
Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
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 ({
9-
page,
10-
}) => {
8+
test("Check forward and backwards pagination causes the ", async ({ page }) => {
119
// 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 });
10+
await page.goto("/explore/biosamples");
1511
await expect(page.locator("text=Biosample Id")).toBeVisible();
1612

17-
const TestThreePageText = await page.locator(PaginationSelector).innerText();
13+
const firstElementTextLocator = page
14+
.getByRole("rowgroup")
15+
.nth(1)
16+
.getByRole("row")
17+
.nth(0)
18+
.getByRole("cell")
19+
.nth(0);
20+
1821
// Should start on first page
1922
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-
23+
const max_pages = 5;
2524
const FirstTableEntries = [];
2625

2726
// Paginate forwards
28-
const FirstTableEntrySelector = "_react=TableComponent >> td >> nth=0";
2927
for (let i = 2; i < max_pages + 1; i++) {
30-
const OriginalFirstTableEntry = await page
31-
.locator(FirstTableEntrySelector)
32-
.innerText();
28+
const OriginalFirstTableEntry = await firstElementTextLocator.innerText();
3329
// Click the next button
34-
await page.locator(ForwardButtonSelector).click();
30+
await page
31+
.getByRole("button")
32+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
33+
.click();
3534
// Expect the page count to have incremented
3635
await expect(page.locator(PaginationSelector)).toContainText(
37-
`Page ${i} of ${max_pages}`
36+
`Page ${i} of `
3837
);
3938
// Expect the back button to be enabled
40-
await expect
41-
.soft(page.locator(BackButtonSelector).locator(".."))
42-
.toBeEnabled();
39+
await expect(
40+
page
41+
.getByRole("button")
42+
.filter({ has: page.getByTestId(BackButtonTestID) })
43+
).toBeEnabled();
4344
// Expect the forwards button to be enabled
4445
if (i != max_pages) {
4546
await expect(
46-
page.locator(ForwardButtonSelector).locator("..")
47+
page
48+
.getByRole("button")
49+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
4750
).toBeEnabled();
4851
}
4952
// Expect the first entry to have changed on the new page
50-
await expect(page.locator(FirstTableEntrySelector)).not.toHaveText(
53+
await expect(firstElementTextLocator).not.toHaveText(
5154
OriginalFirstTableEntry
5255
);
5356
// Remember the first entry
@@ -57,14 +60,15 @@ test("Check forward and backwards pagination causes values to change", async ({
5760
// Paginate backwards
5861
for (let i = 0; i < max_pages - 1; i++) {
5962
const OldFirstTableEntry = FirstTableEntries[max_pages - i - 2];
60-
await page.locator(BackButtonSelector).click();
63+
await page
64+
.getByRole("button")
65+
.filter({ has: page.getByTestId(BackButtonTestID) })
66+
.click();
6167
// Expect page number to be correct
6268
await expect(page.locator(PaginationSelector)).toContainText(
63-
`Page ${max_pages - i - 1} of ${max_pages}`
69+
`Page ${max_pages - i - 1} of `
6470
);
6571
// Expect page entry to be consistent with forward pagination
66-
await expect(page.locator(FirstTableEntrySelector)).toHaveText(
67-
OldFirstTableEntry
68-
);
72+
await expect(firstElementTextLocator).toHaveText(OldFirstTableEntry);
6973
}
7074
});
Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
import { expect, test } from "@playwright/test";
2+
import { anvilTabs } from "./anvil-tabs";
23

34
const PaginationSelector = "_react=Pagination";
4-
const BackButtonSelector = "data-testid=WestRoundedIcon";
5-
const ForwardButtonSelector = "data-testid=EastRoundedIcon";
5+
const BackButtonTestID = "WestRoundedIcon";
6+
const ForwardButtonTestID = "EastRoundedIcon";
67

78
test.beforeEach(async ({ page }) => {
8-
// Navigate to the BioSamples page
9-
await page.goto("/explore/");
10-
await page.locator("text=BioSamples").click();
11-
await expect(page).toHaveURL("/explore/biosamples", { timeout: 10000 });
12-
await expect(page.locator("text=Biosample Id")).toBeVisible();
9+
// Navigate to the Donors page
10+
await page.goto(anvilTabs.donors.url);
11+
await expect(
12+
page.getByRole("tab").getByText(anvilTabs.donors.tabName)
13+
).toBeVisible();
1314
});
1415

15-
test("Check first page has correct buttons", async ({ page }) => {
16+
test("Check first page has disabled back and enabled forward pagination buttons on Donors Page", async ({
17+
page,
18+
}) => {
1619
// Should start on first page
1720
await expect(page.locator(PaginationSelector)).toContainText("Page 1 of ");
1821
// Back Button should start disabled
19-
await expect(page.locator(BackButtonSelector).locator("..")).toBeDisabled();
22+
await expect(
23+
page.getByRole("button").filter({ has: page.getByTestId(BackButtonTestID) })
24+
).toBeDisabled();
2025
// Forward button should start enabled
21-
await expect(page.locator(ForwardButtonSelector).locator("..")).toBeEnabled();
26+
await expect(
27+
page
28+
.getByRole("button")
29+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
30+
).toBeEnabled();
2231
});
2332

24-
test("Check last page has correct buttons and that forward pagination increases the page count", async ({
33+
test.setTimeout(300000);
34+
test("Check that forward pagination increases the page count for the first five pages on the donors tab", async ({
2535
page,
2636
}) => {
2737
// Should start on first page, and there should be multiple pages available
@@ -35,9 +45,13 @@ test("Check last page has correct buttons and that forward pagination increases
3545
const max_pages = parseInt(
3646
SplitStartingPageText[SplitStartingPageText.length - 1]
3747
);
48+
console.log(max_pages);
3849
// Paginate forwards
3950
for (let i = 2; i < max_pages + 1; i++) {
40-
await page.locator(ForwardButtonSelector).click();
51+
await page
52+
.getByRole("button")
53+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
54+
.click();
4155
// Expect the page count to have incremented
4256
await expect(page.locator(PaginationSelector)).toContainText(
4357
`Page ${i} of ${max_pages}`
@@ -48,11 +62,13 @@ test("Check last page has correct buttons and that forward pagination increases
4862
`Page ${max_pages} of ${max_pages}`
4963
);
5064
// Expect the back button to be enabled on the last page
51-
await expect
52-
.soft(page.locator(BackButtonSelector).locator(".."))
53-
.toBeEnabled();
65+
await expect(
66+
page.getByRole("button").filter({ has: page.getByTestId(BackButtonTestID) })
67+
).toBeEnabled();
5468
// Expect the forward button to be disabled
55-
await expect
56-
.soft(page.locator(ForwardButtonSelector).locator(".."))
57-
.toBeDisabled();
69+
await expect(
70+
page
71+
.getByRole("button")
72+
.filter({ has: page.getByTestId(ForwardButtonTestID) })
73+
).toBeDisabled();
5874
});

0 commit comments

Comments
 (0)