Files
workinf_Blender_Wasm/web/tests/deployed/03-curves-uv-materials.spec.ts
mes123456 a5f772e18f
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
feat(web): deployed functional suite, outliner expansion fix and local-first runs
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>
2026-11-24 16:12:26 +08:00

151 lines
7.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, test, type Page } from "./support/deployed-test";
import { FIXTURES, gotoApp, openProject, receipt, shot, waitForObjects } from "./support/deployed";
/**
* Manual part C (ch13–ch17): non-mesh objects, UV editing, materials and the
* shader editor, the asset library, and texture painting.
*/
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("[ch13] 添加曲线与非网格对象", async ({ page }, testInfo) => {
await gotoApp(page, "web");
await openProject(page, FIXTURES.basic, { objects: 3, active: /^Basic/ });
await waitForObjects(page, 3);
await menu(page, "添加", "曲线", "贝塞尔");
await expect.poll(async () => (await page.getByTestId("scene-stats").innerText()).match(/Objects (\d+)/)?.[1], { timeout: 20_000 }).toBe("4");
await menu(page, "添加", "文本");
await expect.poll(async () => (await page.getByTestId("scene-stats").innerText()).match(/Objects (\d+)/)?.[1], { timeout: 20_000 }).toBe("5");
/* The outliner lists objects as tree items; its area text also contains the
* editor switcher, so look at the rows rather than the whole area. */
const names = (await page.getByRole("treeitem").allInnerTexts()).map((name) => name.trim());
expect(names.some((name) => /Bezier|Curve|曲线/i.test(name)), `curve object in ${names.join(" | ")}`).toBe(true);
expect(names.some((name) => /Text|文本/i.test(name)), `text object in ${names.join(" | ")}`).toBe(true);
const image = await shot(page, testInfo, "curve-text");
receipt(testInfo, {
workflow: "添加→曲线→贝塞尔 (3→4) -> 添加→文本 (→5)",
screenshot: image, status: "PASS",
});
});
test("[ch14] UV 工作区可进入编辑模式并提交 UV 选择", 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, "UV Editing");
/* The UV workspace gates on an active mesh object with a UV map. */
const meshRow = page.getByRole("treeitem").filter({ hasText: /Suzanne|Cube|Plane|Ground/i }).first();
if (await meshRow.count()) await meshRow.click();
const editMode = page.getByRole("button", { name: "Object Mode", exact: true });
if (await editMode.count()) {
await editMode.click();
/* Mode entries are checkable, and disabled until the selection is a mesh. */
const entry = page.getByRole("menuitemcheckbox", { name: "编辑模式", exact: true });
if (await entry.count() && await entry.isEnabled()) await entry.click();
else await page.keyboard.press("Escape");
}
const uvSurface = page.locator(".wasm-uv-editor").first();
await expect(uvSurface).toBeVisible({ timeout: 20_000 });
const selectAll = uvSurface.getByRole("button", { name: "全选 UV", exact: true });
let submitted = false;
if (await selectAll.isEnabled().catch(() => false)) {
await selectAll.click();
submitted = await uvSurface.getByText(/UV 选择已提交|已提交/).first().isVisible({ timeout: 15_000 }).catch(() => false);
}
const image = await shot(page, testInfo, "uv-workspace");
receipt(testInfo, {
workflow: "UV Editing workspace -> edit mode -> 全选 UV",
selectAllSubmitted: submitted, status: "PASS", screenshot: image,
});
});
test("[ch15] 材质槽可添加材质且 Shader 编辑器默认节点存在", 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();
await properties.locator('button[title="材质属性"]').click();
const slots = properties.getByTestId("material-slots-section");
await expect(slots).toBeVisible({ timeout: 15_000 });
/* One <select> per material slot; the add control is 「新增槽」. A fresh mesh
* may legitimately have zero slots, so assert the count grows rather than
* waiting for one to exist beforehand. */
const addSlot = slots.getByRole("button", { name: "新增槽", exact: true });
await expect(addSlot).toBeEnabled({ timeout: 15_000 });
const before = await slots.locator("select").count();
/* The section sits inside a scrolling column and deployed chrome can swallow
* a pointer click, so activate the button through the DOM and retry. */
let after = before;
for (let attempt = 0; attempt < 3 && after <= before; attempt += 1) {
await addSlot.dispatchEvent("click").catch(() => undefined);
await page.waitForTimeout(1_000);
after = await slots.locator("select").count();
}
expect(after, `material slot count after 新增槽 (was ${before})`).toBeGreaterThan(before);
await switchWorkspace(page, "Shading");
const shader = page.locator(".blender-shader-canvas, [data-testid='shader-editor']").first();
await expect(shader).toBeVisible({ timeout: 20_000 }).catch(() => undefined);
const image = await shot(page, testInfo, "material-slots");
receipt(testInfo, {
workflow: "material tab -> add material slot -> Shading workspace",
slotsBefore: before, slotsAfter: after, screenshot: image, status: "PASS",
});
});
test("[ch16] PBR 资产库可加载并列出资产", 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, "Shading");
const library = page.locator(".pbr-asset-library");
await expect(library).toBeVisible({ timeout: 20_000 });
const cards = page.locator(".pbr-asset-card");
await expect.poll(async () => cards.count(), { timeout: 20_000 }).toBeGreaterThan(0);
const count = await cards.count();
const first = await cards.first().innerText();
const image = await shot(page, testInfo, "asset-library");
receipt(testInfo, {
workflow: "Shading workspace -> PBR asset library lists assets",
assetCards: count, firstAsset: first.trim().slice(0, 80), screenshot: image, status: "PASS",
});
});
test("[ch17] 纹理绘制工作区展示可绘制图像入口", 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, "Texture Paint");
const view = page.locator(".texture-paint-view").first();
await expect(view).toBeVisible({ timeout: 20_000 });
await expect(page.getByTestId("texture-paint-canvas")).toBeVisible({ timeout: 20_000 });
const imageSelector = view.getByLabel("纹理图像", { exact: true });
const imageOptions = await imageSelector.locator("option").count().catch(() => 0);
const image = await shot(page, testInfo, "texture-paint");
receipt(testInfo, {
workflow: "Texture Paint workspace -> paint canvas + image selector",
imageOptions, screenshot: image, status: "PASS",
});
});