|
1 | | -import { expect, test } from "@playwright/test"; |
2 | | -import { anvilTabs, anvilTabTestOrder } from "./anvil-tabs"; |
| 1 | +import { test } from "@playwright/test"; |
| 2 | +import { testSort } from "../testFunctions"; |
| 3 | +import { anvilTabs } from "./anvil-tabs"; |
3 | 4 |
|
4 | | -test.setTimeout(90000); |
5 | | -test("Expect clicking the column header to change the first displayed entry in each column on each tab, except where all tabs have the same values", async ({ |
| 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 datasets tab, except where all tabs have the same values", async ({ |
| 8 | + page, |
| 9 | +}) => { |
| 10 | + await testSort(page, anvilTabs.datasets); |
| 11 | +}); |
| 12 | + |
| 13 | +test("Expect clicking the column header to change the first displayed entry in each column on the donors tab, except where all tabs have the same values", async ({ |
| 14 | + page, |
| 15 | +}) => { |
| 16 | + await testSort(page, anvilTabs.donors); |
| 17 | +}); |
| 18 | + |
| 19 | +test("Expect clicking the column header to change the first displayed entry in each column on the biosamples tab, except where all tabs have the same values", async ({ |
| 20 | + page, |
| 21 | +}) => { |
| 22 | + await testSort(page, anvilTabs.biosamples); |
| 23 | +}); |
| 24 | + |
| 25 | +test("Expect clicking the column header to change the first displayed entry in each column on the activities tab, except where all tabs have the same values", async ({ |
6 | 26 | page, |
7 | 27 | }) => { |
8 | | - // For each tab |
9 | | - for (const tabId of anvilTabTestOrder) { |
10 | | - // Get the current tab, and go to it's URL |
11 | | - const tab = anvilTabs[tabId]; |
12 | | - await page.goto(tab.url); |
13 | | - // For each column |
14 | | - for ( |
15 | | - let columnPosition = 0; |
16 | | - columnPosition < tab.preselectedColumns.length; |
17 | | - columnPosition++ |
18 | | - ) { |
19 | | - // Get the column position, taking into account that some tabs start with a non-text first column |
20 | | - if (tab.preselectedColumns[columnPosition].sortable) { |
21 | | - const workColumnPosition: number = tab.emptyFirstColumn |
22 | | - ? columnPosition + 1 |
23 | | - : columnPosition; |
24 | | - // Locators for the first and last cells in a particular column position on the page |
25 | | - const firstElementTextLocator = page |
26 | | - .getByRole("rowgroup") |
27 | | - .nth(1) |
28 | | - .getByRole("row") |
29 | | - .nth(0) |
30 | | - .getByRole("cell") |
31 | | - .nth(workColumnPosition); |
32 | | - const lastElementTextLocator = page |
33 | | - .getByRole("rowgroup") |
34 | | - .nth(1) |
35 | | - .getByRole("row") |
36 | | - .last() |
37 | | - .getByRole("cell") |
38 | | - .nth(workColumnPosition); |
39 | | - // Locator for the sort button |
40 | | - const columnSortLocator = page |
41 | | - .getByRole("columnheader", { |
42 | | - name: tab.preselectedColumns[columnPosition].name, |
43 | | - }) |
44 | | - .getByRole("button"); |
45 | | - // Expect the first and last cells to be visible |
46 | | - await expect(firstElementTextLocator).toBeVisible(); |
47 | | - await expect(lastElementTextLocator).toBeVisible(); |
48 | | - // Get the first cell text |
49 | | - const firstElementTextNoClick = |
50 | | - await firstElementTextLocator.innerText(); |
51 | | - // Sort may do nothing if the first and last element are equal, so skip testing here |
52 | | - if ( |
53 | | - (await lastElementTextLocator.innerText()) == firstElementTextNoClick |
54 | | - ) { |
55 | | - continue; |
56 | | - } |
57 | | - // Click to sort |
58 | | - await columnSortLocator.click(); |
59 | | - await expect(firstElementTextLocator).toBeVisible(); |
60 | | - const firstElementTextFirstClick = |
61 | | - await firstElementTextLocator.innerText(); |
62 | | - // Click again |
63 | | - await columnSortLocator.click(); |
64 | | - // Expect the first cell to have changed after clicking sort |
65 | | - await expect(firstElementTextLocator).toBeVisible(); |
66 | | - await expect(firstElementTextLocator).not.toHaveText( |
67 | | - firstElementTextFirstClick |
68 | | - ); |
69 | | - //await expect(firstElementTextLocator).toBeLessThanOrEqual( TODO: make this work, even though this function only works on numbers |
70 | | - // firstElementTextFirstClick |
71 | | - //); |
| 28 | + await testSort(page, anvilTabs.activities); |
| 29 | +}); |
72 | 30 |
|
73 | | - //const newFirstElementText = await getFirstElementText(workColumnPosition); |
74 | | - } |
75 | | - } |
76 | | - } |
| 31 | +test("Expect clicking the column header to change the first displayed entry in each column on the files tab, except where all tabs have the same values", async ({ |
| 32 | + page, |
| 33 | +}) => { |
| 34 | + await testSort(page, anvilTabs.files); |
77 | 35 | }); |
0 commit comments