42 lines
2.4 KiB
TypeScript
42 lines
2.4 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import path from "node:path";
|
|
|
|
const basicBlend = path.resolve(import.meta.dirname, "../../../tests/files/web/basic_scene.blend");
|
|
|
|
for (const source of ["engine", "storage"] as const) {
|
|
test("M7-08 " + source + " Worker crash keeps the project visible and restores the operation log", async ({ page }) => {
|
|
await page.goto("/?worker-fault=" + source);
|
|
await expect(page.getByTestId("engine-status")).toContainText("ready, open a .blend file", { timeout: 20_000 });
|
|
const app = page.locator(".blender-app");
|
|
await page.getByTestId("blend-file-input").setInputFiles(basicBlend);
|
|
await expect(page.getByText("Cube", { exact: true })).toBeVisible();
|
|
|
|
const initialDownload = page.waitForEvent("download");
|
|
await page.getByRole("button", { name: "保存项目" }).click();
|
|
await initialDownload;
|
|
await expect(app).toHaveAttribute("data-dirty", "false");
|
|
const committedRevision = await app.getAttribute("data-committed-main-revision");
|
|
|
|
await page.getByRole("button", { name: "添加立方体" }).click();
|
|
await expect(app).toHaveAttribute("data-dirty", "true");
|
|
const editedRevision = await app.getAttribute("data-current-main-revision");
|
|
const editedStats = await page.getByTestId("scene-stats").textContent();
|
|
await page.waitForTimeout(250);
|
|
|
|
await page.getByTestId("inject-worker-crash").click();
|
|
await expect(app).toHaveAttribute("data-worker-fault-source", source);
|
|
await expect(app).toHaveAttribute("data-worker-fault-code", "WORKER_TERMINATED");
|
|
await expect(page.getByTestId("worker-fault-banner")).toContainText("current project list and scene are retained");
|
|
await expect(app).toHaveAttribute("data-project-snapshot-revision", editedRevision ?? "");
|
|
await expect(page.getByTestId("scene-stats")).toHaveText(editedStats ?? "");
|
|
|
|
await page.getByTestId("restart-and-recover").click();
|
|
await expect(app).toHaveAttribute("data-worker-recovery-status", "SUCCEEDED", { timeout: 30_000 });
|
|
await expect(page.getByTestId("worker-fault-banner")).toHaveCount(0);
|
|
await expect(app).toHaveAttribute("data-committed-main-revision", committedRevision ?? "");
|
|
await expect(app).toHaveAttribute("data-dirty", "true");
|
|
await expect(page.getByTestId("scene-stats")).toHaveText(editedStats ?? "");
|
|
await expect(page.getByTestId("engine-status")).toContainText("project restored");
|
|
});
|
|
}
|