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>
150 lines
7.5 KiB
TypeScript
150 lines
7.5 KiB
TypeScript
import { expect, test } from "./support/deployed-test";
|
||
import { FIXTURES, gotoApp, openProject, opfsProjectIds, receipt, shot, waitEngineBoot, waitForObjects } from "./support/deployed";
|
||
|
||
/**
|
||
* Manual part A (ch01–ch05): first load, opening a project, saving to OPFS,
|
||
* recent projects and recovery. Every assertion is a user-visible end state —
|
||
* object count, status bar text, OPFS contents — never "the button was clicked".
|
||
*/
|
||
test.use({ viewport: { width: 1600, height: 900 } });
|
||
|
||
test("[ch01] @smoke 打开练习工程、编辑后保存到 OPFS", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
const engineStatus = await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
/* A visible edit first, so the save has something to persist. */
|
||
await page.getByRole("button", { name: "添加立方体", exact: true }).click();
|
||
await waitForObjects(page, 7);
|
||
await page.getByLabel("保存项目").click();
|
||
await expect(page.getByTestId("dirty-status")).toHaveText("已保存", { timeout: 20_000 });
|
||
|
||
const projects = await opfsProjectIds(page);
|
||
expect(projects.length, "the project must be written to OPFS").toBeGreaterThan(0);
|
||
const image = await shot(page, testInfo, "saved");
|
||
receipt(testInfo, {
|
||
workflow: "open studio.blend -> add cube (6->7 objects) -> 保存项目 -> 已保存 -> OPFS projects",
|
||
engineStatus, projects, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch02] 工作区标签齐全且状态栏反映引擎状态", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await waitEngineBoot(page);
|
||
|
||
const expected = ["Layout", "Modeling", "Sculpting", "UV Editing", "Texture Paint", "Shading",
|
||
"Animation", "Rendering", "Compositing", "Geometry Nodes", "Scripting"];
|
||
const tabs = page.locator('nav[aria-label="工作区"] button');
|
||
const labels = (await tabs.allInnerTexts()).map((text) => text.trim());
|
||
for (const name of expected) expect(labels, `workspace tab ${name}`).toContain(name);
|
||
|
||
/* This chapter is about the shell, not a project: the engine is expected to
|
||
* sit on the built-in General template here, so SceneIR is not required. */
|
||
await expect(page.getByTestId("engine-status")).not.toContainText(/starting/i);
|
||
const engineStatus = (await page.getByTestId("engine-status").innerText()).trim();
|
||
expect(engineStatus, "status bar reports an engine state").toMatch(/Engine|SceneIR/i);
|
||
const statusBar = (await page.locator(".status-bar").innerText()).replace(/\s+/g, " ").trim();
|
||
expect(statusBar).toMatch(/Engine|SceneIR|objects/i);
|
||
|
||
const image = await shot(page, testInfo, "workspaces");
|
||
receipt(testInfo, {
|
||
workflow: "11 workspace tabs present; status bar reports engine",
|
||
labels, engineStatus, statusBar, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch03] 新建工程与最近项目可重开", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await waitEngineBoot(page);
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
await page.getByLabel("保存项目").click();
|
||
await expect(page.getByTestId("dirty-status")).toHaveText("已保存", { timeout: 20_000 });
|
||
|
||
/* 文件 → 新建 → 常规 opens a confirmation dialog; the project is replaced
|
||
* only after 新建常规工程 is pressed. */
|
||
await page.getByRole("button", { name: "文件", exact: true }).click();
|
||
await page.getByRole("menuitem", { name: "新建", exact: true }).click({ timeout: 15_000 });
|
||
await page.getByRole("menuitem", { name: "常规", exact: true }).click({ timeout: 15_000 });
|
||
const newDialog = page.getByRole("dialog", { name: "新建工程" });
|
||
await expect(newDialog).toBeVisible({ timeout: 15_000 });
|
||
await newDialog.getByRole("button", { name: "新建常规工程", exact: true }).click();
|
||
await waitForObjects(page, 3);
|
||
|
||
/* The saved project is listed and reopens with its six objects. */
|
||
const recent = page.getByTestId("recent-projects");
|
||
await expect(recent.locator("option").first()).toBeAttached({ timeout: 20_000 });
|
||
await recent.selectOption({ index: 1 });
|
||
const discard = page.getByRole("button", { name: "不保存,继续", exact: true });
|
||
if (await discard.count() && await discard.isVisible()) await discard.click();
|
||
await expect.poll(async () => (await page.getByTestId("scene-stats").innerText()).match(/Objects (\d+)/)?.[1], { timeout: 20_000 }).toBe("6");
|
||
|
||
const image = await shot(page, testInfo, "reopen-recent");
|
||
receipt(testInfo, {
|
||
workflow: "save studio -> 文件→新建→常规 (Objects 3) -> 最近项目 -> reopen (Objects 6)",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch04] 刷新后从最近项目恢复已保存工程", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await waitEngineBoot(page);
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
await page.getByRole("button", { name: "添加立方体", exact: true }).click();
|
||
await waitForObjects(page, 7);
|
||
await page.getByLabel("保存项目").click();
|
||
await expect(page.getByTestId("dirty-status")).toHaveText("已保存", { timeout: 20_000 });
|
||
const projects = await opfsProjectIds(page);
|
||
|
||
await page.reload({ waitUntil: "domcontentloaded" });
|
||
await waitEngineBoot(page);
|
||
const recent = page.getByTestId("recent-projects");
|
||
await expect(recent.locator("option").first()).toBeAttached({ timeout: 20_000 });
|
||
await recent.selectOption({ index: 1 });
|
||
const discard = page.getByRole("button", { name: "不保存,继续", exact: true });
|
||
if (await discard.count() && await discard.isVisible()) await discard.click();
|
||
await expect.poll(async () => (await page.getByTestId("scene-stats").innerText()).match(/Objects (\d+)/)?.[1], { timeout: 20_000 }).toBe("7");
|
||
|
||
const image = await shot(page, testInfo, "reloaded-recent");
|
||
receipt(testInfo, {
|
||
workflow: "save 7-object scene -> reload -> 最近项目 -> Objects 7",
|
||
projects, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch05] 撤销重做与诊断报告导出", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
|
||
await page.getByRole("button", { name: "添加立方体", exact: true }).click();
|
||
await waitForObjects(page, 4);
|
||
await page.getByRole("button", { name: "撤销", exact: true }).click();
|
||
await waitForObjects(page, 3);
|
||
await page.getByRole("button", { name: "重做", exact: true }).click();
|
||
await waitForObjects(page, 4);
|
||
|
||
/* The export entry is disabled while the session has recorded no diagnostics
|
||
* (a healthy run legitimately has none), so the check is the state, not a
|
||
* download that cannot happen. */
|
||
const diagnostics = page.getByLabel("导出诊断报告");
|
||
await expect(diagnostics).toBeVisible();
|
||
const enabled = await diagnostics.isEnabled();
|
||
let downloadName: string | null = null;
|
||
if (enabled) {
|
||
const downloadPromise = page.waitForEvent("download", { timeout: 20_000 });
|
||
await diagnostics.click();
|
||
const download = await downloadPromise;
|
||
expect(download.suggestedFilename()).toMatch(/\.json$/i);
|
||
downloadName = download.suggestedFilename();
|
||
}
|
||
|
||
const image = await shot(page, testInfo, "undo-redo");
|
||
receipt(testInfo, {
|
||
workflow: "add cube (3→4) -> 撤销 (→3) -> 重做 (→4) -> 导出诊断报告",
|
||
diagnosticsExport: enabled ? downloadName : "disabled (no diagnostics recorded in this session)",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|