- 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>
33 lines
2.0 KiB
TypeScript
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));
|
|
});
|