mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-26 07:57:36 +00:00
## Summary Replaces #12164. Right-clicking a Vue node, using the selection toolbox More Options menu, or clicking the selection toolbox Node Info button now opens the right-side Info tab only when the new-menu UI makes that panel available. Legacy-menu contexts hide the no-op action even when the legacy node library design is selected; node-library help remains isolated to the node library itself. The existing `selection_toolbox_node_info_opened` telemetry fires only after the toolbox button successfully opens node info. No new context-menu telemetry event is added in this PR. ## Changes - **What**: Share the node-info availability/action path across the context menu and selection toolbox, keep legacy-menu state out of the right-side panel public store API, tighten node-info settings tests, and add unit plus E2E regression coverage for new-menu and legacy-menu modes. - **Dependencies**: None ## Review Focus Confirm the node context menu, selection toolbox direct Info button, and selection toolbox More Options entry all respect right-side panel availability, including legacy menu + legacy node library mode, while node-library help behavior remains isolated to the node library. ## Validation - Self-review: checked production path, unit mocks, and Playwright coverage; only gap found was weak E2E coverage for the toolbox direct Info path, now strengthened. - `pnpm test:unit -- src/composables/graph/useSelectionState.test.ts src/components/graph/SelectionToolbox.test.ts src/components/graph/selectionToolbox/InfoButton.test.ts` - `pnpm test:browser:local -- --project=chromium browser_tests/tests/selectionToolboxActions.spec.ts browser_tests/tests/selectionToolboxSubmenus.spec.ts browser_tests/tests/vueNodes/interactions/node/contextMenu.spec.ts --grep "info button opens the right-side info tab|info button is hidden|hides Node Info|should open node info"` - `pnpm typecheck:browser` - `pnpm exec oxlint --type-aware browser_tests/tests/selectionToolboxActions.spec.ts` - `pnpm exec eslint --cache --no-warn-ignored browser_tests/tests/selectionToolboxActions.spec.ts` - `pnpm exec oxfmt --check browser_tests/tests/selectionToolboxActions.spec.ts` - `git diff --check` - Commit hooks: lint-staged + `pnpm typecheck` + `pnpm typecheck:browser` - Push hook: `knip --cache` (existing tag hint only) ## Screenshots (if applicable) Before https://github.com/user-attachments/assets/4b1f6ddb-a01c-4958-81ab-36167f434e59 https://github.com/user-attachments/assets/83433f0d-24f1-46b7-a81d-f0f065812496 After https://github.com/user-attachments/assets/30bd61e5-f8d4-48b7-97e0-26c93e3cb362 https://github.com/user-attachments/assets/afce9f51-a43d-434f-a006-6b357a61ac8f --------- Co-authored-by: github-actions <github-actions@github.com>
190 lines
5.9 KiB
TypeScript
190 lines
5.9 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe(
|
|
'Selection Toolbox - More Options Submenus',
|
|
{ tag: '@ui' },
|
|
() => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.Canvas.SelectionToolbox', true)
|
|
await comfyPage.workflow.loadWorkflow('nodes/single_ksampler')
|
|
await comfyPage.nodeOps.selectNodes(['KSampler'])
|
|
await comfyPage.nextFrame()
|
|
})
|
|
|
|
const openMoreOptions = async (comfyPage: ComfyPage) => {
|
|
const ksamplerNodes =
|
|
await comfyPage.nodeOps.getNodeRefsByTitle('KSampler')
|
|
if (ksamplerNodes.length === 0) {
|
|
throw new Error('No KSampler nodes found')
|
|
}
|
|
|
|
// Drag the KSampler to the center of the screen
|
|
const nodePos = await ksamplerNodes[0].getPosition()
|
|
const viewportSize = comfyPage.page.viewportSize()
|
|
if (!viewportSize) {
|
|
throw new Error(
|
|
'Viewport size is null - page may not be properly initialized'
|
|
)
|
|
}
|
|
const centerX = viewportSize.width / 3
|
|
const centerY = viewportSize.height / 2
|
|
await comfyPage.canvasOps.dragAndDrop(
|
|
{ x: nodePos.x, y: nodePos.y },
|
|
{ x: centerX, y: centerY }
|
|
)
|
|
await comfyPage.nextFrame()
|
|
|
|
await ksamplerNodes[0].click('title')
|
|
|
|
await expect(comfyPage.page.locator('.selection-toolbox')).toBeVisible()
|
|
|
|
const moreOptionsBtn = comfyPage.page.getByTestId('more-options-button')
|
|
await expect(moreOptionsBtn).toBeVisible()
|
|
|
|
await moreOptionsBtn.click()
|
|
|
|
await comfyPage.nextFrame()
|
|
|
|
const menuOptionsVisible = await comfyPage.page
|
|
.getByText('Rename')
|
|
.isVisible({ timeout: 2000 })
|
|
.catch(() => false)
|
|
if (menuOptionsVisible) {
|
|
return
|
|
}
|
|
|
|
await moreOptionsBtn.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
const menuOptionsVisibleAfterClick = await comfyPage.page
|
|
.getByText('Rename')
|
|
.isVisible({ timeout: 2000 })
|
|
.catch(() => false)
|
|
if (menuOptionsVisibleAfterClick) {
|
|
return
|
|
}
|
|
|
|
throw new Error('Could not open More Options menu - popover not showing')
|
|
}
|
|
|
|
test('hides Node Info from More Options menu when the new menu is disabled', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting('Comfy.NodeLibrary.NewDesign', false)
|
|
|
|
await openMoreOptions(comfyPage)
|
|
const nodeInfoButton = comfyPage.page.getByRole('menuitem', {
|
|
name: 'Node Info'
|
|
})
|
|
await expect(nodeInfoButton).toBeHidden()
|
|
})
|
|
|
|
test('changes node shape via Shape submenu', async ({ comfyPage }) => {
|
|
const nodeRef = (
|
|
await comfyPage.nodeOps.getNodeRefsByTitle('KSampler')
|
|
)[0]
|
|
|
|
await openMoreOptions(comfyPage)
|
|
await comfyPage.page.getByText('Shape', { exact: true }).hover()
|
|
await expect(
|
|
comfyPage.page.getByText('Box', { exact: true })
|
|
).toBeVisible()
|
|
await comfyPage.page.getByText('Box', { exact: true }).click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => nodeRef.getProperty<number>('shape')).toBe(1)
|
|
})
|
|
|
|
test('changes node color via Color submenu swatch', async ({
|
|
comfyPage
|
|
}) => {
|
|
const nodeRef = (
|
|
await comfyPage.nodeOps.getNodeRefsByTitle('KSampler')
|
|
)[0]
|
|
|
|
await openMoreOptions(comfyPage)
|
|
await comfyPage.page.getByText('Color', { exact: true }).click()
|
|
const blueSwatch = comfyPage.page.getByTitle('Blue')
|
|
await expect(blueSwatch.first()).toBeVisible()
|
|
await blueSwatch.first().click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => nodeRef.getProperty<string | undefined>('color'))
|
|
.toBe('#223')
|
|
})
|
|
|
|
test('renames a node using Rename action', async ({ comfyPage }) => {
|
|
const nodeRef = (
|
|
await comfyPage.nodeOps.getNodeRefsByTitle('KSampler')
|
|
)[0]
|
|
await openMoreOptions(comfyPage)
|
|
await comfyPage.page.getByText('Rename', { exact: true }).click()
|
|
const input = comfyPage.page.locator(
|
|
'.group-title-editor.node-title-editor .editable-text input'
|
|
)
|
|
await expect(input).toBeVisible()
|
|
await input.fill('RenamedNode')
|
|
await input.press('Enter')
|
|
await comfyPage.nextFrame()
|
|
await expect
|
|
.poll(() => nodeRef.getProperty<string>('title'))
|
|
.toBe('RenamedNode')
|
|
})
|
|
|
|
test('closes More Options menu when clicking outside', async ({
|
|
comfyPage
|
|
}) => {
|
|
await openMoreOptions(comfyPage)
|
|
const renameItem = comfyPage.page.getByText('Rename', { exact: true })
|
|
await expect(renameItem).toBeVisible()
|
|
|
|
// Wait for multiple frames to allow PrimeVue's outside click handler to initialize
|
|
for (let i = 0; i < 30; i++) {
|
|
await comfyPage.nextFrame()
|
|
}
|
|
|
|
await comfyPage.canvasOps.mouseClickAt({ x: 0, y: 50 })
|
|
await expect(
|
|
comfyPage.page.getByText('Rename', { exact: true })
|
|
).toBeHidden()
|
|
})
|
|
|
|
test('closes More Options menu when clicking the button again (toggle)', async ({
|
|
comfyPage
|
|
}) => {
|
|
await openMoreOptions(comfyPage)
|
|
await expect(
|
|
comfyPage.page.getByText('Rename', { exact: true })
|
|
).toBeVisible()
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const btn = document.querySelector(
|
|
'[data-testid="more-options-button"]'
|
|
)
|
|
if (btn) {
|
|
const event = new MouseEvent('click', {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
view: window,
|
|
detail: 1
|
|
})
|
|
btn.dispatchEvent(event)
|
|
}
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect(
|
|
comfyPage.page.getByText('Rename', { exact: true })
|
|
).toBeHidden()
|
|
})
|
|
}
|
|
)
|