From fd09ea9503c432603de7a9be93786204dcca8e66 Mon Sep 17 00:00:00 2001 From: Penelope Lischer <102491809+penny-lischer@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:18:57 -0700 Subject: [PATCH] Experience/15331/org settings smoke tests (#15862) * 15839 - Implement smoke test user flow for Org Admin page Uncomment daily data user flow tests * 15839 - Fixed linting * 15839 - Removing time check on smoke tests --- .../e2e/pages/authenticated/organization.ts | 12 ++ .../admin/organization-settings-page.spec.ts | 14 +-- .../daily-data-page-user-flow.spec.ts | 5 +- ...ganization-settings-page-user-flow.spec.ts | 118 ++++++++++++++++++ 4 files changed, 138 insertions(+), 11 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..80a09aa4807 100644 --- a/frontend-react/e2e/pages/authenticated/organization.ts +++ b/frontend-react/e2e/pages/authenticated/organization.ts @@ -1,3 +1,4 @@ +import { expect } 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/all/authenticated/admin/organization-settings-page.spec.ts b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts index ee9773e664c..ea405a97a83 100644 --- a/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts +++ b/frontend-react/e2e/spec/all/authenticated/admin/organization-settings-page.spec.ts @@ -1,10 +1,10 @@ -import {expect} from "@playwright/test"; -import {readFileSync} from "node:fs"; -import {join} from "node:path"; -import {fileURLToPath} from "node:url"; -import {MOCK_GET_ORGANIZATION_SETTINGS_LIST} from "../../../../mocks/organizations"; -import {OrganizationPage} from "../../../../pages/authenticated/organization"; -import {test as baseTest} from "../../../../test"; +import { expect } from "@playwright/test"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../../mocks/organizations"; +import { OrganizationPage } from "../../../../pages/authenticated/organization"; +import { test as baseTest } from "../../../../test"; const __dirname = fileURLToPath(import.meta.url); 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..1a7001cadde 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", () => { @@ -239,7 +238,6 @@ test.describe( filterStatusText = filterStatus([ TEST_ORG_UP_RECEIVER_UP, `${format(fromDate, "MM/dd/yyyy")}–${format(toDate, "MM/dd/yyyy")}`, - `${defaultStartTime}–${defaultEndTime}`, ]); await expect(dailyDataPage.page.getByTestId("filter-status")).toContainText( filterStatusText, @@ -340,7 +338,6 @@ test.describe( let filterStatusText = filterStatus([ TEST_ORG_UP_RECEIVER_UP, `${format(fromDate, "MM/dd/yyyy")}–${format(toDate, "MM/dd/yyyy")}`, - `${defaultStartTime}–${defaultEndTime}`, ]); await expect(dailyDataPage.page.getByTestId("filter-status")).toContainText(filterStatusText); 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..fa74fc13713 --- /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"); + }); + }); + }); +});