Files
workinf_Blender_Wasm/web/tests/e2e/storage-budget.spec.ts
mes123456 0fe8d2bb56
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Advance M8-M11 parity workflows
2026-08-17 04:37:07 -04:00

43 lines
2.3 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("M7-11 reports project, snapshot, LOD, media and VDB byte categories", async ({ page }) => {
await page.goto("/");
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 download = page.waitForEvent("download");
await page.getByRole("button", { name: "保存项目" }).click();
await download;
await expect(app).toHaveAttribute("data-project-id", "basic_scene");
const budget = await page.evaluate(async () => {
const { StorageClient } = await import("/src/storage/StorageClient.ts");
const storage = new StorageClient();
await storage.putAsset("basic_scene", new Uint8Array(7).buffer, "image/png", "media/test.png");
await storage.putAsset("basic_scene", new Uint8Array(17).buffer, "application/x-blender-simulation-cache", "cache/simulation.bin");
await storage.saveLOD("basic_scene", "budget-lod", new Uint8Array(13).buffer);
const result = await storage.getBudget("basic_scene");
storage.terminate();
return result;
});
expect(budget.projectBytes).toBeGreaterThan(0);
expect(budget.snapshotBytes).toBeGreaterThan(0);
expect(budget.lodBytes).toBe(13);
expect(budget.mediaBytes).toBe(7);
expect(budget.vdbBytes).toBe(17);
expect(budget.totalBytes).toBe(budget.projectBytes + budget.snapshotBytes + 13 + 7 + 17);
await page.reload();
await expect(page.getByTestId("engine-status")).toContainText("ready, open a .blend file", { timeout: 20_000 });
const panel = page.getByTestId("storage-budget-panel");
await expect(panel).toHaveAttribute("data-project-id", "basic_scene");
await expect(panel.locator('[data-category="LOD"]')).toHaveAttribute("data-bytes", "13");
await expect(panel.locator('[data-category="媒体"]')).toHaveAttribute("data-bytes", "7");
await expect(panel.locator('[data-category="VDB"]')).toHaveAttribute("data-bytes", "17");
await expect(panel).toHaveAttribute("data-total-bytes", String(budget.totalBytes));
});