Files
workinf_Blender_Wasm/web/tests/e2e/zz-debug-mode.spec.ts
mes123456 d1e6b63d54
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
chore: checkpoint web Blender feature-gap work, docs and tests
- update native web_engine sources and rebuilt wasm artifacts
- add task cards, status notes and tooling scripts
- add web e2e specs, tutorial UI sources and tutorial assets
- sync golden task manifests and audit records

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-11 10:46:55 +08:00

33 lines
2.0 KiB
TypeScript

import { test, expect } from "@playwright/test";
import path from "node:path";
import { observeNative, exposeWebTools } from "../fixtures/native-ui-workflow";
const root = path.resolve(import.meta.dirname, "../../..");
function send(page: import("@playwright/test").Page, command: unknown) {
return page.evaluate((command) => new Promise((resolve) => {
const worker = (window as unknown as { __nativeWorkflowEngine: Worker }).__nativeWorkflowEngine;
const requestId = "debug-mode-" + crypto.randomUUID();
const timer = setTimeout(() => resolve({ timeout: true }), 60_000);
worker.addEventListener("message", function receive({ data }: MessageEvent) {
if (data.requestId !== requestId) return;
worker.removeEventListener("message", receive);
clearTimeout(timer);
resolve({ ok: data.ok, error: data.error, json: data.result?.json ?? data.json, snapshot: data.snapshot ? { editorWorkflowStatus: data.snapshot.editorWorkflowStatus, mode: data.snapshot.editorWorkflow?.context?.mode, activeObjectId: data.snapshot.activeObjectId } : undefined });
});
worker.postMessage({ requestId, command });
}), command);
}
test("debug web-only mode switch", async ({ page }) => {
await observeNative(page);
await page.goto("/");
await page.getByTestId("blend-file-input").setInputFiles(path.join(root, "tests/files/web/basic_scene.blend"));
await expect(page.getByTestId("engine-status")).toContainText(/SceneIR r\d+/, { timeout: 60_000 });
await exposeWebTools(page);
const before = await send(page, { type: "snapshot" });
const payload = JSON.stringify({ operator: "object.mode_set", native: true, properties: { mode: "EDIT", toggle: false }, areaType: "VIEW_3D", mode: "OBJECT" });
const source = `import json, web_blender\nweb_blender.desktop_operator(json.loads(${JSON.stringify(payload)}))`;
const result = await send(page, { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "DebugMode.py", console: false } });
console.log("MODE_DEBUG " + JSON.stringify({ before, result }).slice(0, 3000));
});