24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
const root = path.resolve(import.meta.dirname, "../../..");
|
|
const fixture = Array.from(fs.readFileSync(path.join(root, "tests/files/web/script_scene.blend")));
|
|
|
|
test("M13-01B opens a blend and reads script metadata without execution", async ({ page }) => {
|
|
await page.goto("/");
|
|
const result = await page.evaluate(async (bytes) => {
|
|
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
|
const client = new WebEngineClient({ timeoutMs: 30_000 });
|
|
const opened = await client.openBlend(Uint8Array.from(bytes).buffer);
|
|
const sources = opened.snapshot.scriptSources;
|
|
client.terminate();
|
|
return { status: opened.snapshot.scriptSourceStatus, sources };
|
|
}, fixture);
|
|
expect(result.status).toBe("AVAILABLE");
|
|
expect(result.sources?.schemaVersion).toBe(1);
|
|
expect(result.sources?.sources).toHaveLength(3);
|
|
expect(result.sources?.sources.every((source: any) => source.readOnly && source.executionStatus === "BLOCKED" && /^[a-f0-9]{64}$/.test(source.sourceSha256))).toBe(true);
|
|
expect(result.sources?.sources.find((source: any) => source.name === "ModuleAutorun.py")).toMatchObject({ moduleAutorunRequested: true, errorCode: "SCRIPT_POLICY_DENIED" });
|
|
});
|