who_need_help/e2e/tests/production-support-legal.spec.ts

68 lines
2.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import {
captureBrowserFailures,
gotoLiveView,
loginWithPassword,
projectEmail,
} from "./helpers";
test.skip(
process.env.E2E_PRODUCTION_READ_ONLY !== "1",
"This read-only staff queue check requires the production run-scoped fixture",
);
test("run-scoped support and legal fixtures are visible to production staff", async ({
browser,
}, testInfo) => {
const runID = process.env.E2E_RUN_ID;
const fixturePassword = process.env.E2E_FIXTURE_PASSWORD;
const adminEmail =
process.env.E2E_ADMIN_EMAIL ?? projectEmail("admin", testInfo.project.name);
const requesterEmail = projectEmail("requester", testInfo.project.name);
if (!runID || !fixturePassword) {
throw new Error("E2E_RUN_ID and E2E_FIXTURE_PASSWORD are required");
}
const supportSubject = `Production E2E support ${runID}`;
const supportDetails =
"Run-scoped read-only browser fixture for the production support queue.";
const removalExplanation =
"Run-scoped read-only browser fixture for the production legal review queue.";
const admin = await loginWithPassword(browser, adminEmail, fixturePassword);
const assertAdminClean = captureBrowserFailures(admin.page);
await gotoLiveView(admin.page, "/support/operations?queue=support");
await admin.page
.locator("#support-case-filters")
.getByLabel("Search")
.fill(supportSubject);
const supportRow = admin.page
.locator("main tbody tr")
.filter({ hasText: supportSubject });
await expect(supportRow).toHaveCount(1);
await supportRow.getByRole("link", { name: "Open" }).click();
await expect(
admin.page.getByRole("heading", { name: supportSubject }),
).toBeVisible();
await expect(
admin.page.getByText(supportDetails, { exact: true }),
).toBeVisible();
await gotoLiveView(admin.page, "/support/operations?queue=legal");
await admin.page
.locator("#legal-case-filters")
.getByLabel("Search")
.fill(requesterEmail);
const legalRow = admin.page.locator("main tbody tr");
await expect(legalRow).toHaveCount(1);
await legalRow.getByRole("link", { name: "Open" }).click();
await expect(
admin.page.getByText(removalExplanation, { exact: true }),
).toBeVisible();
assertAdminClean();
await admin.context.close();
});