|
| 1 | +import {expect} from "@playwright/test"; |
| 2 | +import {tableRows} from "../../../helpers/utils"; |
| 3 | +import {MOCK_GET_ORGANIZATION_SETTINGS_LIST} from "../../../mocks/organizations"; |
| 4 | +import {OrganizationPage} from "../../../pages/authenticated/organization"; |
| 5 | +import {test as baseTest} from "../../../test"; |
| 6 | + |
| 7 | + |
| 8 | +export interface OrganizationPageFixtures { |
| 9 | + organizationPage: OrganizationPage; |
| 10 | +} |
| 11 | + |
| 12 | +const test = baseTest.extend<OrganizationPageFixtures>({ |
| 13 | + organizationPage: async ( |
| 14 | + { |
| 15 | + page: _page, |
| 16 | + isMockDisabled, |
| 17 | + adminLogin, |
| 18 | + senderLogin, |
| 19 | + receiverLogin, |
| 20 | + storageState, |
| 21 | + frontendWarningsLogPath, |
| 22 | + isFrontendWarningsLog, |
| 23 | + }, |
| 24 | + use, |
| 25 | + ) => { |
| 26 | + const page = new OrganizationPage({ |
| 27 | + page: _page, |
| 28 | + isMockDisabled, |
| 29 | + adminLogin, |
| 30 | + senderLogin, |
| 31 | + receiverLogin, |
| 32 | + storageState, |
| 33 | + frontendWarningsLogPath, |
| 34 | + isFrontendWarningsLog, |
| 35 | + }); |
| 36 | + await page.goto(); |
| 37 | + await use(page); |
| 38 | + }, |
| 39 | +}); |
| 40 | + |
| 41 | +test.describe("Admin Organization Settings Page - user flow smoke tests",{ |
| 42 | + tag: "@smoke", |
| 43 | +}, () => { |
| 44 | + test.describe("admin user", () => { |
| 45 | + test.use({storageState: "e2e/.auth/admin.json"}); |
| 46 | + |
| 47 | + test.describe("header", () => { |
| 48 | + test("has correct title + heading", async ({organizationPage}) => { |
| 49 | + await organizationPage.testHeader(); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + test.describe("table", () => { |
| 54 | + test.beforeEach(async ({ organizationPage }) => { |
| 55 | + await organizationPage.page.locator(".usa-table tbody").waitFor({ state: "visible" }); |
| 56 | + }); |
| 57 | + |
| 58 | + test("has correct headers", async ({organizationPage}) => { |
| 59 | + const result = await organizationPage.testTableHeaders(); |
| 60 | + expect(result).toBe(true); |
| 61 | + }); |
| 62 | + |
| 63 | + test("displays data", async ({organizationPage}) => { |
| 64 | + const rowCount = await tableRows(organizationPage.page).count(); |
| 65 | + // Heading with result length |
| 66 | + await expect( |
| 67 | + organizationPage.page.getByRole("heading", { |
| 68 | + name: `Organizations (${rowCount})`, |
| 69 | + }), |
| 70 | + ).toBeVisible(); |
| 71 | + }); |
| 72 | + |
| 73 | + test("filtering works as expected", async ({organizationPage}) => { |
| 74 | + const table = organizationPage.page.getByRole("table"); |
| 75 | + const {description, name, jurisdiction, stateCode} = MOCK_GET_ORGANIZATION_SETTINGS_LIST[2]; |
| 76 | + const filterBox = organizationPage.page.getByRole("textbox", { |
| 77 | + name: "Filter:", |
| 78 | + }); |
| 79 | + |
| 80 | + await expect(filterBox).toBeVisible(); |
| 81 | + |
| 82 | + await filterBox.fill(name); |
| 83 | + const rows = await table.getByRole("row").all(); |
| 84 | + expect(rows).toHaveLength(2); |
| 85 | + const cols = rows[1].getByRole("cell").allTextContents(); |
| 86 | + const expectedColContents = [ |
| 87 | + name, |
| 88 | + description ?? "", |
| 89 | + jurisdiction ?? "", |
| 90 | + stateCode ?? "", |
| 91 | + "", |
| 92 | + "SetEdit", |
| 93 | + ]; |
| 94 | + |
| 95 | + for (const [i, col] of (await cols).entries()) { |
| 96 | + expect(col).toBe(expectedColContents[i]); |
| 97 | + } |
| 98 | + }); |
| 99 | + |
| 100 | + test('selecting "Set" updates link label in navigation', async ({organizationPage}) => { |
| 101 | + const firstDataRow = organizationPage.page.getByRole("table").getByRole("row").nth(1); |
| 102 | + const firstDataRowName = (await firstDataRow.getByRole("cell").nth(0).textContent()) ?? "INVALID"; |
| 103 | + const setButton = firstDataRow.getByRole("button", { |
| 104 | + name: "Set", |
| 105 | + }); |
| 106 | + |
| 107 | + await expect(setButton).toBeVisible(); |
| 108 | + await setButton.click(); |
| 109 | + |
| 110 | + const orgLink = organizationPage.page.getByRole("link", { |
| 111 | + name: firstDataRowName, |
| 112 | + }); |
| 113 | + await expect(orgLink).toBeVisible(); |
| 114 | + await expect(orgLink).toHaveAttribute("href", "/admin/settings"); |
| 115 | + }); |
| 116 | + }); |
| 117 | + }); |
| 118 | +}); |
0 commit comments