Files
workinf_Blender_Wasm/web/tests/e2e/dirty-state.spec.ts
mes123456 7c16b279ae
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Advance M7 workflows and release operations
2026-08-15 17:43:53 -04:00

70 lines
3.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import path from "node:path";
const attributeBlend = path.resolve(import.meta.dirname, "../../../tests/files/web/attribute_scene.blend");
test("M7-06 changes dirty only for accepted Main transactions and matching saves", async ({ page }) => {
await page.goto("/");
await page.getByTestId("blend-file-input").setInputFiles(attributeBlend);
await expect(page.getByText("AttributeMeshObject", { exact: true })).toBeVisible();
const app = page.locator(".blender-app");
await expect(app).toHaveAttribute("data-dirty", "false");
const openedRevision = await app.getAttribute("data-current-main-revision");
await expect(app).toHaveAttribute("data-committed-main-revision", openedRevision ?? "");
await page.getByRole("button", { name: "Modeling" }).click();
await expect(app).toHaveAttribute("data-dirty", "false");
await expect(app).toHaveAttribute("data-current-main-revision", openedRevision ?? "");
await page.getByRole("button", { name: "预览 Decimate" }).click();
await expect(page.getByTestId("engine-status")).toContainText("Preview");
await expect(app).toHaveAttribute("data-dirty", "false");
await expect(app).toHaveAttribute("data-current-main-revision", openedRevision ?? "");
await page.locator("label.file-button input[type=file]").setInputFiles({
name: "invalid.png",
mimeType: "image/png",
buffer: Buffer.from("not-a-png"),
});
await expect(app).toHaveAttribute("data-user-action-import-status", "FAILED");
await expect(app).toHaveAttribute("data-dirty", "false");
await expect(app).toHaveAttribute("data-current-main-revision", openedRevision ?? "");
await page.getByRole("button", { name: "添加立方体" }).click();
await expect(app).toHaveAttribute("data-dirty", "true");
await expect(page.getByTestId("dirty-status")).toHaveText("未保存");
const editedRevision = Number(await app.getAttribute("data-current-main-revision"));
expect(editedRevision).toBeGreaterThan(Number(openedRevision));
await expect(app).toHaveAttribute("data-committed-main-revision", openedRevision ?? "");
const download = page.waitForEvent("download");
await page.getByRole("button", { name: "保存项目" }).click();
await download;
await expect(app).toHaveAttribute("data-dirty", "false");
await expect(page.getByTestId("dirty-status")).toHaveText("已保存");
await expect(app).toHaveAttribute("data-committed-main-revision", String(editedRevision));
await page.getByRole("button", { name: "添加立方体" }).click();
await expect(app).toHaveAttribute("data-dirty", "true");
await page.getByRole("button", { name: "撤销" }).click();
await expect(app).toHaveAttribute("data-dirty", "false");
const undoRevision = Number(await app.getAttribute("data-current-main-revision"));
expect(undoRevision).toBeGreaterThan(editedRevision);
await page.getByRole("button", { name: "重做" }).click();
await expect(app).toHaveAttribute("data-dirty", "true");
const redoRevision = Number(await app.getAttribute("data-current-main-revision"));
expect(redoRevision).toBeGreaterThan(undoRevision);
await page.getByRole("button", { name: "撤销" }).click();
await expect(app).toHaveAttribute("data-dirty", "false");
await page.getByTestId("blend-file-input").setInputFiles({
name: "invalid.blend",
mimeType: "application/octet-stream",
buffer: Buffer.from([0x42, 0x41, 0x44]),
});
await expect(app).toHaveAttribute("data-user-action-open-status", "FAILED");
await expect(app).toHaveAttribute("data-dirty", "false");
const finalUndoRevision = await app.getAttribute("data-current-main-revision");
await expect(app).toHaveAttribute("data-committed-main-revision", finalUndoRevision ?? "");
});