R31-5: 收口门禁稳定化与资产事务超时

这个提交包含在:
2026-03-24 08:58:52 +08:00
父节点 279be83931
当前提交 5aaa628d54
共修改 4 个文件,包含 93 行新增和 47 行删除
+19 -21
查看文件
@@ -1,25 +1,8 @@
import { expect, test, type Locator, type Page } from "@playwright/test";
import { expect, test, type Locator } from "@playwright/test";
import { EMPLOYEE, FINANCE_MGR, login, logout, MANAGER } from "./helpers/auth";
import { openNavLink } from "./helpers/navigation";
const EMPLOYEE = { identifier: "[email protected]", password: "EmployeePassword1234", name: "Employee" };
const MANAGER = { identifier: "[email protected]", password: "ManagerPassword1234", name: "Manager" };
const FINANCE_MGR = { identifier: "[email protected]", password: "FinanceMgrPassword1234", name: "Finance Manager" };
async function login(page: Page, user: { identifier: string; password: string }) {
await page.goto("/login");
await page.getByTestId("login-identifier").fill(user.identifier);
await page.getByTestId("login-password").fill(user.password);
await page.getByTestId("login-submit").click();
await expect(page).toHaveURL(/\/portal/);
}
async function logout(page: Page, userDisplayName: string) {
await page.getByRole("button", { name: userDisplayName }).click();
await page.getByRole("menuitem", { name: "退出登录" }).click();
await expect(page).toHaveURL(/\/login/);
}
async function selectFirstBusinessOption(locator: Locator) {
await expect
.poll(async () => {
@@ -45,10 +28,22 @@ async function selectFirstBusinessOption(locator: Locator) {
test("E2E 采购主链路:员工提单→经理审批→财务归档", async ({ page }) => {
const title = `Playwright 采购 ${Date.now()}`;
let requestNo = "";
await login(page, EMPLOYEE);
await (await openNavLink(page, "采购申请")).click();
const createResponsePromise = page.waitForResponse(
(response) => response.request().method() === "POST" && new URL(response.url()).pathname === "/api/purchase-requests",
);
await page.getByTestId("purchase-requests-create").click();
const createResponse = await createResponsePromise;
const createPayload = (await createResponse.json()) as {
data: { purchaseRequest: { id: string } };
};
const purchaseRequestId = createPayload.data.purchaseRequest.id;
await page.waitForResponse(
(response) => response.request().method() === "GET" && new URL(response.url()).pathname === `/api/purchase-requests/${purchaseRequestId}`,
);
await expect(page.getByTestId("purchase-title")).toBeVisible();
await page.getByTestId("purchase-title").fill(title);
@@ -72,6 +67,8 @@ test("E2E 采购主链路:员工提单→经理审批→财务归档", async (
};
const currentTaskId = submitPayload.data.currentTaskId;
await expect(page.getByTestId("purchase-detail-status")).toHaveText("审批中", { timeout: 30_000 });
requestNo = (await page.getByRole("heading", { level: 3 }).filter({ hasText: /^CG-/ }).first().textContent())?.trim() ?? "";
expect(requestNo).toMatch(/^CG-/);
await logout(page, EMPLOYEE.name);
@@ -80,7 +77,8 @@ test("E2E 采购主链路:员工提单→经理审批→财务归档", async (
const managerTaskRow = page.getByTestId("workflow-task-row").filter({ hasText: currentTaskId }).first();
await expect(managerTaskRow).toBeVisible({ timeout: 30_000 });
await managerTaskRow.getByTestId("workflow-task-detail-link").click();
await expect(page.getByTestId("workflow-task-summary")).toContainText(title);
await expect(page.getByTestId("workflow-task-summary")).toContainText("对象类型:采购申请");
await expect(page.getByTestId("workflow-task-summary")).toContainText("申请人:Employee");
await page.getByTestId("workflow-task-approve").click();
await expect(page.getByTestId("workflow-task-summary")).toContainText("状态:已完成");
@@ -90,7 +88,7 @@ test("E2E 采购主链路:员工提单→经理审批→财务归档", async (
await (await openNavLink(page, "采购申请")).click();
await page.getByRole("button", { name: "全范围" }).click();
await page.getByRole("combobox").first().selectOption("approved");
const purchaseRow = page.getByRole("row").filter({ hasText: title }).first();
const purchaseRow = page.getByRole("row").filter({ hasText: requestNo }).first();
await expect(purchaseRow).toBeVisible({ timeout: 30_000 });
await purchaseRow.click();