diff --git a/explorer/e2e/anvil-catalog/anvilcatalog-select-tabs.spec.ts b/explorer/e2e/anvil-catalog/anvilcatalog-select-tabs.spec.ts new file mode 100644 index 000000000..87e60043f --- /dev/null +++ b/explorer/e2e/anvil-catalog/anvilcatalog-select-tabs.spec.ts @@ -0,0 +1,34 @@ +import { test } from "@playwright/test"; +import { + testPreSelectedColumns, + testSelectableColumns, +} from "../testFunctions"; +import { anvilcatalogTabs } from "./anvilcatalog-tabs"; + +test("Expect the checkboxes in the 'Edit Columns' menu to add those columns to the tab in the Consortia tab", async ({ + page, +}) => { + const tab = anvilcatalogTabs.consortia; + await testSelectableColumns(page, tab); +}); + +test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the consortia tab", async ({ + page, +}) => { + const tab = anvilcatalogTabs.consortia; + await testPreSelectedColumns(page, tab); +}); + +test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the studies tab", async ({ + page, +}) => { + const tab = anvilcatalogTabs.studies; + await testPreSelectedColumns(page, tab); +}); + +test("Expect the checkboxes for preselected columns in the 'Edit Columns' menu to be checked and disabled on the workspaces tab", async ({ + page, +}) => { + const tab = anvilcatalogTabs.workspaces; + await testPreSelectedColumns(page, tab); +}); diff --git a/explorer/e2e/anvil-catalog/anvilcatalog-sort.spec.ts b/explorer/e2e/anvil-catalog/anvilcatalog-sort.spec.ts new file mode 100644 index 000000000..4d27560d5 --- /dev/null +++ b/explorer/e2e/anvil-catalog/anvilcatalog-sort.spec.ts @@ -0,0 +1,24 @@ +import { test } from "@playwright/test"; +import { testSort } from "../testFunctions"; +import { anvilcatalogTabs } from "./anvilcatalog-tabs"; + +test.describe.configure({ mode: "parallel" }); + +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 ({ + page, +}) => { + await testSort(page, anvilcatalogTabs.consortia); +}); + +test.setTimeout(120000); +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 ({ + page, +}) => { + await testSort(page, anvilcatalogTabs.studies); +}); + +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 ({ + page, +}) => { + await testSort(page, anvilcatalogTabs.workspaces); +}); diff --git a/explorer/e2e/anvil-catalog/anvilcatalog-tabs-buttons.spec.ts b/explorer/e2e/anvil-catalog/anvilcatalog-tabs-buttons.spec.ts new file mode 100644 index 000000000..b92dd42ff --- /dev/null +++ b/explorer/e2e/anvil-catalog/anvilcatalog-tabs-buttons.spec.ts @@ -0,0 +1,27 @@ +import { test } from "@playwright/test"; +import { testTab } from "../testFunctions"; +import { anvilcatalogTabs } from "./anvilcatalog-tabs"; + +test("Expect clicking the consortia tab to go to the correct url and to show all of the relevant columns when selected", async ({ + page, +}) => { + const tab = anvilcatalogTabs.consortia; + await page.goto(anvilcatalogTabs.studies.url); + await testTab(page, tab); +}); + +test("Expect clicking the studies tab to go to the correct url and to show all of the relevant columns when selected", async ({ + page, +}) => { + const tab = anvilcatalogTabs.studies; + await page.goto(anvilcatalogTabs.consortia.url); + await testTab(page, tab); +}); + +test("Expect clicking the workspaces tab to go to the correct url and to show all of the relevant columns when selected", async ({ + page, +}) => { + const tab = anvilcatalogTabs.workspaces; + await page.goto(anvilcatalogTabs.workspaces.url); + await testTab(page, tab); +}); diff --git a/explorer/e2e/anvil-catalog/anvilcatalog-tabs.ts b/explorer/e2e/anvil-catalog/anvilcatalog-tabs.ts new file mode 100644 index 000000000..6f57eb1f0 --- /dev/null +++ b/explorer/e2e/anvil-catalog/anvilcatalog-tabs.ts @@ -0,0 +1,69 @@ +/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ + +import { AnvilCatalogTabCollection, TabDescription } from "../testInterfaces"; + +export const anvilcatalogTabs: AnvilCatalogTabCollection = { + consortia: { + emptyFirstColumn: false, + preselectedColumns: [ + { name: "Consortium", sortable: true }, + { name: "dbGap Id", sortable: true }, + { name: "Consent Codes", sortable: true }, + { name: "Disease (indication)", sortable: true }, + { name: "Data Type", sortable: true }, + { name: "Study Design", sortable: true }, + { name: "Participants", sortable: true }, + { name: "Size (TB)", sortable: true }, + ], + selectableColumns: [ + { name: "Study", sortable: true }, + { name: "Workspaces", sortable: true }, + ], + tabName: "Consortia", + url: "/data/consortia", + }, + studies: { + emptyFirstColumn: false, + preselectedColumns: [ + { name: "Study", sortable: true }, + { name: "dbGap Id", sortable: true }, + { name: "Consortium", sortable: true }, + { name: "Consent Codes", sortable: true }, + { name: "Disease (indication)", sortable: true }, + { name: "Data Type", sortable: true }, + { name: "Study Design", sortable: true }, + { name: "Workspaces", sortable: true }, + { name: "Participants", sortable: true }, + { name: "Size (TB)", sortable: true }, + ], + selectableColumns: [], + tabName: "Studies", + url: "/data/studies", + }, + workspaces: { + emptyFirstColumn: false, + preselectedColumns: [ + { name: "Consortium", sortable: true }, + { name: "Terra Workspace", sortable: true }, + { name: "Study", sortable: true }, + { name: "dbGap Id", sortable: true }, + { name: "Consent Code", sortable: true }, + { name: "Disease (indication)", sortable: true }, + { name: "Data Type", sortable: true }, + { name: "Study Design", sortable: true }, + { name: "Participants", sortable: true }, + { name: "Size (TB)", sortable: true }, + ], + selectableColumns: [], + tabName: "Workspaces", + url: "/data/workspaces", + }, +}; + +export const anvilCatalogTabList: TabDescription[] = [ + anvilcatalogTabs.consortia, + anvilcatalogTabs.studies, + anvilcatalogTabs.workspaces, +]; + +/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/ diff --git a/explorer/e2e/anvil-catalog/anvilcatalog-url.spec.ts b/explorer/e2e/anvil-catalog/anvilcatalog-url.spec.ts index 0bc944cbb..4cdc21ab4 100644 --- a/explorer/e2e/anvil-catalog/anvilcatalog-url.spec.ts +++ b/explorer/e2e/anvil-catalog/anvilcatalog-url.spec.ts @@ -1,30 +1,24 @@ -import { expect, test } from "@playwright/test"; -/* eslint-disable sonarjs/no-duplicate-string -- ignoring duplicate strings here */ +import { test } from "@playwright/test"; +import { testUrl } from "../testFunctions"; +import { anvilCatalogTabList, anvilcatalogTabs } from "./anvilcatalog-tabs"; -test("Expect workspaces url to go to workspaces tab", async ({ page }) => { - await page.goto("/data/workspaces"); - await expect( - page.locator("_react=Tabs >> button >> text='Workspaces'") - ).toHaveAttribute("aria-selected", "true"); - await expect( - page.locator("text='Terra Workspace Name' >> nth=0") - ).toBeVisible(); +test("Expect the consortia tab to appear as selected when the corresponding url is accessed", async ({ + page, +}) => { + const tab = anvilcatalogTabs.consortia; + await testUrl(page, tab, anvilCatalogTabList); }); -test("Expect studies url to go to studies tab", async ({ page }) => { - await page.goto("/data/studies"); - await expect( - page.locator("_react=Tabs >> button >> text='Studies'") - ).toHaveAttribute("aria-selected", "true"); - await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible(); +test("Expect the studies tab to appear as selected when the corresponding url is accessedb", async ({ + page, +}) => { + const tab = anvilcatalogTabs.studies; + await testUrl(page, tab, anvilCatalogTabList); }); -test("Expect consortia url to go to consortia tab", async ({ page }) => { - await page.goto("/data/consortia"); - await expect( - page.locator("_react=Tabs >> button >> text='Consortia'") - ).toHaveAttribute("aria-selected", "true"); - await expect(page.locator("text='Study Design' >> nth=0")).toBeVisible(); +test("Expect the workspaces tab to appear as selected when the corresponding url is accessed", async ({ + page, +}) => { + const tab = anvilcatalogTabs.workspaces; + await testUrl(page, tab, anvilCatalogTabList); }); - -/* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/ diff --git a/explorer/e2e/anvil/anvil-pagination-content.spec.ts b/explorer/e2e/anvil/anvil-pagination-content.spec.ts index 1144a5d18..18063ebc2 100644 --- a/explorer/e2e/anvil/anvil-pagination-content.spec.ts +++ b/explorer/e2e/anvil/anvil-pagination-content.spec.ts @@ -5,7 +5,7 @@ const BackButtonTestID = "WestRoundedIcon"; const ForwardButtonTestID = "EastRoundedIcon"; test.setTimeout(90000); -test("Check forward and backwards pagination causes the page content to change", async ({ +test("Check forward and backwards pagination causes the page content to change on the biosamples apge", async ({ page, }) => { // Navigate to the BioSamples page diff --git a/explorer/e2e/general/tabs.spec.ts b/explorer/e2e/general/tabs.spec.ts deleted file mode 100644 index 439a6ed0b..000000000 --- a/explorer/e2e/general/tabs.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { expect, test } from "@playwright/test"; - -test.setTimeout(60000); -test("Navigate through each tab, expecting them to render a table and change the url", async ({ - page, -}) => { - // Go to the front page - await page.goto("http://localhost:3000/explore"); - // Wait for the page to load - await expect(page.locator("_react=TableComponent")).toBeVisible({ - timeout: 20000, - }); - const NumTabs = (await page.$$("_react=Tabs >> button")).length; - // Go through the tabs, from back to front - for (let i = 0; i < NumTabs; i++) { - const CurrentTabNumber = NumTabs - i - 1; - const CurrentTabLocator = page.locator( - `_react=Tabs >> button >> nth=${CurrentTabNumber}` - ); - const currentUrl = page.url(); - // Check that the next tab is not selected - await expect(CurrentTabLocator).toHaveAttribute("aria-selected", "false"); - await expect(CurrentTabLocator).not.toHaveClass(/Mui-selected/); - // Click the next tab - await CurrentTabLocator.click(); - // Check that the next tab is selected - await expect(CurrentTabLocator).toHaveAttribute("aria-selected", "true", { - timeout: 30000, - }); - await expect(CurrentTabLocator).toHaveClass(/Mui-selected/); - // Check that the next page has changes - await expect(page).not.toHaveURL(currentUrl, { timeout: 20000 }); - } -}); diff --git a/explorer/e2e/testFunctions.ts b/explorer/e2e/testFunctions.ts index cb36ec475..cc56a6a06 100644 --- a/explorer/e2e/testFunctions.ts +++ b/explorer/e2e/testFunctions.ts @@ -128,4 +128,58 @@ export async function testSort(page: Page, tab: TabDescription): Promise { } } +export async function testSelectableColumns( + page: Page, + tab: TabDescription +): Promise { + await page.goto(tab.url); + await page.getByRole("button").getByText("Edit Columns").click(); + await expect(page.getByRole("menu")).toBeVisible(); + for (const column of tab.selectableColumns) { + const checkboxLocator = page + .getByRole("menu") + .locator("*") + //.getByText(column.name, {exact: true}); + .filter({ + has: page + .locator("*") + .filter({ has: page.getByText(column.name, { exact: true }) }), + }) + .getByRole("checkbox"); + //await checkboxLocator.click(); + await expect(checkboxLocator).toBeEnabled(); + await expect(checkboxLocator).not.toBeChecked(); + await checkboxLocator.click(); + await expect(checkboxLocator).toBeChecked(); + } + await page.getByRole("document").click(); + await expect(page.getByRole("menu")).not.toBeVisible(); + await expect(page.getByRole("columnheader")).toContainText( + tab.selectableColumns.map((x) => x.name) + ); +} + +export async function testPreSelectedColumns( + page: Page, + tab: TabDescription +): Promise { + await page.goto(tab.url); + await page.getByRole("button").getByText("Edit Columns").click(); + await expect(page.getByRole("menu")).toBeVisible(); + for (const column of tab.preselectedColumns) { + const checkboxLocator = page + .getByRole("menu") + .locator("*") + //.getByText(column.name, {exact: true}); + .filter({ + has: page + .locator("*") + .filter({ has: page.getByText(column.name, { exact: true }) }), + }) + .getByRole("checkbox"); + await expect(checkboxLocator).toBeDisabled(); + await expect(checkboxLocator).toBeChecked(); + } +} + /* eslint-enable sonarjs/no-duplicate-string -- Checking duplicate strings again*/