Files
workinf_Blender_Wasm/web/tests/e2e/outliner-treeview-production.spec.ts
mes123456 3e97d5b645
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): outliner rows render through one React tree with search and filters
Both Outliner surfaces (native workflow rows and the snapshot fallback) now
render through the shared OutlinerTreeView, so the hand-built tree markup in
App.tsx is gone. The toolbar gains a name search, and the filter popover at
the end of the toolbar narrows rows to visible or selected objects; collection
rows join a sidebar-filtered result only as ancestors, so the root cannot keep
every descendant visible. The treeview is keyed on its node set and restores
focus and scroll across that remount. A production spec exercises the search,
clear and filter round trip.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-30 03:12:32 +08:00

86 lines
4.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";
const HERE = path.dirname(fileURLToPath(import.meta.url));
const BASIC_SCENE = path.resolve(HERE, "../../../tests/files/web/basic_scene.blend");
test.describe("Outliner React treeview production path", () => {
test("renders native rows with tree semantics and keeps selection wired", async ({ page }) => {
await page.goto("/?ui=web");
await page.locator('[data-testid="blend-file-input"]').setInputFiles(BASIC_SCENE);
await expect(page.locator(".blender-app")).toHaveAttribute("data-project-id", /.+/, { timeout: 60_000 });
await expect(page.getByText(/Engine: SceneIR/).first()).toBeVisible({ timeout: 60_000 });
const webTools = page.locator('[data-testid="native-web-tools-toggle"]');
if (await webTools.count()) await webTools.click();
const tree = page.locator(".outliner-tree").first();
await expect(tree).toBeVisible({ timeout: 20_000 });
await expect(page.getByRole("tree").first()).toBeVisible();
const items = page.getByRole("treeitem");
await expect.poll(async () => items.count(), { timeout: 20_000 }).toBeGreaterThan(0);
const firstItem = items.first();
await expect(firstItem).toHaveAttribute("aria-level", /^\d+$/);
await expect(firstItem).toHaveAttribute("aria-label", /.+/);
const name = firstItem.locator(".tree-node-name").first();
if (await name.count()) {
await name.click();
await expect.poll(async () => page.locator('[role="treeitem"][aria-selected="true"]').count(), { timeout: 15_000 }).toBeGreaterThan(0);
}
const expand = page.locator(".tree-expand").first();
if (await expand.count()) {
const before = await items.count();
const label = await expand.getAttribute("aria-label");
if (label?.startsWith("展开")) {
await expand.click();
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBeGreaterThan(before);
}
}
});
test("searches, filters and clears rows through the shared tree", async ({ page }) => {
await page.goto("/?ui=web");
await page.locator('[data-testid="blend-file-input"]').setInputFiles(BASIC_SCENE);
await expect(page.locator(".blender-app")).toHaveAttribute("data-project-id", /.+/, { timeout: 60_000 });
await expect(page.getByText(/Engine: SceneIR/).first()).toBeVisible({ timeout: 60_000 });
const webTools = page.locator('[data-testid="native-web-tools-toggle"]');
if (await webTools.count()) await webTools.click();
const tree = page.locator(".outliner-tree").first();
await expect(tree).toBeVisible({ timeout: 20_000 });
const items = page.getByRole("treeitem");
await expect.poll(async () => items.count(), { timeout: 20_000 }).toBeGreaterThan(0);
const before = await items.count();
const search = page.locator('input[aria-label="搜索场景"]').first();
await expect(search).toBeVisible();
const target = await items.last().getAttribute("aria-label");
expect(target).toBeTruthy();
await search.fill(target!);
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBeLessThan(before);
await expect(page.locator(`[role="treeitem"][aria-label="${target}"]`).first()).toBeVisible();
await page.locator('button[aria-label="清除大纲搜索"]').first().click();
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBe(before);
await page.locator(".tree-node-name").last().click();
await expect.poll(async () => page.locator('[role="treeitem"][aria-selected="true"]').count(), { timeout: 15_000 }).toBeGreaterThan(0);
const filterToggle = page.locator('button[aria-label="筛选"]').first();
await filterToggle.click();
const filterMenu = page.locator(".outliner-filter-menu").first();
await expect(filterMenu).toBeVisible();
await filterMenu.locator('input[type="checkbox"]').nth(1).check();
await expect(filterToggle).toHaveAttribute("aria-pressed", "true");
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBeLessThan(before);
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBeGreaterThan(0);
await filterMenu.getByRole("button", { name: "清除筛选" }).click();
await expect.poll(async () => items.count(), { timeout: 15_000 }).toBe(before);
});
});