mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary
Enable the previously disabled `playwright/no-force-option` lint rule at
error level and resolve all 29 violations across 10 files.
## Changes
### Lint rule
- `.oxlintrc.json`: `playwright/no-force-option` changed from `off` to
`error`
### Shared utility
- `CanvasHelper.ts`: Add `mouseClickAt()` and `mouseDblclickAt()`
methods that convert canvas-element-relative positions to absolute page
coordinates and use `page.mouse` APIs, avoiding Playwright's locator
actionability checks that fail when Vue DOM overlays sit above the
`<canvas>` element
### Force removal (20 violations)
- `selectionToolboxActions.spec.ts`: Remove `force: true` from 8 toolbox
button clicks (the `pointer-events: none` splitter overlay does not
intercept `elementFromPoint()`)
- `selectionToolboxSubmenus.spec.ts`: Remove `force: true` from 2
popover menu item clicks
- `BuilderSelectHelper.ts`: Remove `force: true` from 2 widget/node
clicks (builder mode does not disable pointer events)
- `linkInteraction.spec.ts`: Remove `force: true` from 3 slot `dragTo()`
calls (`::after` pseudo-elements do not intercept `elementFromPoint()`)
- `SidebarTab.ts`: Remove `force: true` from toast dismissal (`.catch()`
already handles failures)
- `nodeHelp.spec.ts`: Remove `force: true` from info button click
(preceding `toBeVisible()` assertion is sufficient)
### Rewrites (3 violations)
- `integerWidget.spec.ts`: Replace force-clicking disabled buttons with
`toBeDisabled()` assertions
- `Topbar.ts`: Replace force-click with `waitFor({ state: 'visible' })`
after hover
### Canvas coordinate clicks (9 violations)
- `litegraphUtils.ts`: Convert `NodeReference.click()` and
`navigateIntoSubgraph()` to use
`canvasOps.mouseClickAt()`/`mouseDblclickAt()`
- `subgraphPromotion.spec.ts`: Convert 3 right-click canvas calls to
`canvasOps.mouseClickAt()`
- `selectionToolboxSubmenus.spec.ts`: Convert 1 canvas dismiss-click to
`canvasOps.mouseClickAt()`
## Rationale
The original `force: true` usages were added defensively based on
incorrect assumptions about the `z-999 pointer-events: none` splitter
overlay intercepting Playwright's actionability checks. In reality,
`elementFromPoint()` skips elements with `pointer-events: none`, so the
overlay is transparent to Playwright's hit-test.
For canvas coordinate clicks, `force: true` on a locator does not tunnel
through DOM overlays — it only skips Playwright's preflight checks.
`page.mouse.click()` is the correct API for coordinate-based canvas
interactions.
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-11164-fix-enable-playwright-no-force-option-lint-rule-33f6d73d365081e78601c6114121d272)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Amp <amp@ampcode.com>
262 lines
8.1 KiB
TypeScript
262 lines
8.1 KiB
TypeScript
import type { Locator } from '@playwright/test'
|
|
|
|
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '@e2e/fixtures/ComfyPage'
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import type { NodeReference } from '@e2e/fixtures/utils/litegraphUtils'
|
|
|
|
const BYPASS_CLASS = /before:bg-bypass\/60/
|
|
|
|
function getNodeWrapper(comfyPage: ComfyPage, nodeTitle: string): Locator {
|
|
return comfyPage.page
|
|
.locator('[data-node-id]')
|
|
.filter({ hasText: nodeTitle })
|
|
.getByTestId('node-inner-wrapper')
|
|
}
|
|
|
|
async function selectNodeWithPan(comfyPage: ComfyPage, nodeRef: NodeReference) {
|
|
const nodePos = await nodeRef.getPosition()
|
|
await comfyPage.page.evaluate((pos) => {
|
|
const canvas = window.app!.canvas
|
|
canvas.ds.offset[0] = -pos.x + canvas.canvas.width / 2
|
|
canvas.ds.offset[1] = -pos.y + canvas.canvas.height / 2 + 100
|
|
canvas.setDirty(true, true)
|
|
}, nodePos)
|
|
await comfyPage.nextFrame()
|
|
await nodeRef.click('title')
|
|
}
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
})
|
|
|
|
test.describe('Selection Toolbox - Button Actions', { tag: '@ui' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.Canvas.SelectionToolbox', true)
|
|
await comfyPage.workflow.loadWorkflow('nodes/single_ksampler')
|
|
await comfyPage.nextFrame()
|
|
})
|
|
|
|
test('delete button removes selected node', async ({ comfyPage }) => {
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
const initialCount = await comfyPage.page.evaluate(
|
|
() => window.app!.graph!._nodes.length
|
|
)
|
|
|
|
const deleteButton = comfyPage.page.getByTestId('delete-button')
|
|
await expect(deleteButton).toBeVisible()
|
|
await deleteButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() => window.app!.graph!._nodes.length)
|
|
)
|
|
.toBe(initialCount - 1)
|
|
})
|
|
|
|
test('info button opens properties panel', async ({ comfyPage }) => {
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
const infoButton = comfyPage.page.getByTestId('info-button')
|
|
await expect(infoButton).toBeVisible()
|
|
await infoButton.click()
|
|
await expect(comfyPage.page.getByTestId('properties-panel')).toBeVisible()
|
|
})
|
|
|
|
test('convert-to-subgraph button visible with multi-select', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.nodeOps.selectNodes(['KSampler', 'Empty Latent Image'])
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect(
|
|
comfyPage.page.getByTestId('convert-to-subgraph-button')
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('delete button removes multiple selected nodes', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
await comfyPage.nodeOps.selectNodes(['KSampler', 'Empty Latent Image'])
|
|
await comfyPage.nextFrame()
|
|
|
|
const initialCount = await comfyPage.page.evaluate(
|
|
() => window.app!.graph!._nodes.length
|
|
)
|
|
|
|
const deleteButton = comfyPage.page.getByTestId('delete-button')
|
|
await expect(deleteButton).toBeVisible()
|
|
await deleteButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() => window.app!.graph!._nodes.length)
|
|
)
|
|
.toBe(initialCount - 2)
|
|
})
|
|
|
|
test('bypass button toggles bypass on single node', async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true)
|
|
await comfyPage.workflow.loadWorkflow('nodes/single_ksampler')
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(false)
|
|
|
|
const bypassButton = comfyPage.page.getByTestId('bypass-button')
|
|
await expect(bypassButton).toBeVisible()
|
|
await bypassButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(true)
|
|
await expect(getNodeWrapper(comfyPage, 'KSampler')).toHaveClass(
|
|
BYPASS_CLASS
|
|
)
|
|
|
|
await bypassButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect.poll(() => nodeRef.isBypassed()).toBe(false)
|
|
await expect(getNodeWrapper(comfyPage, 'KSampler')).not.toHaveClass(
|
|
BYPASS_CLASS
|
|
)
|
|
})
|
|
|
|
test('convert-to-subgraph button converts node to subgraph', async ({
|
|
comfyPage
|
|
}) => {
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
const convertButton = comfyPage.page.getByTestId(
|
|
'convert-to-subgraph-button'
|
|
)
|
|
await expect(convertButton).toBeVisible()
|
|
await convertButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
// KSampler should be gone, replaced by a subgraph node
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))
|
|
.toHaveLength(0)
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeRefsByTitle('New Subgraph'))
|
|
.toHaveLength(1)
|
|
})
|
|
|
|
test('convert-to-subgraph button converts multiple nodes', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
await comfyPage.nodeOps.selectNodes(['KSampler', 'Empty Latent Image'])
|
|
await comfyPage.nextFrame()
|
|
|
|
const convertButton = comfyPage.page.getByTestId(
|
|
'convert-to-subgraph-button'
|
|
)
|
|
await expect(convertButton).toBeVisible()
|
|
await convertButton.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getNodeRefsByTitle('New Subgraph'))
|
|
.toHaveLength(1)
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount())
|
|
.toBe(initialCount - 1)
|
|
})
|
|
|
|
test('frame nodes button creates group from multiple selected nodes', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
const initialGroupCount = await comfyPage.page.evaluate(
|
|
() => window.app!.graph.groups.length
|
|
)
|
|
|
|
await comfyPage.nodeOps.selectNodes(['KSampler', 'Empty Latent Image'])
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect(
|
|
comfyPage.selectionToolbox.getByRole('button', {
|
|
name: /Frame Nodes/i
|
|
})
|
|
).toBeVisible()
|
|
await comfyPage.selectionToolbox
|
|
.getByRole('button', { name: /Frame Nodes/i })
|
|
.click()
|
|
await comfyPage.nextFrame()
|
|
|
|
await expect
|
|
.poll(() =>
|
|
comfyPage.page.evaluate(() => window.app!.graph.groups.length)
|
|
)
|
|
.toBe(initialGroupCount + 1)
|
|
})
|
|
|
|
test('frame nodes button is not visible for single selection', async ({
|
|
comfyPage
|
|
}) => {
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
const frameButton = comfyPage.page.getByRole('button', {
|
|
name: /Frame Nodes/i
|
|
})
|
|
await expect(frameButton).toBeHidden()
|
|
})
|
|
|
|
test('execute button visible when output node selected', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.nextFrame()
|
|
|
|
// Select the SaveImage node by panning to it
|
|
const saveImageRef = (
|
|
await comfyPage.nodeOps.getNodeRefsByTitle('Save Image')
|
|
)[0]
|
|
await selectNodeWithPan(comfyPage, saveImageRef)
|
|
|
|
const executeButton = comfyPage.page.getByRole('button', {
|
|
name: /Execute to selected output nodes/i
|
|
})
|
|
await expect(executeButton).toBeVisible()
|
|
})
|
|
|
|
test('execute button not visible when non-output node selected', async ({
|
|
comfyPage
|
|
}) => {
|
|
const nodeRef = (await comfyPage.nodeOps.getNodeRefsByTitle('KSampler'))[0]
|
|
await selectNodeWithPan(comfyPage, nodeRef)
|
|
|
|
const executeButton = comfyPage.page.getByRole('button', {
|
|
name: /Execute to selected output nodes/i
|
|
})
|
|
await expect(executeButton).toBeHidden()
|
|
})
|
|
})
|