43 lines
2.3 KiB
TypeScript
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));
|
|
});
|