refactor(workbench): simplify appointment tasks
This commit is contained in:
@@ -109,7 +109,7 @@ test.describe("外围工单测试", () => {
|
||||
await expect(workOrderList).toContainText("待处理");
|
||||
await expect(workOrderList).toContainText("处理中");
|
||||
await expect(workOrderList).toContainText("已完成");
|
||||
await expect(workOrderList.getByText("未提供过程", { exact: true })).toHaveCount(3);
|
||||
await expect(workOrderList.getByText("暂无活动记录;不根据工单状态推测处置过程。", { exact: true })).toHaveCount(3);
|
||||
expect(requestedPaths).toEqual(expect.arrayContaining([
|
||||
"/api/sample/v1/context",
|
||||
"/api/sample/v1/work-orders"
|
||||
@@ -254,19 +254,18 @@ test.describe("外围工单测试", () => {
|
||||
if (path.endsWith("/work-orders") && request.method() === "POST") {
|
||||
const body = request.postDataJSON();
|
||||
writes.push(body);
|
||||
const item = { ...body, work_order_id: "50000000-0000-4000-8000-000000000001", project_id: projectId, revision: 1, origin: "synthetic", created_at: now, updated_at: now, created_by: "tester", updated_by: "tester" };
|
||||
const item = { ...body, work_order_id: "50000000-0000-4000-8000-000000000001", project_id: projectId, revision: 1, origin: "synthetic", created_at: now, updated_at: now, created_by: "tester", updated_by: "tester", activity: [{ sequence: 1, occurred_at: now, actor: "tester", kind: "created", title: "工单创建", detail: "预约工单已创建。" }] };
|
||||
delete item.request_id; workOrders = [item]; return route.fulfill({ status: 201, json: item });
|
||||
}
|
||||
if (path.includes("/work-orders/") && request.method() === "PATCH") {
|
||||
const body = request.postDataJSON();
|
||||
writes.push(body);
|
||||
const next = { ...workOrders[0], ...body, revision: 2, updated_at: "2026-09-18T01:00:00Z" };
|
||||
const next = { ...workOrders[0], ...body, revision: 2, updated_at: "2026-09-18T01:00:00Z", activity: [...workOrders[0].activity, { sequence: 2, occurred_at: "2026-09-18T01:00:00Z", actor: "tester", kind: "feedback", title: "现场反馈", detail: body.progress_note }] };
|
||||
if (body.clear_assignee) next.assignee = null;
|
||||
if (body.clear_location) next.location = null;
|
||||
if (body.clear_scenario_code) next.scenario_code = null;
|
||||
if (body.clear_scheduled_at) next.scheduled_at = null;
|
||||
if (body.clear_subtasks) next.subtasks = null;
|
||||
for (const key of ["request_id", "expected_revision", "clear_assignee", "clear_location", "clear_scenario_code", "clear_scheduled_at", "clear_subtasks"]) delete next[key];
|
||||
for (const key of ["request_id", "expected_revision", "clear_assignee", "clear_location", "clear_scenario_code", "clear_scheduled_at", "progress_note"]) delete next[key];
|
||||
workOrders = [next];
|
||||
return route.fulfill({ json: workOrders[0] });
|
||||
}
|
||||
@@ -287,9 +286,7 @@ test.describe("外围工单测试", () => {
|
||||
await editor.getByRole("textbox", { name: "负责人", exact: true }).fill("测试班组甲");
|
||||
await editor.getByRole("textbox", { name: "位置", exact: true }).fill("联调测试点西侧");
|
||||
await editor.getByRole("textbox", { name: "场景编号" }).fill("APPOINTMENT-TEST-001");
|
||||
await editor.getByRole("textbox", { name: "责任班组" }).fill("测试班组甲");
|
||||
await editor.getByRole("textbox", { name: "处置位置" }).fill("联调测试点西侧");
|
||||
await editor.getByRole("textbox", { name: "阶段说明", exact: true }).first().fill("确认班组甲和西侧作业窗口。");
|
||||
await editor.getByRole("textbox", { name: "回执要求(每行一项)" }).fill("回传现场处理结果\n上传照片");
|
||||
await editor.getByRole("button", { name: "创建预约工单" }).click();
|
||||
await expect(panel.getByText("合成预约维修", { exact: true })).toBeVisible();
|
||||
expect(writes[0]).toMatchObject({
|
||||
@@ -297,11 +294,7 @@ test.describe("外围工单测试", () => {
|
||||
assignee: "测试班组甲",
|
||||
location: "联调测试点西侧",
|
||||
scenario_code: "APPOINTMENT-TEST-001",
|
||||
subtasks: expect.arrayContaining([expect.objectContaining({
|
||||
assignee: "测试班组甲",
|
||||
location: "联调测试点西侧",
|
||||
stages: expect.arrayContaining([expect.objectContaining({ description: "确认班组甲和西侧作业窗口。" })])
|
||||
})])
|
||||
feedback_requirements: ["回传现场处理结果", "上传照片"]
|
||||
});
|
||||
|
||||
await panel.getByRole("button", { name: "编辑工单 合成预约维修" }).click();
|
||||
@@ -309,12 +302,10 @@ test.describe("外围工单测试", () => {
|
||||
await editor.getByRole("textbox", { name: "标题" }).fill("合成预约维修(已对齐)");
|
||||
await editor.getByRole("textbox", { name: "负责人", exact: true }).fill("测试班组乙");
|
||||
await editor.getByRole("textbox", { name: "位置", exact: true }).fill("联调测试点东侧");
|
||||
await editor.getByRole("textbox", { name: "责任班组" }).fill("测试班组乙");
|
||||
await editor.getByRole("textbox", { name: "处置位置" }).fill("联调测试点东侧");
|
||||
await editor.getByRole("textbox", { name: "阶段说明", exact: true }).first().fill("确认班组乙和东侧作业窗口,等待真实反馈。");
|
||||
await editor.getByRole("textbox", { name: "现场反馈(可选)" }).fill("班组乙已确认东侧作业窗口,等待复核。");
|
||||
await editor.getByRole("combobox", { name: "工单状态" }).click();
|
||||
await page.getByRole("option", { name: "待复令", exact: true }).click();
|
||||
await editor.getByRole("button", { name: "保存工单与过程" }).click();
|
||||
await editor.getByRole("button", { name: "保存工单" }).click();
|
||||
await expect(panel.getByText("合成预约维修(已对齐)", { exact: true })).toBeVisible();
|
||||
expect(writes[1]).toMatchObject({
|
||||
status: "awaiting_reply",
|
||||
@@ -322,12 +313,8 @@ test.describe("外围工单测试", () => {
|
||||
location: "联调测试点东侧",
|
||||
clear_assignee: false,
|
||||
clear_location: false,
|
||||
clear_subtasks: false,
|
||||
subtasks: expect.arrayContaining([expect.objectContaining({
|
||||
assignee: "测试班组乙",
|
||||
location: "联调测试点东侧",
|
||||
stages: expect.arrayContaining([expect.objectContaining({ description: "确认班组乙和东侧作业窗口,等待真实反馈。" })])
|
||||
})])
|
||||
progress_note: "班组乙已确认东侧作业窗口,等待复核。",
|
||||
feedback_requirements: ["回传现场处理结果", "上传照片"]
|
||||
});
|
||||
expect(workOrders[0]).toMatchObject({ work_order_type: "general", scenario_code: "APPOINTMENT-TEST-001" });
|
||||
|
||||
@@ -337,8 +324,8 @@ test.describe("外围工单测试", () => {
|
||||
await panel.getByRole("button", { name: "编辑工单 外部系统更新后的预约维修" }).click();
|
||||
const refreshedEditor = panel.getByRole("region", { name: "编辑工单 外部系统更新后的预约维修" });
|
||||
await expect(refreshedEditor.getByRole("textbox", { name: "负责人", exact: true })).toHaveValue("测试班组乙");
|
||||
await expect(refreshedEditor.getByRole("textbox", { name: "处置位置" })).toHaveValue("联调测试点东侧");
|
||||
await expect(refreshedEditor.getByRole("textbox", { name: "阶段说明", exact: true }).first()).toHaveValue("确认班组乙和东侧作业窗口,等待真实反馈。");
|
||||
await expect(refreshedEditor.getByRole("textbox", { name: "位置", exact: true })).toHaveValue("联调测试点东侧");
|
||||
await expect(refreshedEditor.getByRole("textbox", { name: "回执要求(每行一项)" })).toHaveValue("回传现场处理结果\n上传照片");
|
||||
|
||||
for (const width of [1280, 375, 320]) {
|
||||
await page.setViewportSize({ width, height: 780 });
|
||||
@@ -730,7 +717,8 @@ function createSourceWorkOrders(projectId: string) {
|
||||
work_order_type: "general",
|
||||
location: null,
|
||||
scenario_code: null,
|
||||
subtasks: null,
|
||||
feedback_requirements: [],
|
||||
activity: [],
|
||||
origin: "synthetic",
|
||||
created_at: "2026-09-17T00:00:00Z",
|
||||
updated_at: "2026-09-17T00:00:00Z",
|
||||
|
||||
Reference in New Issue
Block a user