fix(dialogs): F03 证据弹窗同期间重复点击不再停留在加载中
- 第 0 页重复点击当前已选期间直接返回,不清空列表、不重复请求; 第二页点击当前期间回到第一页并刷新 - 请求失败显示错误并提供“重试”按钮;空结果显示空态行而不是过期数据 - E2E 覆盖:重复点击、快速本期/基期切换、第二页切期间、失败重试、空列表
This commit is contained in:
+94
-23
@@ -30,7 +30,9 @@ test("桌面:真实导入、异常、下钻、证据、设置、Copilot、导
|
||||
});
|
||||
await uploaded;
|
||||
const dialog = page.getByRole("dialog");
|
||||
await expect(dialog.getByRole("heading", { name: "确认导入字段" })).toBeVisible();
|
||||
await expect(
|
||||
dialog.getByRole("heading", { name: "确认导入字段" }),
|
||||
).toBeVisible();
|
||||
await dialog.getByRole("button", { name: "确认并导入" }).click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "集团经营总览", exact: true }),
|
||||
@@ -85,14 +87,27 @@ test("桌面:真实导入、异常、下钻、证据、设置、Copilot、导
|
||||
await expect(evidenceDialog).toContainText("1 条");
|
||||
await expect(evidenceDialog).toContainText("2026-08");
|
||||
await expect(evidenceDialog).toContainText("CSV");
|
||||
await evidenceDialog.getByRole("button", { name: "基期", exact: true }).click();
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "基期", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("2025-08");
|
||||
await evidenceDialog.getByLabel("关闭", { exact: true }).click();
|
||||
const evidenceOffsets: number[] = [];
|
||||
let evidenceFailOnce = false;
|
||||
let evidenceEmpty = false;
|
||||
await page.route("**/api/datasets/*/evidence", async (route) => {
|
||||
const request = route.request().postDataJSON() as { offset?: number };
|
||||
const offset = request.offset || 0;
|
||||
if (evidenceFailOnce) {
|
||||
evidenceFailOnce = false;
|
||||
await route.fulfill({ status: 500, json: { error: "服务暂不可用" } });
|
||||
return;
|
||||
}
|
||||
evidenceOffsets.push(offset);
|
||||
if (evidenceEmpty) {
|
||||
await route.fulfill({ json: { total: 0, sheet: "CSV", rows: [] } });
|
||||
return;
|
||||
}
|
||||
const count = offset === 0 ? 50 : 1;
|
||||
await route.fulfill({
|
||||
json: {
|
||||
@@ -111,10 +126,51 @@ test("桌面:真实导入、异常、下钻、证据、设置、Copilot、导
|
||||
});
|
||||
await page.getByLabel("查看医生A证据", { exact: true }).click();
|
||||
await expect(evidenceDialog).toContainText("第 1-50 条,共 51 条");
|
||||
await evidenceDialog.getByRole("button", { name: "下一页", exact: true }).click();
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "下一页", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("第 51-51 条,共 51 条");
|
||||
await expect(evidenceDialog).toContainText("2026-09");
|
||||
expect(evidenceOffsets).toEqual([0, 50]);
|
||||
// F03 回归:第二页时重复点击当前期间应回到第一页并重新加载
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "本期", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("第 1-50 条,共 51 条");
|
||||
expect(evidenceOffsets).toEqual([0, 50, 0]);
|
||||
// F03 回归:第一页重复点击当前期间不清空列表、不重新请求、不停在“加载中”
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "本期", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("第 1-50 条,共 51 条");
|
||||
await expect(evidenceDialog).not.toContainText("加载中");
|
||||
expect(evidenceOffsets).toEqual([0, 50, 0]);
|
||||
// F03 回归:快速本期/基期切换最终停留在当前期间的数据
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "基期", exact: true })
|
||||
.click();
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "本期", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("第 1-50 条,共 51 条");
|
||||
await expect(evidenceDialog).not.toContainText("加载中");
|
||||
// F03 回归:请求失败显示错误并可重试恢复
|
||||
evidenceFailOnce = true;
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "下一页", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("服务暂不可用");
|
||||
await expect(evidenceDialog).toContainText("加载失败");
|
||||
await evidenceDialog.getByRole("button", { name: "重试" }).click();
|
||||
await expect(evidenceDialog).toContainText("第 51-51 条,共 51 条");
|
||||
// F03 回归:空结果显示空态而不是过期数据或加载中
|
||||
evidenceEmpty = true;
|
||||
await evidenceDialog
|
||||
.getByRole("button", { name: "上一页", exact: true })
|
||||
.click();
|
||||
await expect(evidenceDialog).toContainText("本期范围内没有数据");
|
||||
await expect(evidenceDialog).toContainText("共 0 条");
|
||||
await expect(evidenceDialog).not.toContainText("加载中");
|
||||
await evidenceDialog.getByLabel("关闭", { exact: true }).click();
|
||||
await page
|
||||
.getByRole("navigation", { name: "分析路径" })
|
||||
@@ -164,38 +220,53 @@ test("桌面:真实导入、异常、下钻、证据、设置、Copilot、导
|
||||
await page.route("**/formula-design", async (route) => {
|
||||
designCalls++;
|
||||
await route.fulfill({
|
||||
json: designCalls === 1
|
||||
? { complete: false, questions: ["缺失值和零分母如何处理?"], column: null }
|
||||
: {
|
||||
complete: true,
|
||||
questions: [],
|
||||
column: {
|
||||
name: "收入成本差",
|
||||
meaning: "实际收入减成本",
|
||||
scope: "所选分组与期间",
|
||||
missing: "结果不可用(#N/A);零分母不可用",
|
||||
expression: {
|
||||
operator: "subtract",
|
||||
left: { metric: "revenue" },
|
||||
right: { metric: "cost" },
|
||||
json:
|
||||
designCalls === 1
|
||||
? {
|
||||
complete: false,
|
||||
questions: ["缺失值和零分母如何处理?"],
|
||||
column: null,
|
||||
}
|
||||
: {
|
||||
complete: true,
|
||||
questions: [],
|
||||
column: {
|
||||
name: "收入成本差",
|
||||
meaning: "实际收入减成本",
|
||||
scope: "所选分组与期间",
|
||||
missing: "结果不可用(#N/A);零分母不可用",
|
||||
expression: {
|
||||
operator: "subtract",
|
||||
left: { metric: "revenue" },
|
||||
right: { metric: "cost" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
await page.getByRole("button", { name: "生成公式工作簿" }).click();
|
||||
const formulaDialog = page.getByRole("dialog", { name: "生成公式工作簿" });
|
||||
await formulaDialog.getByRole("checkbox").check();
|
||||
await formulaDialog.getByLabel("列计算描述").fill("新增收入成本差,缺失或零分母显示不可用");
|
||||
await formulaDialog
|
||||
.getByLabel("列计算描述")
|
||||
.fill("新增收入成本差,缺失或零分母显示不可用");
|
||||
await formulaDialog.getByRole("button", { name: "发送描述" }).click();
|
||||
await expect(formulaDialog).toContainText("缺失值和零分母如何处理?");
|
||||
await formulaDialog.getByLabel("列计算描述").fill("缺失项和零分母都按不可用处理");
|
||||
await formulaDialog
|
||||
.getByLabel("列计算描述")
|
||||
.fill("缺失项和零分母都按不可用处理");
|
||||
await formulaDialog.getByRole("button", { name: "发送描述" }).click();
|
||||
await formulaDialog.getByRole("button", { name: "确认并生成公式工作簿" }).click();
|
||||
await expect(formulaDialog.getByRole("status")).toContainText("生成完成", { timeout: 30000 });
|
||||
await formulaDialog
|
||||
.getByRole("button", { name: "确认并生成公式工作簿" })
|
||||
.click();
|
||||
await expect(formulaDialog.getByRole("status")).toContainText("生成完成", {
|
||||
timeout: 30000,
|
||||
});
|
||||
const formulaDownload = page.waitForEvent("download");
|
||||
await formulaDialog.getByRole("button", { name: "下载公式工作簿" }).click();
|
||||
expect((await formulaDownload).suggestedFilename()).toBe("traceiq-formula-analysis.xlsx");
|
||||
expect((await formulaDownload).suggestedFilename()).toBe(
|
||||
"traceiq-formula-analysis.xlsx",
|
||||
);
|
||||
await formulaDialog.getByLabel("关闭").click();
|
||||
});
|
||||
test("手机:登录、总览、设置、Copilot 布局无横向溢出", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user