Skip to content

Commit 3a2fc7c

Browse files
author
Penelope Lischer
committed
15839 - Implement smoke test user flow for Org Admin page
Uncomment daily data user flow tests
1 parent 86c4b77 commit 3a2fc7c

File tree

3 files changed

+131
-2
lines changed

3 files changed

+131
-2
lines changed

frontend-react/e2e/pages/authenticated/organization.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import {expect, Page} from "@playwright/test";
12
import { RSOrganizationSettings } from "../../../src/config/endpoints/settings";
23
import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../mocks/organizations";
34
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../BasePage";
45

56
export class OrganizationPage extends BasePage {
67
static readonly API_ORGANIZATIONS = "/api/settings/organizations";
78
protected _organizationSettings: RSOrganizationSettings[];
9+
810
constructor(testArgs: BasePageTestArgs) {
911
super(
1012
{
@@ -38,4 +40,14 @@ export class OrganizationPage extends BasePage {
3840
},
3941
];
4042
}
43+
44+
async testTableHeaders() {
45+
await expect(this.page.locator(".usa-table th").nth(0)).toHaveText(/Name/);
46+
await expect(this.page.locator(".usa-table th").nth(1)).toHaveText(/Description/);
47+
await expect(this.page.locator(".usa-table th").nth(2)).toHaveText(/Jurisdiction/);
48+
await expect(this.page.locator(".usa-table th").nth(3)).toHaveText(/State/);
49+
await expect(this.page.locator(".usa-table th").nth(4)).toHaveText(/County/);
50+
51+
return true;
52+
}
4153
}

frontend-react/e2e/spec/chromium-only/authenticated/daily-data-page-user-flow.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ const SMOKE_RECEIVERS = [TEST_ORG_UP_RECEIVER_UP, TEST_ORG_CP_RECEIVER_CP, TEST_
7474
test.describe(
7575
"Daily Data page - user flow smoke tests",
7676
{
77-
// TODO: Investigate Daily Data page - user flow smoke tests › admin user › ignore org - FULL_ELR receiver › filter › on 'Apply' › clears 'Report ID'
78-
//tag: "@smoke",
77+
tag: "@smoke",
7978
},
8079
() => {
8180
test.describe("admin user", () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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

Comments
 (0)