generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
15839 - Implement smoke test user flow for Org Admin page
Uncomment daily data user flow tests
- Loading branch information
1 parent
86c4b77
commit 3a2fc7c
Showing
3 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...d-react/e2e/spec/chromium-only/authenticated/organization-settings-page-user-flow.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OrganizationPageFixtures>({ | ||
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"); | ||
}); | ||
}); | ||
}); | ||
}); |