|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { testFilterPresence } from "../testFunctions"; |
| 3 | +import { anvilFilters, anvilTabs, anvilTabTestOrder } from "./anvil-tabs"; |
| 4 | + |
| 5 | +test.describe.configure({ mode: "parallel" }); |
| 6 | + |
| 7 | +const filter_regex = (filter: string): RegExp => |
| 8 | + new RegExp(filter + "\\s+\\([0-9]+\\)\\s*"); |
| 9 | + |
| 10 | +test("Check that all filters exist on the Datasets tab and are clickable", async ({ |
| 11 | + page, |
| 12 | +}) => { |
| 13 | + await testFilterPresence(page, anvilTabs.datasets); |
| 14 | +}); |
| 15 | + |
| 16 | +test("Check that all filters exist on the Donors tab and are clickable", async ({ |
| 17 | + page, |
| 18 | +}) => { |
| 19 | + await testFilterPresence(page, anvilTabs.donors); |
| 20 | +}); |
| 21 | + |
| 22 | +test("Check that all filters exist on the BioSamples tab and are clickable", async ({ |
| 23 | + page, |
| 24 | +}) => { |
| 25 | + await testFilterPresence(page, anvilTabs.biosamples); |
| 26 | +}); |
| 27 | + |
| 28 | +test("Check that all filters exist on the Activities tab and are clickable", async ({ |
| 29 | + page, |
| 30 | +}) => { |
| 31 | + await testFilterPresence(page, anvilTabs.activities); |
| 32 | +}); |
| 33 | + |
| 34 | +test("Check that all filters exist on the Files tab and are clickable", async ({ |
| 35 | + page, |
| 36 | +}) => { |
| 37 | + await testFilterPresence(page, anvilTabs.files); |
| 38 | +}); |
| 39 | + |
| 40 | +test("Check that the first filter on the Datasets tab creates at least one checkbox, and that checking up to the first five does not cause an error and does not cause there to be no entries in the table", async ({ |
| 41 | + page, |
| 42 | +}) => { |
| 43 | + // Goto the datasets tab |
| 44 | + await page.goto(anvilTabs.datasets.url); |
| 45 | + await expect( |
| 46 | + page.getByRole("tab").getByText(anvilTabs.datasets.tabName) |
| 47 | + ).toBeVisible(); |
| 48 | + |
| 49 | + // Select a filter |
| 50 | + await page |
| 51 | + .getByRole("button") |
| 52 | + .getByText(filter_regex(anvilFilters[4])) |
| 53 | + .click(); |
| 54 | + // Expect all checkboxes to be unchecked initially and to work properly |
| 55 | + await expect(page.getByRole("checkbox").first()).toBeVisible(); |
| 56 | + const all_checkboxes = await page.getByRole("checkbox").all(); |
| 57 | + for (let i = 0; i < all_checkboxes.length && i < 5; i++) { |
| 58 | + const checkbox = all_checkboxes[i]; |
| 59 | + await checkbox.scrollIntoViewIfNeeded(); |
| 60 | + await expect(checkbox).not.toBeChecked(); |
| 61 | + await checkbox.click(); |
| 62 | + await expect(checkbox).toBeChecked(); |
| 63 | + } |
| 64 | + await page.locator("body").click(); |
| 65 | + const firstElementTextLocator = page |
| 66 | + .getByRole("rowgroup") |
| 67 | + .nth(1) |
| 68 | + .getByRole("row") |
| 69 | + .nth(0) |
| 70 | + .getByRole("cell") |
| 71 | + .first(); |
| 72 | + await expect(firstElementTextLocator).toBeVisible(); |
| 73 | +}); |
| 74 | + |
| 75 | +test("Check that filter checkboxes are persistent across pages", async ({ |
| 76 | + page, |
| 77 | +}) => { |
| 78 | + await page.goto(anvilTabs.datasets.url); |
| 79 | + await expect( |
| 80 | + page.getByRole("tab").getByText(anvilTabs.datasets.tabName) |
| 81 | + ).toBeVisible(); |
| 82 | + await page.getByText(filter_regex(anvilFilters[3])).click(); // maybe should select a random one instead; |
| 83 | + await expect(page.getByRole("checkbox").first()).not.toBeChecked(); |
| 84 | + await page.getByRole("checkbox").first().click(); |
| 85 | + await expect(page.getByRole("checkbox").first()).toBeChecked(); |
| 86 | + await page.locator("body").click(); |
| 87 | + for (const blah of anvilTabTestOrder) { |
| 88 | + console.log(blah); |
| 89 | + await page.getByRole("tab").getByText(anvilTabs[blah].tabName).click(); |
| 90 | + const firstElementTextLocator = page |
| 91 | + .getByRole("rowgroup") |
| 92 | + .nth(1) |
| 93 | + .getByRole("row") |
| 94 | + .nth(0) |
| 95 | + .getByRole("cell") |
| 96 | + .first(); |
| 97 | + await expect(firstElementTextLocator).toBeVisible(); |
| 98 | + await expect(page.getByText(filter_regex(anvilFilters[3]))).toBeVisible(); |
| 99 | + await page.getByText(filter_regex(anvilFilters[3])).click(); |
| 100 | + await expect(page.getByRole("checkbox").first()).toBeChecked(); |
| 101 | + await page.locator("body").click(); |
| 102 | + } |
| 103 | +}); |
0 commit comments