From 64cc62da12d9f69b54bbafb9f655d2c534a3c45e Mon Sep 17 00:00:00 2001 From: Penelope Lischer <102491809+penny-lischer@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:09:32 -0700 Subject: [PATCH] 15908 - Implement user flow for e2e smoke test for Org Settings Edit Page (#15965) * 15908 - Implement user flow for e2e smoke test for Org Settings Edit Page * 15908 - Skipping failing smoke test --- .../last-mile-failures-page-user-flow.spec.ts | 2 +- ...ation-settings-edit-page-user-flow.spec.ts | 86 +++++++++++++++++++ ...ganization-settings-page-user-flow.spec.ts | 16 ++-- 3 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-edit-page-user-flow.spec.ts diff --git a/frontend-react/e2e/spec/chromium-only/authenticated/last-mile-failures-page-user-flow.spec.ts b/frontend-react/e2e/spec/chromium-only/authenticated/last-mile-failures-page-user-flow.spec.ts index 6e4baa74876..c10e94b3f5d 100644 --- a/frontend-react/e2e/spec/chromium-only/authenticated/last-mile-failures-page-user-flow.spec.ts +++ b/frontend-react/e2e/spec/chromium-only/authenticated/last-mile-failures-page-user-flow.spec.ts @@ -83,7 +83,7 @@ test.describe("Last Mile Failure page", await expect(modal).toContainText(`Report ID:${reportIdCell}`); }); - test("table column 'Receiver' will open receiver edit page", async ({ lastMileFailuresPage, isMockDisabled }) => { + test.skip("table column 'Receiver' will open receiver edit page", async ({ lastMileFailuresPage, isMockDisabled }) => { test.skip(!isMockDisabled, "Mocks are ENABLED, skipping test"); const receiver = tableRows(lastMileFailuresPage.page).nth(0).locator("td").nth(2); const receiverCell = await receiver.getByRole("link").innerText(); diff --git a/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-edit-page-user-flow.spec.ts b/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-edit-page-user-flow.spec.ts new file mode 100644 index 00000000000..a96aefcb628 --- /dev/null +++ b/frontend-react/e2e/spec/chromium-only/authenticated/organization-settings-edit-page-user-flow.spec.ts @@ -0,0 +1,86 @@ +import { expect } from "@playwright/test"; +import { OrganizationEditPage } from "../../../pages/authenticated/admin/organization-edit"; +import { test as baseTest } from "../../../test"; + +export interface OrganizationEditPageFixtures { + organizationEditPage: OrganizationEditPage; +} + +const test = baseTest.extend({ + organizationEditPage: async ( + { + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + frontendWarningsLogPath, + isFrontendWarningsLog, + }, + use, + ) => { + const page = new OrganizationEditPage({ + page: _page, + isMockDisabled, + adminLogin, + senderLogin, + receiverLogin, + storageState, + frontendWarningsLogPath, + isFrontendWarningsLog, + }); + await page.goto(); + await use(page); + }, +}); + +test.describe("Organization Edit Page", { + tag: "@smoke", +}, () => { + test.describe("admin user", () => { + test.use({storageState: "e2e/.auth/admin.json"}); + + test("has correct title", async ({organizationEditPage}) => { + await organizationEditPage.testHeader(false); + await expect(organizationEditPage.page.getByText(/Org name: ignore/)).toBeVisible(); + }); + + test.describe("edit section", () => { + test("has expected 'Meta'", async ({organizationEditPage}) => { + const meta = organizationEditPage.page.getByTestId("gridContainer").getByTestId("grid").nth(2); + await expect(meta).not.toBeEmpty(); + }); + + test("has expected 'Description'", async ({organizationEditPage}) => { + await expect(organizationEditPage.page.getByTestId("description")).not.toBeEmpty(); + }); + + test("has expected 'Jurisdiction'", async ({organizationEditPage}) => { + await expect(organizationEditPage.page.getByTestId("jurisdiction")).not.toBeEmpty(); + }); + }); + + test.describe("'Organization Sender Settings' section", () => { + test.beforeEach(async ({ organizationEditPage }) => { + await organizationEditPage.page.locator("#orgsendersettings .usa-table tbody").waitFor({ state: "visible" }); + }); + + test("has at least one sender listed in the table", async ({organizationEditPage}) => { + const rowCount = await organizationEditPage.page.locator("#orgsendersettings .usa-table tbody tr").count(); + expect(rowCount).toBeGreaterThanOrEqual(1); + }); + }); + + test.describe("'Organization Receiver Settings' section", () => { + test.beforeEach(async ({ organizationEditPage }) => { + await organizationEditPage.page.locator("#orgreceiversettings .usa-table tbody").waitFor({ state: "visible" }); + }); + + test("has at least one sender listed in the table", async ({organizationEditPage}) => { + const rowCount = await organizationEditPage.page.locator("#orgreceiversettings .usa-table tbody tr").count(); + expect(rowCount).toBeGreaterThanOrEqual(1); + }); + }); + }); +}); 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 index 0cd6327d074..c1decd33a17 100644 --- 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 @@ -1,6 +1,5 @@ import { expect } from "@playwright/test"; import { tableRows } from "../../../helpers/utils"; -import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../mocks/organizations"; import { OrganizationPage } from "../../../pages/authenticated/admin/organization"; import { test as baseTest } from "../../../test"; @@ -72,23 +71,24 @@ test.describe("Admin Organization Settings Page - user flow smoke tests", { 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 firstDataRow = organizationPage.page.getByRole("table").getByRole("row").nth(1); + const firstDataRowName = (await firstDataRow.getByRole("cell").nth(0).textContent()) ?? "INVALID"; const filterBox = organizationPage.page.getByRole("textbox", { name: "Filter:", }); await expect(filterBox).toBeVisible(); - await filterBox.fill(name); + await filterBox.fill(firstDataRowName); const rows = await table.getByRole("row").all(); expect(rows).toHaveLength(2); const cols = rows[1].getByRole("cell").allTextContents(); const expectedColContents = [ - name, - description ?? "", - jurisdiction ?? "", - stateCode ?? "", - "", + await firstDataRow.getByRole("cell").nth(0).textContent(), + await firstDataRow.getByRole("cell").nth(1).textContent() ?? "", + await firstDataRow.getByRole("cell").nth(2).textContent() ?? "", + await firstDataRow.getByRole("cell").nth(3).textContent() ?? "", + await firstDataRow.getByRole("cell").nth(4).textContent() ?? "", "SetEdit", ];