Skip to content

Commit

Permalink
Experience/15331/org settings smoke tests (#15862)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
penny-lischer authored Sep 12, 2024
1 parent a90be0a commit fd09ea9
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 11 deletions.
12 changes: 12 additions & 0 deletions frontend-react/e2e/pages/authenticated/organization.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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";

export class OrganizationPage extends BasePage {
static readonly API_ORGANIZATIONS = "/api/settings/organizations";
protected _organizationSettings: RSOrganizationSettings[];

constructor(testArgs: BasePageTestArgs) {
super(
{
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
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");
});
});
});
});

0 comments on commit fd09ea9

Please sign in to comment.