R31-5: 收口门禁稳定化与资产事务超时
这个提交包含在:
@@ -11,6 +11,7 @@ export default defineConfig({
|
||||
expect: {
|
||||
timeout: 30_000,
|
||||
},
|
||||
workers: process.env.CI ? 2 : 4,
|
||||
retries: process.env.CI ? 1 : 0,
|
||||
use: {
|
||||
baseURL,
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户