Skip to content

Commit 5359bd9

Browse files
committed
fix: correct issues with anvil tests (#3637)
1 parent 82a5eb8 commit 5359bd9

File tree

8 files changed

+58
-55
lines changed

8 files changed

+58
-55
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Playwright Tests anvil-cmg
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: "16.15.1"
16+
- name: Install dependencies
17+
run: |
18+
cd explorer
19+
npm ci
20+
- name: Install Playwright Browsers
21+
run: |
22+
cd explorer
23+
npx playwright install --with-deps
24+
- name: Run Playwright tests
25+
run: |
26+
cd explorer
27+
npm run test:anvil-catalog
28+
- uses: actions/upload-artifact@v3
29+
if: always()
30+
with:
31+
name: playwright-report
32+
path: playwright-report/
33+
retention-days: 30

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import { anvilcatalogTabs } from "./anvilcatalog-tabs";
55
test.describe.configure({ mode: "parallel" });
66

77
test.setTimeout(120000);
8-
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+
test("On the Consortia tab, expect clicking the column header (the sort button) to keep the first element of the column visible", async ({
99
page,
1010
}) => {
1111
await testSortCatalog(page, anvilcatalogTabs.consortia);
1212
});
1313

1414
test.setTimeout(120000);
15-
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+
test("On the Studies tab, expect clicking the column header (the sort button) to keep the first element of the column visible", async ({
1616
page,
1717
}) => {
1818
await testSortCatalog(page, anvilcatalogTabs.studies);
1919
});
2020

2121
test.setTimeout(120000);
22-
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 ({
22+
test("On the Workspaces tab, expect clicking the column header (the sort button) to keep the first element of the column visible", async ({
2323
page,
2424
}) => {
2525
await testSortCatalog(page, anvilcatalogTabs.workspaces);

explorer/e2e/anvil-catalog/anvilcatalog-tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const anvilcatalogTabs: AnvilCatalogTabCollection = {
5050
{ name: "Consent Code", sortable: true },
5151
{ name: "Disease (indication)", sortable: true },
5252
{ name: "Data Type", sortable: true },
53-
{ name: "Study Design", sortable: true },
53+
{ name: "Study Design", sortable: false },
5454
{ name: "Participants", sortable: true },
5555
{ name: "Size (TB)", sortable: true },
5656
],

explorer/e2e/testFunctions.ts

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ export async function testSortAzure(
9494
await expect(lastElementTextLocator).toBeVisible();
9595
await expect(firstElementTextLocator).not.toHaveText("");
9696
await expect(lastElementTextLocator).not.toHaveText("");
97-
// Get the first cell text
98-
/*
99-
const firstElementTextNoClick = await firstElementTextLocator.innerText();
100-
// Sort may do nothing if the first and last element are equal, so skip testing here
101-
if (
102-
(await lastElementTextLocator.innerText()) == firstElementTextNoClick
103-
) {
104-
continue;
105-
}
106-
*/
10797
// Click to sort
10898
await columnSortLocator.click();
10999
// Expect the first and last cell to still have text after clicking sort
@@ -114,8 +104,6 @@ export async function testSortAzure(
114104
// Expect the first and last cell to still have text after clicking sort
115105
await expect(firstElementTextLocator).not.toHaveText("");
116106
await expect(lastElementTextLocator).not.toHaveText("");
117-
118-
//const newFirstElementText = await getFirstElementText(workColumnPosition);
119107
}
120108
}
121109
}
@@ -145,13 +133,6 @@ export async function testSortCatalog(
145133
.nth(0)
146134
.getByRole("cell")
147135
.nth(workColumnPosition);
148-
const lastElementTextLocator = page
149-
.getByRole("rowgroup")
150-
.nth(1)
151-
.getByRole("row")
152-
.last()
153-
.getByRole("cell")
154-
.nth(workColumnPosition);
155136
// Locator for the sort button
156137
const columnSortLocator = page
157138
.getByRole("columnheader", {
@@ -164,36 +145,13 @@ export async function testSortCatalog(
164145

165146
// Click to sort
166147
await columnSortLocator.click();
167-
// Expect the first and last cells to be visible
148+
// Expect the first and cells to still be visible
168149
await expect(firstElementTextLocator).toBeVisible();
169-
await expect(lastElementTextLocator).toBeVisible();
170-
// Get the first cell text
171-
const firstElementTextFirstClick =
172-
await firstElementTextLocator.innerText();
173-
const lastElementTextFirstClick =
174-
await lastElementTextLocator.innerText();
175-
// Sort may do nothing if the first and last element are equal, so skip testing here
176-
if (lastElementTextFirstClick == firstElementTextFirstClick) {
177-
continue;
178-
}
179-
180150
// Click again
181151
await columnSortLocator.click();
182152
// Expect the first cell to have changed after clicking sort
183153
await expect(firstElementTextLocator).toBeVisible();
184-
await expect(firstElementTextLocator).not.toHaveText(
185-
firstElementTextFirstClick
186-
);
187-
await expect(lastElementTextLocator).toBeVisible();
188-
await expect(lastElementTextLocator).not.toHaveText(
189-
lastElementTextFirstClick
190-
);
191-
/*await expect(firstElementTextLocator).toHaveText(
192-
lastElementTextFirstClick
193-
);
194-
await expect(lastElementTextLocator).toHaveText(
195-
firstElementTextFirstClick
196-
);*/
154+
await expect(firstElementTextLocator).not.toHaveText("");
197155
}
198156
}
199157
}
@@ -209,14 +167,12 @@ export async function testSelectableColumns(
209167
const checkboxLocator = page
210168
.getByRole("menu")
211169
.locator("*")
212-
//.getByText(column.name, {exact: true});
213170
.filter({
214171
has: page
215172
.locator("*")
216173
.filter({ has: page.getByText(column.name, { exact: true }) }),
217174
})
218175
.getByRole("checkbox");
219-
//await checkboxLocator.click();
220176
await expect(checkboxLocator).toBeEnabled();
221177
await expect(checkboxLocator).not.toBeChecked();
222178
await checkboxLocator.click();
@@ -240,7 +196,6 @@ export async function testPreSelectedColumns(
240196
const checkboxLocator = page
241197
.getByRole("menu")
242198
.locator("*")
243-
//.getByText(column.name, {exact: true});
244199
.filter({
245200
has: page
246201
.locator("*")

explorer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"build-storybook": "storybook build",
3232
"test": "jest --watch",
3333
"test:e2e": "playwright test",
34-
"get-cellxgene-projects-hca": "esrun ./site-config/hca-dcp/dev/scripts/get-cellxgene-projects.ts"
34+
"get-cellxgene-projects-hca": "esrun ./site-config/hca-dcp/dev/scripts/get-cellxgene-projects.ts ",
3535
"test:anvil-cmg": "playwright test -c playwright_anvil.config.ts --trace retain-on-failure",
36-
"test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts"
36+
"test:anvil-catalog": "playwright test -c playwright_anvil-catalog.config.ts --trace retain-on-failure"
3737
},
3838
"dependencies": {
3939
"@clevercanary/data-explorer-ui": "71.0.0",

explorer/playwright-report/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

explorer/playwright_anvil-catalog.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import type { PlaywrightTestConfig } from "@playwright/test";
2+
import { devices } from "@playwright/test";
3+
24
const config: PlaywrightTestConfig = {
35
expect: {
46
timeout: 10 * 1000,
57
},
8+
projects: [
9+
{
10+
name: "chromium",
11+
use: { ...devices["Desktop Chrome"] },
12+
},
13+
{
14+
name: "firefox",
15+
use: { ...devices["Desktop Firefox"] },
16+
},
17+
{
18+
name: "webkit",
19+
use: { ...devices["Desktop Safari"] },
20+
},
21+
],
622
testDir: "e2e",
723
testMatch: /.*\/(anvil-catalog)\/.*\.spec\.ts/,
824
use: {

explorer/playwright_anvil.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const config: PlaywrightTestConfig = {
3131
command: "npm run build-cc-dev:anvil-cmg && npm start",
3232
reuseExistingServer: !process.env.CI,
3333
timeout: 240 * 1000,
34-
url: "http://localhost:3000/explore",
34+
url: "http://localhost:3000/",
3535
},
3636
workers: "75%",
3737
};

0 commit comments

Comments
 (0)