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>
234 lines
12 KiB
TypeScript
234 lines
12 KiB
TypeScript
import { expect, test, type Page } from "./support/deployed-test";
|
||
import { FIXTURES, ensureDefaultLayout, gotoApp, openProject, receipt, resetAreaLayout, shot, waitForObjects } from "./support/deployed";
|
||
|
||
/**
|
||
* Manual part B (ch06–ch12): workspaces and areas, viewport navigation,
|
||
* outliner, properties, object mode, mesh editing, modifier stack.
|
||
*
|
||
* Actions follow the manual's own wording — menu path first, shortcut second —
|
||
* and every case ends on a user-visible state (object/face counts, panel rows,
|
||
* persisted layout) rather than on "the click landed".
|
||
*/
|
||
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("[ch06] 区域可切换编辑器、可分割并重置布局", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
const grid = page.locator(".workspace-grid");
|
||
await ensureDefaultLayout(page);
|
||
await expect(grid.locator(":scope > .area-frame")).toHaveCount(4, { timeout: 30_000 });
|
||
|
||
/* Area ⋮ → 垂直分割. */
|
||
const properties = page.locator(".area-frame.properties-area").first();
|
||
await properties.locator(".area-type-switch .area-menu button").click();
|
||
await page.getByRole("menuitem", { name: "垂直分割(左右)", exact: true }).click({ timeout: 15_000 });
|
||
await expect(page.locator("main.blender-app")).toHaveAttribute("data-area-layout", "custom");
|
||
await expect.poll(async () => grid.locator(":scope > .area-frame").count()).toBe(5);
|
||
|
||
/* Reset goes back to the built-in four-area layout. */
|
||
await resetAreaLayout(page);
|
||
await expect(page.locator("main.blender-app")).toHaveAttribute("data-area-layout", "default");
|
||
await expect.poll(async () => grid.locator(":scope > .area-frame").count()).toBe(4);
|
||
|
||
const image = await shot(page, testInfo, "areas-reset");
|
||
receipt(testInfo, {
|
||
workflow: "properties ⋮ -> 垂直分割 -> 5 areas -> area reset -> 4 areas",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch06b] 区域可通过编辑器选择器切换类型", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
const properties = page.locator(".area-frame.properties-area").first();
|
||
const switcher = properties.locator(".area-type-switch select");
|
||
await expect(switcher).toBeVisible({ timeout: 15_000 });
|
||
await switcher.selectOption("Spreadsheet");
|
||
await expect(properties).toHaveAttribute("data-editor", "Spreadsheet", { timeout: 15_000 });
|
||
await properties.locator(".area-type-switch select").selectOption("Properties");
|
||
await expect(properties).toHaveAttribute("data-editor", "Properties", { timeout: 15_000 });
|
||
|
||
const image = await shot(page, testInfo, "area-editor-switch");
|
||
receipt(testInfo, {
|
||
workflow: "properties area switcher: Properties -> Spreadsheet -> Properties",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch07] 视口导航按钮改变视图名称与相机模式", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ });
|
||
await waitForObjects(page, 6);
|
||
|
||
await page.getByRole("button", { name: "显示全部", exact: true }).click();
|
||
await page.getByRole("button", { name: "框显所选", exact: true }).click();
|
||
await expect(page.locator(".viewport-view-label")).toBeVisible({ timeout: 30_000 }).catch(() => undefined);
|
||
|
||
/* Projection toggle flips the pressed state, camera view enters CAMERA. */
|
||
const projection = page.getByRole("button", { name: "切换透视正交", exact: true });
|
||
const before = await projection.getAttribute("aria-pressed");
|
||
await projection.click();
|
||
await expect(projection).not.toHaveAttribute("aria-pressed", before ?? "false", { timeout: 30_000 });
|
||
|
||
const camera = page.getByRole("button", { name: "相机视图", exact: true });
|
||
await camera.click();
|
||
await expect(camera).toHaveAttribute("aria-pressed", "true", { timeout: 30_000 });
|
||
const viewLabel = (await page.locator(".viewport-view-label").innerText().catch(() => "")).trim();
|
||
|
||
const image = await shot(page, testInfo, "camera-view");
|
||
receipt(testInfo, {
|
||
workflow: "显示全部 -> 框显所选 -> 透视/正交 -> 相机视图",
|
||
projectionBefore: before, viewLabel, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch08] Outliner 选中对象并重命名", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
|
||
const cube = page.getByRole("treeitem", { name: "BasicCube", exact: true });
|
||
await cube.click();
|
||
await expect(cube).toHaveAttribute("aria-selected", "true");
|
||
|
||
await menu(page, "物体", "重命名");
|
||
await page.getByLabel("新对象名称").fill("Renamed By Deployed Suite");
|
||
await page.getByRole("button", { name: "确认", exact: true }).click();
|
||
await expect(page.getByRole("treeitem", { name: "Renamed By Deployed Suite", exact: true })).toBeVisible({ timeout: 15_000 });
|
||
|
||
const image = await shot(page, testInfo, "outliner-renamed");
|
||
receipt(testInfo, {
|
||
workflow: "select BasicCube -> 物体 → 重命名 -> tree shows new name",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch09] Properties 标签跳转到对象、修改器与材质区", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
await page.getByRole("treeitem", { name: "BasicCube", exact: true }).click();
|
||
|
||
const properties = page.locator(".area-frame.properties-area").first();
|
||
const modifierTab = properties.locator('button[title="修改器属性"]');
|
||
await modifierTab.click();
|
||
await expect(modifierTab).toHaveAttribute("aria-selected", "true", { timeout: 15_000 });
|
||
|
||
const materialTab = properties.locator('button[title="材质属性"]');
|
||
await materialTab.click();
|
||
await expect(materialTab).toHaveAttribute("aria-selected", "true", { timeout: 15_000 });
|
||
await expect(properties.getByTestId("material-slots-section")).toBeVisible({ timeout: 15_000 });
|
||
|
||
const image = await shot(page, testInfo, "properties-material");
|
||
receipt(testInfo, {
|
||
workflow: "properties tabs: modifier -> material, material slots visible",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch10] 对象模式添加、复制并删除对象", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
|
||
await menu(page, "添加", "网格", "立方体");
|
||
await waitForObjects(page, 4);
|
||
await menu(page, "物体", "复制对象");
|
||
await waitForObjects(page, 5);
|
||
await menu(page, "物体", "删除");
|
||
await waitForObjects(page, 4);
|
||
await menu(page, "编辑", "撤销");
|
||
await waitForObjects(page, 5);
|
||
|
||
const image = await shot(page, testInfo, "object-add-duplicate-delete");
|
||
receipt(testInfo, {
|
||
workflow: "添加→网格→立方体 (3→4) -> 复制 (→5) -> 删除 (→4) -> 撤销 (→5)",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch11] 编辑模式面选择后三角化改变面数", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
await page.getByRole("treeitem", { name: "BasicCube", exact: true }).click();
|
||
|
||
await page.getByRole("button", { name: "Object Mode", exact: true }).click();
|
||
/* Mode entries carry a checked state, so their role is menuitemcheckbox;
|
||
* they are disabled until the selection has resolved to a mesh. */
|
||
const editEntry = page.getByRole("menuitemcheckbox", { name: "编辑模式", exact: true });
|
||
await expect(editEntry).toBeEnabled({ timeout: 15_000 });
|
||
await editEntry.click({ timeout: 15_000 });
|
||
const facesBefore = Number((await page.getByTestId("scene-stats").innerText()).match(/Faces (\d+)/)?.[1] ?? -1);
|
||
|
||
await page.getByRole("button", { name: "面选择", exact: true }).click();
|
||
await page.getByRole("button", { name: "选择", exact: true }).click();
|
||
await page.getByRole("menuitem", { name: "全部", exact: true }).click({ timeout: 15_000 });
|
||
await page.getByRole("button", { name: "面", exact: true }).click();
|
||
await page.getByRole("menuitem", { name: "三角化", exact: true }).click({ timeout: 15_000 });
|
||
await expect.poll(async () => Number((await page.getByTestId("scene-stats").innerText()).match(/Faces (\d+)/)?.[1] ?? -1), { timeout: 20_000 }).toBe(facesBefore * 2);
|
||
|
||
const image = await shot(page, testInfo, "triangulated");
|
||
receipt(testInfo, {
|
||
workflow: "edit mode -> face select all -> 三角化",
|
||
facesBefore, facesAfter: facesBefore * 2, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch12] 修改器栈添加修改器后出现行并可使用撤销", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await waitForObjects(page, 3);
|
||
await page.getByRole("treeitem", { name: "BasicCube", exact: true }).click();
|
||
|
||
/* Web mode authors the stack with a free-text type box plus "Add" in the
|
||
* `.modifier-stack-authoring` section; `.modifier-panel` is the Decimate
|
||
* parameter block below it, and `[data-modifier-row]` belongs to the native
|
||
* session UI. */
|
||
const properties = page.locator(".area-frame.properties-area").first();
|
||
await properties.locator('button[title="修改器属性"]').click();
|
||
const authoring = properties.locator(".modifier-stack-authoring");
|
||
await expect(authoring).toBeVisible({ timeout: 15_000 });
|
||
const rows = properties.locator(".modifier-row");
|
||
const rowsBefore = await rows.count();
|
||
await authoring.getByLabel("Modifier type", { exact: true }).fill("BEVEL");
|
||
await authoring.getByRole("button", { name: "Add", exact: true }).click();
|
||
await expect.poll(async () => rows.count(), { timeout: 20_000 }).toBe(rowsBefore + 1);
|
||
|
||
const image = await shot(page, testInfo, "modifier-added");
|
||
receipt(testInfo, {
|
||
workflow: "properties -> modifier tab -> Modifier type BEVEL -> Add",
|
||
rowsBefore, rowsAfter: rowsBefore + 1, screenshot: image, status: "PASS",
|
||
});
|
||
});
|
||
|
||
test("[ch02] 切换到 Modeling 工作区后快捷栏提供建模入口", async ({ page }, testInfo) => {
|
||
await gotoApp(page, "web");
|
||
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
|
||
await switchWorkspace(page, "Modeling");
|
||
await expect(page.locator(".legacy-quick-toolbar")).toBeVisible({ timeout: 15_000 });
|
||
/* Primitive buttons carry an aria-label, so that is their accessible name. */
|
||
await page.locator(".legacy-quick-toolbar").getByRole("button", { name: "添加立方体", exact: true }).click();
|
||
await expect.poll(async () => (await page.getByTestId("scene-stats").innerText()).match(/Objects (\d+)/)?.[1], { timeout: 20_000 }).toBe("4");
|
||
|
||
const image = await shot(page, testInfo, "modeling-toolbar");
|
||
receipt(testInfo, {
|
||
workflow: "Modeling workspace -> quick toolbar Add CUBE -> Objects 4",
|
||
screenshot: image, status: "PASS",
|
||
});
|
||
});
|