From 3a2fc7c1292475411defc542341c9e6e596f0047 Mon Sep 17 00:00:00 2001 From: Penelope Lischer Date: Thu, 12 Sep 2024 09:33:09 -0700 Subject: [PATCH] 15839 - Implement smoke test user flow for Org Admin page Uncomment daily data user flow tests --- .../e2e/pages/authenticated/organization.ts | 12 ++ .../daily-data-page-user-flow.spec.ts | 3 +- ...ganization-settings-page-user-flow.spec.ts | 118 ++++++++++++++++++ 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-page-user-flow.spec.ts diff --git a/frontend-react/e2e/pages/authenticated/organization.ts b/frontend-react/e2e/pages/authenticated/organization.ts index 6d24305989d..3e8fa2163a5 100644 --- a/frontend-react/e2e/pages/authenticated/organization.ts +++ b/frontend-react/e2e/pages/authenticated/organization.ts @@ -1,3 +1,4 @@ +import {expect, Page} from "@playwright/test"; import { RSOrganizationSettings } from "../../../src/config/endpoints/settings"; import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../mocks/organizations"; import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../BasePage"; @@ -5,6 +6,7 @@ import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../Ba export class OrganizationPage extends BasePage { static readonly API_ORGANIZATIONS = "/api/settings/organizations"; protected _organizationSettings: RSOrganizationSettings[]; + constructor(testArgs: BasePageTestArgs) { super( { @@ -38,4 +40,14 @@ export class OrganizationPage extends BasePage { }, ]; } + + async testTableHeaders() { + await expect(this.page.locator(".usa-table th").nth(0)).toHaveText(/Name/); + await expect(this.page.locator(".usa-table th").nth(1)).toHaveText(/Description/); + await expect(this.page.locator(".usa-table th").nth(2)).toHaveText(/Jurisdiction/); + await expect(this.page.locator(".usa-table th").nth(3)).toHaveText(/State/); + await expect(this.page.locator(".usa-table th").nth(4)).toHaveText(/County/); + + return true; + } } diff --git a/frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts b/frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts index c39aaff902e..4b843e01167 100644 --- a/frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts +++ b/frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts @@ -74,8 +74,7 @@ const SMOKE_RECEIVERS = [TEST_ORG_UP_RECEIVER_UP, TEST_ORG_CP_RECEIVER_CP, TEST_ test.describe( "Daily Data page - user flow smoke tests", { - // TODO: Investigate Daily Data page - user flow smoke tests › admin user › ignore org - FULL_ELR receiver › filter › on 'Apply' › clears 'Report ID' - //tag: "@smoke", + tag: "@smoke", }, () => { test.describe("admin user", () => { diff --git a/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-page-user-flow.spec.ts b/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-page-user-flow.spec.ts new file mode 100644 index 00000000000..7af645edefe --- /dev/null +++ b/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-page-user-flow.spec.ts @@ -0,0 +1,118 @@ +import {expect} from "@playwright/test"; +import {tableRows} from "../../../helpers/utils"; +import {MOCK_GET_ORGANIZATION_SETTINGS_LIST} from "../../../mocks/organizations"; +import {OrganizationPage} from "../../../pages/authenticated/organization"; +import {test as baseTest} from "../../../test"; + + +export interface OrganizationPageFixtures { + organizationPage: OrganizationPage; +} + +const test = baseTest.extend({ + organizationPage: async ( + { + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + frontendWarningsLogPath, + isFrontendWarningsLog, + }, + use, + ) => { + const page = new OrganizationPage({ + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + frontendWarningsLogPath, + isFrontendWarningsLog, + }); + await page.goto(); + await use(page); + }, +}); + +test.describe("Admin Organization Settings Page - user flow smoke tests",{ + tag: "@smoke", +}, () => { + test.describe("admin user", () => { + test.use({storageState: "e2e/.auth/admin.json"}); + + test.describe("header", () => { + test("has correct title + heading", async ({organizationPage}) => { + await organizationPage.testHeader(); + }); + }); + + test.describe("table", () => { + test.beforeEach(async ({ organizationPage }) => { + await organizationPage.page.locator(".usa-table tbody").waitFor({ state: "visible" }); + }); + + test("has correct headers", async ({organizationPage}) => { + const result = await organizationPage.testTableHeaders(); + expect(result).toBe(true); + }); + + test("displays data", async ({organizationPage}) => { + const rowCount = await tableRows(organizationPage.page).count(); + // Heading with result length + await expect( + organizationPage.page.getByRole("heading", { + name: `Organizations (${rowCount})`, + }), + ).toBeVisible(); + }); + + test("filtering works as expected", async ({organizationPage}) => { + const table = organizationPage.page.getByRole("table"); + const {description, name, jurisdiction, stateCode} = MOCK_GET_ORGANIZATION_SETTINGS_LIST[2]; + const filterBox = organizationPage.page.getByRole("textbox", { + name: "Filter:", + }); + + await expect(filterBox).toBeVisible(); + + await filterBox.fill(name); + const rows = await table.getByRole("row").all(); + expect(rows).toHaveLength(2); + const cols = rows[1].getByRole("cell").allTextContents(); + const expectedColContents = [ + name, + description ?? "", + jurisdiction ?? "", + stateCode ?? "", + "", + "SetEdit", + ]; + + for (const [i, col] of (await cols).entries()) { + expect(col).toBe(expectedColContents[i]); + } + }); + + test('selecting "Set" updates link label in navigation', async ({organizationPage}) => { + const firstDataRow = organizationPage.page.getByRole("table").getByRole("row").nth(1); + const firstDataRowName = (await firstDataRow.getByRole("cell").nth(0).textContent()) ?? "INVALID"; + const setButton = firstDataRow.getByRole("button", { + name: "Set", + }); + + await expect(setButton).toBeVisible(); + await setButton.click(); + + const orgLink = organizationPage.page.getByRole("link", { + name: firstDataRowName, + }); + await expect(orgLink).toBeVisible(); + await expect(orgLink).toHaveAttribute("href", "/admin/settings"); + }); + }); + }); +});