feat: 完善编辑工作台保存与离开体验

This commit is contained in:
que01 committed 2026-10-10 11:22:49 +08:00
1 parent 860d9266fe
commit fa6b492bce
7 files changed
+168 -15

No files matched your search

@@ -245,6 +245,7 @@ const templateContent = {
};
test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ page }) => {
let rejectOfferingSave = false;
await page.setViewportSize({ width: 1920, height: 1000 });
await page.route("http://localhost:3001/public/workspace**", (route) =>
route.fulfill({ json: runtimeWorkspace }),
@@ -291,6 +292,15 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa
url.pathname === `/admin/workspace/offerings/${adminOffering.id}` &&
request.method() === "PATCH"
) {
if (rejectOfferingSave) {
rejectOfferingSave = false;
return route.fulfill({
status: 500,
json: {
error: { message: "保存暂时失败,请重试", code: "TEST_FAILURE", requestId: "fixture" },
},
});
}
Object.assign(adminOffering, request.postDataJSON());
Object.assign(runtimeWorkspace.offerings[0], {
name: adminOffering.name,
@@ -430,7 +440,16 @@ test("Admin 按通用预览目标筛选字段并同步品牌草稿", async ({ pa
adminOffering.id,
);
await page.getByLabel("餐品名称").fill("编辑后的家庭餐");
await expect(page.getByText("有未保存修改", { exact: true })).toBeVisible();
await page.getByText("出摊服务", { exact: true }).click();
await expect(page.getByRole("dialog", { name: "有尚未保存的修改" })).toBeVisible();
await page.getByRole("button", { name: "继续编辑" }).click();
await expect(page.getByLabel("餐品名称")).toHaveValue("编辑后的家庭餐");
await expect(preview.locator(".offering-card")).toContainText("编辑后的家庭餐");
rejectOfferingSave = true;
await page.getByRole("button", { name: "保存此项内容" }).click();
await expect(page.getByText("保存暂时失败,请重试", { exact: true })).toBeVisible();
await expect(page.getByLabel("餐品名称")).toHaveValue("编辑后的家庭餐");
await page.getByRole("button", { name: "保存此项内容" }).click();
await expect.poll(() => adminOffering.name).toBe("编辑后的家庭餐");
await page.reload();