Outliner: react-accessible-treeview's controlled expandedIds sync expands a node together with its parent, then the next pass treats that extra parent id as removed from the controlled set and collapses the whole branch. Reproduced as a collapsed tree after ch11 -> ch12 (scene rows complete in React, one collapsed row in the DOM). Keep OUTLINER_ROOT_ID in the controlled set so both passes agree, and drop the rows-digest memo that regressed the normal path. Also arm a bounded post-open OUTLINER_REFRESH loop so the tree settles on rows of the newly opened Main instead of the previous one. Tests: web/playwright.deployed.config.ts + web/tests/deployed walk the 31 manual chapters and the 31 capability rows headed against a deployed origin, and tools/web/run-deployed-functional-tests.mjs preflights, runs and reports. --local serves the production bundle from web/dist on loopback with the same COOP/COEP/CORP/CSP headers, so a case costs compile time instead of a 300 MB download: full local suite 60/60 in 10.3 min, also 60/60 against the deployed release. Report dirs are resolved absolute and [ch28a]-style tags map to their chapter. Area layout: split from the clamped source rect and keep the area switcher inside a narrow header. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
104 lines
5.1 KiB
TypeScript
104 lines
5.1 KiB
TypeScript
import { expect, test, type Page } from "./support/deployed-test";
|
||
import { FIXTURES, gotoApp, openProject, receipt, shot, waitForObjects } from "./support/deployed";
|
||
|
||
/**
|
||
* Manual part F (ch29–ch31): the scripting editors, preferences and keymap,
|
||
* and the troubleshooting entry points.
|
||
*/
|
||
test.use({ viewport: { width: 1600, height: 900 } });
|
||
|
||
async function menu(page: Page, ...items: string[]): Promise<void> {
|
||
await page.getByRole("button", { name: items[0], exact: true }).click();
|
||
for (const name of items.slice(1)) await page.getByRole("menuitem", { name, exact: true }).click();
|
||
}
|
||
|
||
async function switchWorkspace(page: Page, name: string): Promise<void> {
|
||
await page.locator('nav[aria-label="工作区"] button', { hasText: new RegExp(`^${name}$`) }).click();
|
||
await expect(page.locator("main.blender-app")).toHaveAttribute("data-workspace", name, { timeout: 15_000 });
|
||
}
|
||
|
||
test("[ch29] Scripting 工作区提供文本编辑器与 Python 控制台", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
await switchWorkspace(page, "Scripting");
|
||
|
||
const textEditor = page.locator(".area-frame.text-editor-area, .text-editor-area").first();
|
||
const console_ = page.locator(".area-frame.console-area, .console-area").first();
|
||
await expect(textEditor).toBeVisible({ timeout: 20_000 });
|
||
await expect(console_).toBeVisible({ timeout: 20_000 });
|
||
const infoLine = await page.getByTestId("info-engine-line").innerText().catch(() => "");
|
||
expect(infoLine || (await textEditor.innerText()).length, "scripting surfaces render content").toBeTruthy();
|
||
|
||
const image = await shot(page, testInfo, "scripting");
|
||
receipt(testInfo, {
|
||
workflow: "Scripting workspace -> Text Editor + Python Console + Info",
|
||
infoLine: infoLine.trim().slice(0, 120), screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch30] @smoke 偏好设置计数与保存落盘到 OPFS", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
await menu(page, "编辑", "偏好设置");
|
||
const window = page.getByTestId("preferences-window");
|
||
await expect(window).toBeVisible({ timeout: 15_000 });
|
||
const navCount = await page.getByRole("dialog", { name: "Web Blender 偏好设置" }).locator("nav button").count();
|
||
expect(navCount, "preferences has all nine sections").toBe(9);
|
||
|
||
const statusToggle = page.getByLabel("显示状态栏", { exact: true });
|
||
const wasChecked = await statusToggle.isChecked();
|
||
if (wasChecked) await statusToggle.uncheck(); else await statusToggle.check();
|
||
await page.getByRole("button", { name: "保存偏好", exact: true }).click();
|
||
await expect(window.locator("header output")).toContainText("已保存到 OPFS", { timeout: 15_000 });
|
||
|
||
/* Restore the previous value so later runs see a stable default. */
|
||
if (wasChecked) await statusToggle.check(); else await statusToggle.uncheck();
|
||
await page.getByRole("button", { name: "保存偏好", exact: true }).click();
|
||
await expect(window.locator("header output")).toContainText("已保存到 OPFS", { timeout: 15_000 });
|
||
|
||
const stored = await page.evaluate(async () => {
|
||
const root = await navigator.storage.getDirectory();
|
||
const settings = await root.getDirectoryHandle("settings");
|
||
const file = await (await settings.getFileHandle("web-interface.json")).getFile();
|
||
return JSON.parse(await file.text()) as { preferences?: unknown };
|
||
});
|
||
expect(stored.preferences, "preferences are written to OPFS settings/web-interface.json").toBeTruthy();
|
||
|
||
const image = await shot(page, testInfo, "preferences-saved");
|
||
receipt(testInfo, {
|
||
workflow: "编辑 → 偏好设置 -> toggle 显示状态栏 -> 保存偏好 -> OPFS settings/web-interface.json",
|
||
navCount, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch31] 诊断报告可从顶栏导出", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
/* A healthy session records no diagnostics and the export entry stays
|
||
* disabled; that is the documented behaviour, so the case asserts the state
|
||
* and downloads only when diagnostics exist. */
|
||
const button = page.getByLabel("导出诊断报告");
|
||
await expect(button).toBeVisible({ timeout: 15_000 });
|
||
const enabled = await button.isEnabled();
|
||
let downloadName: string | null = null;
|
||
if (enabled) {
|
||
const downloadPromise = page.waitForEvent("download", { timeout: 20_000 });
|
||
await button.click();
|
||
const download = await downloadPromise;
|
||
expect(download.suggestedFilename()).toMatch(/diagnostics.*\.json$|\.json$/i);
|
||
downloadName = download.suggestedFilename();
|
||
}
|
||
|
||
const image = await shot(page, testInfo, "diagnostics");
|
||
receipt(testInfo, {
|
||
workflow: "top bar 导出诊断报告",
|
||
diagnosticsExport: enabled ? downloadName : "disabled (no diagnostics recorded in this session)",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|