mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
test: address review comments on multi-drag/duplicate e2e
- Replace non-existent getSelectedNodeCount with selectedNodes.toHaveCount - Scope title selectors via getNodeByTitle + data-testid=node-title to avoid strict-mode substring collisions (e.g. 'KSampler') - Add explicit return type on getHeaderPos - Use toHaveLength with assertion message for CLIPTextEncode precondition - Pin Node Duplication describe to legacy canvas by disabling Comfy.VueNodes
This commit is contained in:
@@ -181,9 +181,19 @@ test.describe('Node Interaction', () => {
|
||||
})
|
||||
|
||||
test.describe('Node Duplication', () => {
|
||||
test.beforeEach(async ({ comfyPage }) => {
|
||||
// Pin this suite to the legacy canvas path so Alt+drag exercises
|
||||
// LGraphCanvas, not the Vue node drag handler.
|
||||
await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', false)
|
||||
await comfyPage.nextFrame()
|
||||
})
|
||||
|
||||
test('Can duplicate a regular node via Alt+drag', async ({ comfyPage }) => {
|
||||
const before = await comfyPage.nodeOps.getNodeRefsByType('CLIPTextEncode')
|
||||
expect(before.length).toBe(2)
|
||||
expect(
|
||||
before,
|
||||
'Expected exactly 2 CLIPTextEncode nodes in default graph'
|
||||
).toHaveLength(2)
|
||||
|
||||
const target = before[0]
|
||||
const pos = await target.getPosition()
|
||||
|
||||
@@ -11,8 +11,15 @@ test.describe('Vue Node Moving', () => {
|
||||
await comfyPage.vueNodes.waitForNodes()
|
||||
})
|
||||
|
||||
const getHeaderPos = async (comfyPage: ComfyPage, title: string) => {
|
||||
const box = await comfyPage.page.getByText(title).boundingBox()
|
||||
const getHeaderPos = async (
|
||||
comfyPage: ComfyPage,
|
||||
title: string
|
||||
): Promise<{ x: number; y: number; width: number; height: number }> => {
|
||||
const box = await comfyPage.vueNodes
|
||||
.getNodeByTitle(title)
|
||||
.getByTestId('node-title')
|
||||
.first()
|
||||
.boundingBox()
|
||||
if (!box) throw new Error(`${title} header not found`)
|
||||
return box
|
||||
}
|
||||
@@ -98,16 +105,20 @@ test.describe('Vue Node Moving', () => {
|
||||
const dx = 120
|
||||
const dy = 80
|
||||
|
||||
const clickNodeTitleWithMeta = async (title: string) => {
|
||||
await comfyPage.vueNodes
|
||||
.getNodeByTitle(title)
|
||||
.locator('[data-testid="node-title"]')
|
||||
.first()
|
||||
.click({ modifiers: ['Meta'] })
|
||||
}
|
||||
|
||||
await comfyPage.page.keyboard.down('Meta')
|
||||
try {
|
||||
await comfyPage.page
|
||||
.getByText('Load Checkpoint')
|
||||
.click({ modifiers: ['Meta'] })
|
||||
await comfyPage.page.getByText('KSampler').click({ modifiers: ['Meta'] })
|
||||
await comfyPage.page
|
||||
.getByText('Empty Latent Image')
|
||||
.click({ modifiers: ['Meta'] })
|
||||
await expect.poll(() => comfyPage.vueNodes.getSelectedNodeCount()).toBe(3)
|
||||
await clickNodeTitleWithMeta('Load Checkpoint')
|
||||
await clickNodeTitleWithMeta('KSampler')
|
||||
await clickNodeTitleWithMeta('Empty Latent Image')
|
||||
await expect(comfyPage.vueNodes.selectedNodes).toHaveCount(3)
|
||||
|
||||
// Re-fetch drag source after clicks in case the header reflowed.
|
||||
const dragSrc = await getHeaderPos(comfyPage, 'Load Checkpoint')
|
||||
@@ -127,7 +138,7 @@ test.describe('Vue Node Moving', () => {
|
||||
await comfyPage.nextFrame()
|
||||
}
|
||||
|
||||
await expect.poll(() => comfyPage.vueNodes.getSelectedNodeCount()).toBe(3)
|
||||
await expect(comfyPage.vueNodes.selectedNodes).toHaveCount(3)
|
||||
|
||||
const checkpointAfter = await getHeaderPos(comfyPage, 'Load Checkpoint')
|
||||
const ksamplerAfter = await getHeaderPos(comfyPage, 'KSampler')
|
||||
|
||||
Reference in New Issue
Block a user