feat(web): Outliner search and state filters run through the native engine
The web Outliner filtered rows in the bundle while desktop filters inside
outliner_build_tree, so the filter controls diverged as soon as the tree
was rebuilt. OUTLINER_SET_FILTER writes SpaceOutliner's own search_string,
search_flags, flag and filter/filter_state fields and lets the native tree
rebuild; OUTLINER_SET_SYNC_SELECT toggles SO_SYNC_SELECT. Both are UI
state, so they report changed=false and leave history alone.
The protocol, worker and snapshot carry filter{...} and syncSelection; the
App drops the client-side filter on the native path (it stays for the
fallback surface), keeps an optimistic draft so the snapshot-controlled
checkboxes do not snap back during the async round trip, and rebases
Outliner intents after any Outliner command bumps the revision.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,59 @@ test.describe("Outliner headed baseline", () => {
|
||||
await expect.poll(labels, { timeout: 15_000 }).toEqual(viewLayerLabels);
|
||||
});
|
||||
|
||||
test("[outliner-filter-web] search and state filters run through the native Outliner filter", async ({ page }) => {
|
||||
test.setTimeout(150_000);
|
||||
await openWorkbench(page);
|
||||
const items = page.getByRole("treeitem");
|
||||
await expect.poll(async () => items.count(), { timeout: 20_000 }).toBeGreaterThan(1);
|
||||
const labels = () => items.evaluateAll((nodes) => nodes.map((node) => node.getAttribute("aria-label") ?? ""));
|
||||
const all = await labels();
|
||||
expect(all.some((label) => label.includes("Cube"))).toBe(true);
|
||||
|
||||
/* The snapshot's filter object drives the popover: 反转/同步选择 only render
|
||||
* on the native path, so their presence proves filtering is engine-backed. */
|
||||
const filterButton = page.locator('button[aria-label="筛选"]').first();
|
||||
await filterButton.click();
|
||||
const menu = page.locator(".outliner-filter-menu").first();
|
||||
await expect(menu).toBeVisible();
|
||||
const checkboxes = menu.locator('input[type="checkbox"]');
|
||||
await expect(checkboxes).toHaveCount(4);
|
||||
await filterButton.click();
|
||||
await expect(menu).toBeHidden();
|
||||
|
||||
/* Search writes SpaceOutliner.search_string; the engine trims the tree and
|
||||
* clearing it restores exactly the previous rows. */
|
||||
const search = page.locator('input[aria-label="搜索场景"]').first();
|
||||
await search.fill("Cube");
|
||||
await expect.poll(async () => (await labels()).length, { timeout: 15_000 }).toBeLessThan(all.length);
|
||||
expect((await labels()).some((label) => label.includes("Cube"))).toBe(true);
|
||||
await page.locator('button[aria-label="清除大纲搜索"]').first().click();
|
||||
await expect.poll(labels, { timeout: 15_000 }).toEqual(all);
|
||||
|
||||
/* Filter state SELECTED keeps the selected object plus its ancestors
|
||||
* (outliner_tree.cc filters children up to the matching branch). */
|
||||
await page.locator(".tree-node-name").last().click();
|
||||
const selectedLabel = await items.last().getAttribute("aria-label");
|
||||
await filterButton.click();
|
||||
await checkboxes.nth(1).check();
|
||||
await expect.poll(async () => (await labels()).length, { timeout: 15_000 }).toBeLessThan(all.length);
|
||||
const filtered = await labels();
|
||||
expect(filtered).toContain(selectedLabel);
|
||||
for (const label of filtered) expect(all).toContain(label);
|
||||
/* The popover reflects the engine-side filter_state, not local UI state. */
|
||||
await expect.poll(() => checkboxes.nth(1).isChecked(), { timeout: 15_000 }).toBe(true);
|
||||
await menu.getByRole("button", { name: "清除筛选" }).click();
|
||||
await expect.poll(labels, { timeout: 15_000 }).toEqual(all);
|
||||
|
||||
/* 同步选择 writes SO_SYNC_SELECT and round-trips through the snapshot. */
|
||||
const sync = checkboxes.last();
|
||||
await expect(sync).toBeChecked();
|
||||
await sync.uncheck();
|
||||
await expect.poll(() => sync.isChecked(), { timeout: 15_000 }).toBe(false);
|
||||
await sync.check();
|
||||
await expect.poll(() => sync.isChecked(), { timeout: 15_000 }).toBe(true);
|
||||
});
|
||||
|
||||
test("[outliner-mirror-baseline-web] the desktop mirror hands the Outliner to the DOM workspace", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.goto("/");
|
||||
|
||||
Reference in New Issue
Block a user