Advance M7 workflows and release operations
This commit is contained in:
69
web/tests/e2e/dirty-state.spec.ts
Normal file
69
web/tests/e2e/dirty-state.spec.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
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 ?? "");
|
||||
});
|
||||
Reference in New Issue
Block a user