feat(web): Outliner object and collection rows open the desktop menus
- Rebuild the row menus from shared builders following space_outliner.py: OUTLINER_MT_object (Copy/Paste | Delete | Select* | Unlink/New Collection | ID Data | common groups) and OUTLINER_MT_collection (New/Duplicate/Copy/ Paste | Delete | Select Objects | Instance/Unlink | Visibility | View Layer | Color Tag | ID Data | common groups). - The ID Data, visibility, view layer, color tag, asset, library override and view submenus are shared by the row-type menus and the empty-area menu; the asset entries are inlined like draw_common_operators' menu_contents, and the library override operations now nest under their desktop submenu. - Top-level Copy/Paste dispatch OUTLINER_OT_id_copy/id_paste; the ID Data submenu keeps its enum entries. - New headed case [outliner-menu-structure-web]; separator and submenu expectations updated. Full headed suite 45/45, validator PASS. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web", "outliner-show-active-web", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web"];
|
||||
const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web", "outliner-show-active-web", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web", "outliner-menu-structure-web"];
|
||||
/* Desktop Layout geometry the metrics case must reproduce (batch 2: UI sizes). */
|
||||
const GEOMETRY_GOLDEN = path.join(REPO_ROOT, "tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json");
|
||||
const errors = [];
|
||||
|
||||
@@ -75,6 +75,7 @@ const KNOWN_CASES = [
|
||||
{ id: "outliner-relocate-web", title: /\[outliner-relocate-web\]/ },
|
||||
{ id: "outliner-liboverride-troubleshoot-web", title: /\[outliner-liboverride-troubleshoot-web\]/ },
|
||||
{ id: "outliner-row-type-menus-web", title: /\[outliner-row-type-menus-web\]/ },
|
||||
{ id: "outliner-menu-structure-web", title: /\[outliner-menu-structure-web\]/ },
|
||||
];
|
||||
|
||||
function usage() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -758,7 +758,13 @@ test.describe("Outliner headed baseline", () => {
|
||||
const make = page.getByRole("menuitem", { name: "创建库覆盖 (Make Library Override)", exact: true });
|
||||
const reset = page.getByRole("menuitem", { name: "重置库覆盖 (Reset Library Override)", exact: true });
|
||||
const clear = page.getByRole("menuitem", { name: "清除库覆盖 (Clear Library Override)", exact: true });
|
||||
await overrideRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
/* Desktop draws OUTLINER_MT_liboverride as a submenu (space_outliner.py);
|
||||
* the three operations live under it. */
|
||||
const openOverrideMenu = async () => {
|
||||
await overrideRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click();
|
||||
};
|
||||
await openOverrideMenu();
|
||||
await expect(reset).toBeEnabled();
|
||||
await expect(clear).toBeEnabled();
|
||||
/* Only linked references can be overridden; an existing override cannot. */
|
||||
@@ -767,7 +773,7 @@ test.describe("Outliner headed baseline", () => {
|
||||
await expect(status).toContainText("已重置库覆盖", { timeout: 30_000 });
|
||||
await expect(overrideRow).toBeVisible();
|
||||
|
||||
await overrideRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await openOverrideMenu();
|
||||
await clear.click();
|
||||
await expect(status).toContainText("已清除库覆盖", { timeout: 30_000 });
|
||||
/* Clearing drops the local override and relinks the library original, so
|
||||
@@ -1487,9 +1493,10 @@ test.describe("Outliner headed baseline", () => {
|
||||
}
|
||||
await expect(page.getByRole("menuitem", { name: "‹ ID Data", exact: true })).toHaveCount(1);
|
||||
|
||||
/* The moved operations no longer sit in the flat menu. */
|
||||
/* Back in the collection menu: the desktop object/collection menus carry
|
||||
* their own top-level Copy/Paste next to the ID Data submenu. */
|
||||
await page.getByRole("menuitem", { name: "‹ ID Data", exact: true }).click();
|
||||
await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(1);
|
||||
await expect(page.getByRole("menuitem", { name: "标记为资产 (Mark as Asset)", exact: true })).toHaveCount(1);
|
||||
});
|
||||
|
||||
@@ -1505,14 +1512,15 @@ test.describe("Outliner headed baseline", () => {
|
||||
await expect(partsRow).toBeVisible({ timeout: 30_000 });
|
||||
await partsRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
|
||||
/* Desktop space_outliner.py groups the menu with separators: New/Duplicate |
|
||||
* Delete | Select Objects | Instance/Link/Unlink | Visibility | [View Layer]
|
||||
* | Color Tag | ID Data | …; the web Data menu keeps the same boundaries. */
|
||||
/* Desktop OUTLINER_MT_collection groups the menu with separators:
|
||||
* New/Duplicate/Copy/Paste | Delete | Select Objects | Instance/Unlink |
|
||||
* Visibility | [View Layer] | Color Tag | ID Data | assets | overrides |
|
||||
* View; the web Data menu keeps the same boundaries. */
|
||||
const panel = page.locator(".desktop-menu-panel").first();
|
||||
await expect(page.getByRole("menuitem", { name: "视图 (View)", exact: true })).toHaveCount(1, { timeout: 15_000 });
|
||||
const sequence: string[] = await panel.evaluate((el) => Array.from(el.children).map((child) => child.getAttribute("role") === "separator" ? "|" : (child.getAttribute("aria-label") ?? "")));
|
||||
expect(sequence.filter((entry) => entry === "|")).toHaveLength(8);
|
||||
for (const [above, below] of [["删除层级", "新建集合 (New Collection)"], ["视图层 (View Layer)", "选择对象 (Select Objects)"], ["取消选择对象 (Deselect Objects)", "取消链接"], ["取消链接", "选择 (Select)"], ["取消选择 (Deselect)", "ID Data"], ["ID Data", "标记为资产 (Mark as Asset)"], ["清除资产(设置伪用户)", "创建库覆盖 (Make Library Override)"], ["清除库覆盖 (Clear Library Override)", "视图 (View)"]]) {
|
||||
expect(sequence.filter((entry) => entry === "|")).toHaveLength(10);
|
||||
for (const [above, below] of [["粘贴", "删除集合"], ["删除层级", "选择对象 (Select Objects)"], ["取消选择对象 (Deselect Objects)", "实例化到场景 (Instance to Scene)"], ["取消链接", "可见性 (Visibility)"], ["可见性 (Visibility)", "视图层 (View Layer)"], ["视图层 (View Layer)", "颜色标签 (Color Tag)"], ["颜色标签 (Color Tag)", "ID Data"], ["ID Data", "标记为资产 (Mark as Asset)"], ["清除资产(设置伪用户)", "库覆盖 (Library Override)"], ["库覆盖 (Library Override)", "视图 (View)"]]) {
|
||||
const boundary = sequence.findIndex((entry, index) => entry === "|" && sequence[index - 1] === above && sequence[index + 1] === below);
|
||||
expect(boundary, `${above} | ${below}`).toBeGreaterThan(0);
|
||||
}
|
||||
@@ -1607,6 +1615,7 @@ test.describe("Outliner headed baseline", () => {
|
||||
/* Desktop OUTLINER_MT_liboverride ends with Troubleshoot:
|
||||
* Resync | Resync Enforce | separator | Delete. */
|
||||
await overrideRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click();
|
||||
const troubleshoot = page.getByRole("menuitem", { name: "库覆盖排查 (Troubleshoot)", exact: true });
|
||||
await expect(troubleshoot).toHaveCount(1, { timeout: 15_000 });
|
||||
await troubleshoot.click();
|
||||
@@ -1620,6 +1629,7 @@ test.describe("Outliner headed baseline", () => {
|
||||
/* Delete removes the override hierarchy and relinks the usage to the
|
||||
* linked data-block, so the Current File object row disappears. */
|
||||
await overrideRow.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "库覆盖排查 (Troubleshoot)", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "删除 (Delete)", exact: true }).click();
|
||||
await expect(status).toContainText("已删除库覆盖层级", { timeout: 30_000 });
|
||||
@@ -1821,7 +1831,7 @@ test.describe("Outliner headed baseline", () => {
|
||||
* right-click target, so dispatch the contextmenu on it directly. */
|
||||
await page.locator(".outliner-content:visible").first()
|
||||
.dispatchEvent("contextmenu", { button: 2, buttons: 2, clientX: 8, clientY: 8 });
|
||||
for (const label of ["新建集合 (New Collection)", "粘贴数据块 (Paste Data-Blocks)", "资产", "库覆盖", "视图 (View)"]) {
|
||||
for (const label of ["新建集合 (New Collection)", "粘贴数据块 (Paste Data-Blocks)", "标记为资产 (Mark as Asset)", "库覆盖 (Library Override)", "视图 (View)"]) {
|
||||
await expect(page.getByRole("menuitem", { name: label, exact: true })).toHaveCount(1, { timeout: 15_000 });
|
||||
}
|
||||
await page.getByRole("menuitem", { name: "新建集合 (New Collection)", exact: true }).click();
|
||||
@@ -1868,4 +1878,51 @@ test.describe("Outliner headed baseline", () => {
|
||||
await expect(status).toContainText("已重新加载库", { timeout: 120_000 });
|
||||
await expect(libraryRow).toBeVisible({ timeout: 30_000 });
|
||||
});
|
||||
|
||||
test("[outliner-menu-structure-web] object and collection rows open the desktop menus with top-level copy/paste", async ({ page }) => {
|
||||
test.setTimeout(240_000);
|
||||
await openWorkbench(page);
|
||||
const objectRows = page.locator('.outliner-tree .tree-row[data-node-id]:not([data-node-id=""])');
|
||||
await expect.poll(() => objectRows.count(), { timeout: 20_000 }).toBeGreaterThan(0);
|
||||
const panel = page.locator(".desktop-menu-panel").first();
|
||||
const sequence = () => panel.evaluate((el) => Array.from(el.children).map((child) =>
|
||||
child.getAttribute("role") === "separator" ? "|" : (child.getAttribute("aria-label") ?? "")));
|
||||
|
||||
/* OUTLINER_MT_object starts with top-level Copy/Paste, then Delete,
|
||||
* Select*, Unlink, New Collection, ID Data and the common groups. */
|
||||
const cube = page.locator('.tree-row[aria-label="BasicCube"]').first();
|
||||
await cube.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(1, { timeout: 15_000 });
|
||||
const objectSequence = await sequence();
|
||||
expect(objectSequence.slice(0, 3)).toEqual(["复制", "粘贴", "|"]);
|
||||
expect(objectSequence).toContain("删除 (X)");
|
||||
expect(objectSequence.indexOf("删除 (X)")).toBeGreaterThan(2);
|
||||
expect(objectSequence).toContain("选择 (Select)");
|
||||
expect(objectSequence).toContain("选择层级 (Select Hierarchy)");
|
||||
expect(objectSequence).toContain("取消选择 (Deselect)");
|
||||
expect(objectSequence).toContain("ID Data");
|
||||
expect(objectSequence).toContain("视图 (View)");
|
||||
/* Collection-only entries stay out of the object menu. */
|
||||
expect(objectSequence).not.toContain("选择对象 (Select Objects)");
|
||||
expect(objectSequence).not.toContain("删除集合");
|
||||
|
||||
/* The top-level entries run OUTLINER_OT_id_copy/id_paste directly. */
|
||||
await page.getByRole("menuitem", { name: "复制", exact: true }).click();
|
||||
await expect(page.locator('[data-testid="engine-status"]')).toContainText("已复制数据块", { timeout: 20_000 });
|
||||
const before = await objectRows.count();
|
||||
await cube.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "粘贴", exact: true }).click();
|
||||
await expect.poll(() => objectRows.count(), { timeout: 20_000 }).toBe(before + 1);
|
||||
|
||||
/* OUTLINER_MT_collection starts with New/Duplicate Collection and Copy/
|
||||
* Paste, keeps Select Objects, and drops the object-only entries. */
|
||||
const collection = page.locator('.tree-row[aria-label="Collection"]').first();
|
||||
await collection.locator(".tree-node-name").first().click({ button: "right" });
|
||||
await expect(page.getByRole("menuitem", { name: "选择对象 (Select Objects)", exact: true })).toHaveCount(1, { timeout: 15_000 });
|
||||
const collectionSequence = await sequence();
|
||||
expect(collectionSequence.slice(0, 5)).toEqual(["新建集合 (New Collection)", "复制集合 (Duplicate Collection)", "复制链接 (Duplicate Linked)", "复制", "粘贴"]);
|
||||
expect(collectionSequence).toContain("选择对象 (Select Objects)");
|
||||
expect(collectionSequence).not.toContain("删除 (X)");
|
||||
expect(collectionSequence).not.toContain("选择 (Select)");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user