R7E-16D 审批动作二次确认
Refs: R7E-16D BIZ8-12B QAOPS8-17
这个提交包含在:
@@ -41,6 +41,14 @@ export class WorkflowTaskDetailPageObject {
|
||||
return this.page.getByTestId(TEST_IDS.workflow.actionError);
|
||||
}
|
||||
|
||||
get actionConfirmDialog() {
|
||||
return this.page.getByTestId("workflow-action-confirm-dialog");
|
||||
}
|
||||
|
||||
get actionConfirmSubmit() {
|
||||
return this.page.getByTestId("workflow-action-confirm-submit");
|
||||
}
|
||||
|
||||
get transferApproverSelect() {
|
||||
return this.page.getByTestId(TEST_IDS.workflow.transferApprover);
|
||||
}
|
||||
@@ -52,15 +60,21 @@ export class WorkflowTaskDetailPageObject {
|
||||
|
||||
async approve() {
|
||||
await this.approveBtn.click();
|
||||
await expect(this.actionConfirmDialog).toContainText("确认后将进入下一审批节点");
|
||||
await this.actionConfirmSubmit.click();
|
||||
}
|
||||
|
||||
async reject(comment: string) {
|
||||
await this.rejectCommentInput.fill(comment);
|
||||
await this.rejectBtn.click();
|
||||
await expect(this.actionConfirmDialog).toContainText("当前流程将终止");
|
||||
await this.actionConfirmSubmit.click();
|
||||
}
|
||||
|
||||
async returnTask(comment: string) {
|
||||
await this.returnCommentInput.fill(comment);
|
||||
await this.returnBtn.click();
|
||||
await expect(this.actionConfirmDialog).toContainText("回到申请人修改态");
|
||||
await this.actionConfirmSubmit.click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ test("E2E 移动审批:deep link 分流 + 离线草稿重放", async ({ page }
|
||||
await expect(page.getByText("当前离线")).toBeVisible();
|
||||
await expect(page.getByTestId("mobile-approvals-approve")).toBeEnabled({ timeout: 15_000 });
|
||||
await page.getByTestId("mobile-approvals-approve").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("只会保存为待同步草稿");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(page.getByRole("main").getByText("当前离线,通过草稿已加入待同步队列。")).toBeVisible();
|
||||
|
||||
await page.context().setOffline(false);
|
||||
@@ -119,6 +121,8 @@ test("E2E 移动审批:离线草稿冲突态可见", async ({ page }) => {
|
||||
await expect(page.getByTestId("mobile-approvals-reject")).toBeEnabled({ timeout: 15_000 });
|
||||
await page.getByTestId("mobile-approvals-comment").fill("离线驳回意见:请补充差旅安排说明");
|
||||
await page.getByTestId("mobile-approvals-reject").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("只会保存为待同步草稿");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(page.getByRole("main").getByText("当前离线,驳回草稿已加入待同步队列。")).toBeVisible();
|
||||
|
||||
await approveWorkflowTaskViaApi(managerApi.api, task.id);
|
||||
|
||||
@@ -92,6 +92,8 @@ test("E2E 采购主链路:员工提单→经理审批→财务归档", async (
|
||||
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-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(page.getByTestId("workflow-task-summary")).toContainText(/状态:(已处理|已完成|completed)/);
|
||||
|
||||
await logout(page, MANAGER.name);
|
||||
|
||||
@@ -481,6 +481,8 @@ test.describe.serial("R108 企业微信移动端视觉专项", () => {
|
||||
await manager390.page.getByTestId("mobile-approvals-comment").fill("R108 移动审批操作区验证");
|
||||
await auditMobilePage(manager390.page, { label: "企微 390-审批详情", route: `/mobile/approvals?taskId=${encodeURIComponent(task.id)}`, screenshotName: "mobile-390-approvals-detail" });
|
||||
await manager390.page.getByTestId("mobile-approvals-approve").click();
|
||||
await expect(manager390.page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await manager390.page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(manager390.page.getByText("操作成功")).toBeVisible({ timeout: 30_000 });
|
||||
await manager390.context.close();
|
||||
|
||||
|
||||
@@ -416,7 +416,19 @@ test.describe("R89 移动底部导航与核心页面", () => {
|
||||
await expect(page.getByTestId("mobile-approvals-detail")).toBeVisible();
|
||||
await expect(page.getByTestId("mobile-approvals-approve")).toBeVisible();
|
||||
await expect(page.getByTestId("mobile-approvals-reject")).toBeVisible();
|
||||
await page.getByTestId("mobile-approvals-approve").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await page.getByTestId("workflow-action-confirm-cancel").click();
|
||||
await page.context().setOffline(true);
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("offline")));
|
||||
await page.getByTestId("mobile-approvals-approve").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("只会保存为待同步草稿");
|
||||
await page.getByTestId("workflow-action-confirm-cancel").click();
|
||||
await page.context().setOffline(false);
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("online")));
|
||||
await attachScreenshot(page, testInfo, "r97-mobile-approvals.png");
|
||||
await page.getByTestId("mobile-approvals-detail-header").getByRole("button", { name: "返回" }).click();
|
||||
await expect(page).toHaveURL(/\/mobile\/approvals/);
|
||||
|
||||
await page.getByTestId("mobile-nav-reimbursements").click();
|
||||
await expect(page).toHaveURL(/\/mobile\/reimbursements/);
|
||||
|
||||
@@ -28,6 +28,8 @@ test("E2E 差旅支付主链路:申请→审批→支付→绑票", async ({ p
|
||||
await expect(taskRow).toBeVisible({ timeout: 30_000 });
|
||||
await taskRow.getByTestId("workflow-task-detail-link").click();
|
||||
await page.getByTestId("workflow-task-approve").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(page.getByTestId("workflow-task-summary")).toContainText("状态:");
|
||||
await expect(page.getByTestId("workflow-task-summary")).toContainText("已完成");
|
||||
await logout(page, MANAGER.name);
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
import type { Page, Route } from "@playwright/test";
|
||||
|
||||
import { test, expect } from "./helpers/fixtures";
|
||||
import { login, MANAGER } from "./helpers/auth";
|
||||
import { TEST_IDS } from "./helpers/testIds";
|
||||
|
||||
test.use({ serviceWorkers: "block" });
|
||||
|
||||
function envelope<T>(data: T) {
|
||||
return { requestId: "mock-workflow-confirm", data };
|
||||
}
|
||||
|
||||
async function fulfillJson<T>(route: Route, data: T) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify(envelope(data)),
|
||||
});
|
||||
}
|
||||
|
||||
const mockMe = {
|
||||
id: "employee-confirm-manager",
|
||||
employeeNo: "M-confirm",
|
||||
name: "Manager",
|
||||
email: "[email protected]",
|
||||
phone: null,
|
||||
roleCodes: ["manager"],
|
||||
profileCompleteness: {
|
||||
hasEmergencyContact: true,
|
||||
hasBankAccount: true,
|
||||
hasAvatar: false,
|
||||
hasIdNumber: false,
|
||||
score: 70,
|
||||
},
|
||||
};
|
||||
|
||||
const pendingTask = {
|
||||
id: "task-confirm-1",
|
||||
instanceId: "instance-confirm-1",
|
||||
stepId: "manager-review",
|
||||
stepName: "主管审批",
|
||||
assigneeId: mockMe.id,
|
||||
assigneeRole: "manager",
|
||||
status: "pending",
|
||||
outcome: null,
|
||||
createdAt: "2026-05-15T09:00:00.000Z",
|
||||
completedAt: null,
|
||||
workflowInstance: {
|
||||
entityType: "leave",
|
||||
entityId: "leave-confirm-1",
|
||||
currentStatus: "reviewing",
|
||||
},
|
||||
businessSummary: {
|
||||
reference: "QJ-CONFIRM-001",
|
||||
title: "R7E 审批确认测试",
|
||||
applicantName: "Employee",
|
||||
amount: null,
|
||||
duration: "1 天",
|
||||
businessStatus: "reviewing",
|
||||
},
|
||||
allowedActions: ["approve", "reject", "return"],
|
||||
};
|
||||
|
||||
const pendingTaskDetail = {
|
||||
task: {
|
||||
id: pendingTask.id,
|
||||
instanceId: pendingTask.instanceId,
|
||||
stepId: pendingTask.stepId,
|
||||
stepName: pendingTask.stepName,
|
||||
assigneeId: pendingTask.assigneeId,
|
||||
assigneeRole: pendingTask.assigneeRole,
|
||||
status: pendingTask.status,
|
||||
outcome: null,
|
||||
comment: null,
|
||||
createdAt: pendingTask.createdAt,
|
||||
completedAt: null,
|
||||
},
|
||||
workflowInstance: {
|
||||
id: pendingTask.instanceId,
|
||||
entityType: "leave",
|
||||
currentStatus: "reviewing",
|
||||
currentStepId: "manager-review",
|
||||
contextData: { standardViolations: [] },
|
||||
startedAt: "2026-05-15T09:00:00.000Z",
|
||||
completedAt: null,
|
||||
},
|
||||
reimbursement: null,
|
||||
leaveRequest: {
|
||||
id: "leave-confirm-1",
|
||||
status: "reviewing",
|
||||
startDate: "2026-06-01",
|
||||
endDate: "2026-06-01",
|
||||
startSession: "am",
|
||||
endSession: "pm",
|
||||
requestedDays: 1,
|
||||
reason: "R7E 审批动作确认",
|
||||
attachment: null,
|
||||
leaveType: { id: "annual", code: "annual", name: "年假" },
|
||||
owner: { id: "employee-confirm-applicant", employeeNo: "E-confirm", name: "Employee" },
|
||||
},
|
||||
purchaseRequest: null,
|
||||
travelRequest: null,
|
||||
allowedActions: pendingTask.allowedActions,
|
||||
history: [],
|
||||
};
|
||||
|
||||
function navigationItem(key: string, href: string, label: string, icon: string, placement = "main") {
|
||||
return { key, href, label, icon, placement, permissionCodes: [], featureFlagKey: null };
|
||||
}
|
||||
|
||||
async function mockWorkflowConfirmApis(page: Page) {
|
||||
const actionCalls = {
|
||||
approve: 0,
|
||||
reject: 0,
|
||||
return: 0,
|
||||
};
|
||||
|
||||
await page.route((url) => url.pathname.startsWith("/api/"), async (route) => {
|
||||
const request = route.request();
|
||||
const url = new URL(request.url());
|
||||
const path = url.pathname;
|
||||
|
||||
if (path === "/api/auth/sso/providers") {
|
||||
await fulfillJson(route, []);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/auth/wecom/config") {
|
||||
await fulfillJson(route, {
|
||||
enabled: true,
|
||||
entryEnabled: true,
|
||||
oauthEnabled: true,
|
||||
corpId: "wx-test-corp",
|
||||
agentId: "1000002",
|
||||
loginUrl: "/api/auth/wecom/login?returnTo=%2Fportal",
|
||||
bindEnabled: true,
|
||||
defaultReturnTo: "/portal",
|
||||
status: "ready",
|
||||
statusReasons: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/auth/login" || path === "/api/auth/refresh") {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
headers: { "set-cookie": "has_session=1; Path=/; SameSite=Lax" },
|
||||
body: JSON.stringify(envelope({
|
||||
accessToken: "mock-workflow-confirm-token",
|
||||
expiresIn: 900,
|
||||
mustChangePassword: false,
|
||||
})),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/auth/logout") {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
headers: { "set-cookie": "has_session=; Path=/; Max-Age=0" },
|
||||
body: JSON.stringify(envelope({})),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/me") {
|
||||
await fulfillJson(route, mockMe);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/system/navigation") {
|
||||
await fulfillJson(route, {
|
||||
workspace: {
|
||||
id: "workspace-confirm",
|
||||
persisted: true,
|
||||
profile: "small_team_internal",
|
||||
orgMode: "single_company",
|
||||
primaryEntryMode: "password",
|
||||
notificationStrategy: "in_app",
|
||||
devicePriority: "desktop",
|
||||
moduleVisibility: {},
|
||||
createdAt: null,
|
||||
updatedAt: null,
|
||||
updatedBy: null,
|
||||
},
|
||||
sections: {
|
||||
main: [
|
||||
navigationItem("portal", "/portal", "Portal", "home_app_logo"),
|
||||
navigationItem("workflow", "/workflow/tasks", "审批待办", "fact_check"),
|
||||
],
|
||||
admin: [],
|
||||
backup: [],
|
||||
},
|
||||
recommendedRolePresets: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/notifications") {
|
||||
await fulfillJson(route, {
|
||||
page: 1,
|
||||
pageSize: Number(url.searchParams.get("pageSize") ?? 5),
|
||||
total: 0,
|
||||
unreadOnly: url.searchParams.get("unreadOnly") === "1",
|
||||
unreadCount: 0,
|
||||
items: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/portal/home") {
|
||||
await fulfillJson(route, {
|
||||
hero: { title: "工作台", subtitle: "审批动作确认测试" },
|
||||
metrics: [],
|
||||
todos: [],
|
||||
notifications: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/workflow/tasks/summary") {
|
||||
await fulfillJson(route, {
|
||||
scope: "mine",
|
||||
pendingTotal: actionCalls.approve > 0 ? 0 : 1,
|
||||
overdueTotal: 0,
|
||||
earliestPendingAt: pendingTask.createdAt,
|
||||
averagePendingAgeHours: 1,
|
||||
byEntityType: [],
|
||||
byStep: [],
|
||||
byAssigneeRole: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/workflow/tasks") {
|
||||
const status = url.searchParams.get("status") ?? "pending";
|
||||
const items = status === "pending" && actionCalls.approve === 0 ? [pendingTask] : [];
|
||||
await fulfillJson(route, {
|
||||
page: 1,
|
||||
pageSize: Number(url.searchParams.get("pageSize") ?? 20),
|
||||
total: items.length,
|
||||
items,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const actionMatch = path.match(/^\/api\/workflow\/tasks\/[^/]+\/(approve|reject|return)$/);
|
||||
if (actionMatch) {
|
||||
const action = actionMatch[1] as keyof typeof actionCalls;
|
||||
actionCalls[action] += 1;
|
||||
await fulfillJson(route, { ok: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (/^\/api\/workflow\/tasks\/[^/]+$/.test(path)) {
|
||||
await fulfillJson(route, pendingTaskDetail);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path === "/api/workflow/approvers") {
|
||||
await fulfillJson(route, { page: 1, pageSize: 100, total: 0, items: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
await fulfillJson(route, {});
|
||||
});
|
||||
|
||||
return actionCalls;
|
||||
}
|
||||
|
||||
test.describe("R7E 审批动作二次确认", () => {
|
||||
test("PC 列表快捷通过必须二次确认后才提交", async ({ page }) => {
|
||||
const actionCalls = await mockWorkflowConfirmApis(page);
|
||||
|
||||
await login(page, MANAGER);
|
||||
await page.goto("/workflow/tasks");
|
||||
await expect(page.getByTestId(TEST_IDS.workflow.tasksTable)).toBeVisible();
|
||||
|
||||
const taskRow = page.getByTestId(TEST_IDS.workflow.taskRow).filter({ hasText: "QJ-CONFIRM-001" });
|
||||
await expect(taskRow).toHaveCount(1);
|
||||
|
||||
await taskRow.getByTestId(TEST_IDS.workflow.quickApprove).click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
expect(actionCalls.approve).toBe(0);
|
||||
|
||||
await page.getByTestId("workflow-action-confirm-cancel").click();
|
||||
expect(actionCalls.approve).toBe(0);
|
||||
|
||||
await taskRow.getByTestId(TEST_IDS.workflow.quickApprove).click();
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect.poll(() => actionCalls.approve).toBe(1);
|
||||
});
|
||||
|
||||
test("PC 审批详情通过、驳回、退回都先解释动作后果", async ({ page }) => {
|
||||
const actionCalls = await mockWorkflowConfirmApis(page);
|
||||
|
||||
await login(page, MANAGER);
|
||||
await page.goto(`/workflow/tasks/${pendingTask.id}`);
|
||||
await expect(page.getByTestId("workflow-task-overview")).toBeVisible();
|
||||
|
||||
await page.getByTestId("workflow-task-approve").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await page.getByTestId("workflow-action-confirm-cancel").click();
|
||||
expect(actionCalls.approve).toBe(0);
|
||||
|
||||
await page.getByTestId("workflow-task-reject-comment").fill("资料不符合要求,请重新发起。");
|
||||
await page.getByTestId("workflow-task-reject").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("流程将终止");
|
||||
await page.getByTestId("workflow-action-confirm-cancel").click();
|
||||
expect(actionCalls.reject).toBe(0);
|
||||
|
||||
await page.getByTestId("workflow-task-return-comment").fill("请补充附件后重新提交。");
|
||||
await page.getByTestId("workflow-task-return").click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("回到申请人修改态");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect.poll(() => actionCalls.return).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -96,6 +96,8 @@ test("E2E 审批列表快捷通过:经理可在待办列表行内直接通过
|
||||
await expect(taskRow.getByTestId(TEST_IDS.workflow.detailLink)).toBeVisible();
|
||||
|
||||
await taskRow.getByTestId(TEST_IDS.workflow.quickApprove).click();
|
||||
await expect(page.getByTestId("workflow-action-confirm-dialog")).toContainText("确认后将进入下一审批节点");
|
||||
await page.getByTestId("workflow-action-confirm-submit").click();
|
||||
await expect(taskRows).toHaveCount(0, { timeout: 30_000 });
|
||||
|
||||
await logout(page, MANAGER.name);
|
||||
|
||||
在新工单中引用
屏蔽一个用户