Files
workinf_Blender_Wasm/web/tests/e2e/network-interruption.spec.ts
2026-08-14 18:08:29 -04:00

30 lines
1.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");
test("keeps Main edit and save-reopen available during a Chromium network interruption", async ({ context, page }) => {
await page.goto("/");
await expect(page.getByTestId("engine-status")).toContainText("Engine: ready", { timeout: 20_000 });
await page.setInputFiles("[data-testid=blend-file-input]", basicBlend);
await expect(page.getByTestId("scene-stats")).toContainText("Objects 3");
await context.setOffline(true);
try {
await page.getByRole("button", { name: "添加立方体" }).click();
await expect(page.getByTestId("engine-status")).toContainText("SceneIR r2 (4 objects)");
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "保存项目" }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe("blender-web.blend");
const savedPath = await download.path();
expect(savedPath).not.toBeNull();
await page.setInputFiles("[data-testid=blend-file-input]", savedPath!);
await expect(page.getByTestId("engine-status")).toContainText("SceneIR r3 (4 objects)");
await expect(page.getByTestId("scene-stats")).toContainText("Objects 4");
}
finally {
await context.setOffline(false);
}
});