mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-23 06:10:32 +00:00
*PR Created by the Glary-Bot Agent* --- ## Summary Adds `browser_tests/tests/selectionPasteRename.spec.ts` covering the untested `pasteSelection()` and `renameSelection()` paths in `useSelectionOperations.ts`. ### Coverage gaps filled - `pasteSelection()` — copy → paste creates new nodes - `renameSelection()` single node path — opens title editor - `renameSelection()` batch path — prompt dialog with sequential naming - Empty selection → toast warning ### References - Follows patterns from `selectionToolboxMoreActions.spec.ts` (More Options menu, `selectNodeWithPan`) - Follows `browser_tests/AGENTS.md` directory structure - Follows `browser_tests/FLAKE_PREVENTION_RULES.md` assertion patterns ### Verification - TypeScript: clean - ESLint: clean - oxlint: clean - oxfmt: formatted ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11367-test-add-selection-paste-rename-and-batch-rename-browser-tests-3466d73d3650812194a4d8bfbed3dee7) by [Unito](https://www.unito.io) --------- Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com> Co-authored-by: Amp <amp@ampcode.com>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { getGroupTitlePosition } from '@e2e/fixtures/utils/groupHelpers'
|
|
|
|
/**
|
|
* Returns {selectedNodeCount, selectedGroupCount, selectedItemCount}
|
|
* from the canvas in the browser.
|
|
*/
|
|
async function getSelectionCounts(comfyPage: ComfyPage) {
|
|
return comfyPage.page.evaluate(() => {
|
|
const canvas = window.app!.canvas
|
|
let selectedNodeCount = 0
|
|
let selectedGroupCount = 0
|
|
for (const item of canvas.selectedItems) {
|
|
if ('inputs' in item || 'outputs' in item) selectedNodeCount++
|
|
else selectedGroupCount++
|
|
}
|
|
return {
|
|
selectedNodeCount,
|
|
selectedGroupCount,
|
|
selectedItemCount: canvas.selectedItems.size
|
|
}
|
|
})
|
|
}
|
|
|
|
test.describe('Group Select Children', { tag: ['@canvas', '@node'] }, () => {
|
|
test.afterEach(async ({ comfyPage }) => {
|
|
await comfyPage.canvasOps.resetView()
|
|
})
|
|
|
|
test('Setting enabled: clicking outer group selects nested group and inner node', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'LiteGraph.Group.SelectChildrenOnClick',
|
|
true
|
|
)
|
|
await comfyPage.workflow.loadWorkflow('groups/nested-groups-1-inner-node')
|
|
|
|
const outerPos = await getGroupTitlePosition(comfyPage, 'Outer Group')
|
|
await comfyPage.canvas.click({ position: outerPos })
|
|
await comfyPage.nextFrame()
|
|
|
|
// Outer Group + Inner Group + 1 node = 3 items
|
|
await expect
|
|
.poll(() => getSelectionCounts(comfyPage))
|
|
.toMatchObject({
|
|
selectedItemCount: 3,
|
|
selectedGroupCount: 2,
|
|
selectedNodeCount: 1
|
|
})
|
|
})
|
|
|
|
test('Setting disabled: clicking outer group selects only the group', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'LiteGraph.Group.SelectChildrenOnClick',
|
|
false
|
|
)
|
|
await comfyPage.workflow.loadWorkflow('groups/nested-groups-1-inner-node')
|
|
|
|
const outerPos = await getGroupTitlePosition(comfyPage, 'Outer Group')
|
|
await comfyPage.canvas.click({ position: outerPos })
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => getSelectionCounts(comfyPage))
|
|
.toMatchObject({
|
|
selectedItemCount: 1,
|
|
selectedGroupCount: 1,
|
|
selectedNodeCount: 0
|
|
})
|
|
})
|
|
|
|
test('Deselecting outer group deselects all children', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'LiteGraph.Group.SelectChildrenOnClick',
|
|
true
|
|
)
|
|
await comfyPage.workflow.loadWorkflow('groups/nested-groups-1-inner-node')
|
|
|
|
// Select the outer group (cascades to children)
|
|
const outerPos = await getGroupTitlePosition(comfyPage, 'Outer Group')
|
|
await comfyPage.canvas.click({ position: outerPos })
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => getSelectionCounts(comfyPage))
|
|
.toMatchObject({ selectedItemCount: 3 })
|
|
|
|
// Deselect all via page.evaluate to avoid UI overlay interception
|
|
await comfyPage.page.evaluate(() => {
|
|
window.app!.canvas.deselectAll()
|
|
})
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => getSelectionCounts(comfyPage))
|
|
.toMatchObject({ selectedItemCount: 0 })
|
|
})
|
|
})
|