From be427c325b680e9bada63d3ce5355120620e4ff7 Mon Sep 17 00:00:00 2001 From: Alexander Brown <448862+DrJKL@users.noreply.github.com> Date: Sat, 31 Jan 2026 14:39:22 -0800 Subject: [PATCH] refactor(tests): use DefaultGraphPositions constants for raw coordinates - Replace hardcoded coordinates with DefaultGraphPositions references - Fix y-coordinate inconsistency (625 vs 645) in emptyLatentWidgetClick usage Amp-Thread-ID: https://ampcode.com/threads/T-019c161a-ed63-7545-bbd0-655efec143c4 Co-authored-by: Amp --- browser_tests/fixtures/ComfyPage.ts | 5 ++++- browser_tests/tests/copyPaste.spec.ts | 8 ++++++-- browser_tests/tests/dialog.spec.ts | 5 ++++- browser_tests/tests/rightClickMenu.spec.ts | 23 +++++++++++----------- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 0d83d20f2..24d61bfc7 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -591,7 +591,10 @@ export class ComfyPage { } async dragNode2() { - await this.canvasOps.dragAndDrop({ x: 622, y: 400 }, { x: 622, y: 300 }) + await this.canvasOps.dragAndDrop(DefaultGraphPositions.textEncodeNode2, { + x: DefaultGraphPositions.textEncodeNode2.x, + y: 300 + }) await this.nextFrame() } diff --git a/browser_tests/tests/copyPaste.spec.ts b/browser_tests/tests/copyPaste.spec.ts index 89c494b27..4481d00c0 100644 --- a/browser_tests/tests/copyPaste.spec.ts +++ b/browser_tests/tests/copyPaste.spec.ts @@ -9,7 +9,9 @@ test.beforeEach(async ({ comfyPage }) => { test.describe('Copy Paste', { tag: ['@screenshot', '@workflow'] }, () => { test('Can copy and paste node', async ({ comfyPage }) => { - await comfyPage.canvas.click({ position: { x: 724, y: 625 } }) + await comfyPage.canvas.click({ + position: DefaultGraphPositions.emptyLatentWidgetClick + }) await comfyPage.page.mouse.move(10, 10) await comfyPage.nextFrame() await comfyPage.clipboard.copy() @@ -68,7 +70,9 @@ test.describe('Copy Paste', { tag: ['@screenshot', '@workflow'] }, () => { test('Paste in text area with node previously copied', async ({ comfyPage }) => { - await comfyPage.canvas.click({ position: { x: 724, y: 625 } }) + await comfyPage.canvas.click({ + position: DefaultGraphPositions.emptyLatentWidgetClick + }) await comfyPage.page.mouse.move(10, 10) await comfyPage.nextFrame() await comfyPage.clipboard.copy(null) diff --git a/browser_tests/tests/dialog.spec.ts b/browser_tests/tests/dialog.spec.ts index a14e1bcee..1d426c9fa 100644 --- a/browser_tests/tests/dialog.spec.ts +++ b/browser_tests/tests/dialog.spec.ts @@ -3,6 +3,7 @@ import { expect } from '@playwright/test' import type { Keybinding } from '../../src/platform/keybindings' import { comfyPageFixture as test } from '../fixtures/ComfyPage' +import { DefaultGraphPositions } from '../fixtures/constants/defaultGraphPositions' test.beforeEach(async ({ comfyPage }) => { await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled') @@ -376,7 +377,9 @@ test.describe('Signin dialog', () => { comfyPage }) => { const nodeNum = (await comfyPage.nodeOps.getNodes()).length - await comfyPage.canvas.click({ position: { x: 724, y: 625 } }) + await comfyPage.canvas.click({ + position: DefaultGraphPositions.emptyLatentWidgetClick + }) await comfyPage.page.mouse.move(10, 10) await comfyPage.nextFrame() await comfyPage.clipboard.copy() diff --git a/browser_tests/tests/rightClickMenu.spec.ts b/browser_tests/tests/rightClickMenu.spec.ts index 757b131f4..a07ac261e 100644 --- a/browser_tests/tests/rightClickMenu.spec.ts +++ b/browser_tests/tests/rightClickMenu.spec.ts @@ -2,6 +2,7 @@ import { expect } from '@playwright/test' import { NodeBadgeMode } from '../../src/types/nodeSource' import { comfyPageFixture as test } from '../fixtures/ComfyPage' +import { DefaultGraphPositions } from '../fixtures/constants/defaultGraphPositions' test.beforeEach(async ({ comfyPage }) => { await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled') @@ -55,7 +56,7 @@ test.describe( test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { test('Can open properties panel', async ({ comfyPage }) => { await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -70,7 +71,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { test('Can collapse', async ({ comfyPage }) => { await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -94,7 +95,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { ) await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -108,7 +109,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { test('Can bypass', async ({ comfyPage }) => { await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -123,7 +124,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { test('Can pin and unpin', async ({ comfyPage }) => { await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -138,7 +139,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { await comfyPage.canvasOps.dragAndDrop(titlePos, { x: 16, y: 16 }) await expect(comfyPage.canvas).toHaveScreenshot('node-pinned.png') await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -149,7 +150,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { await comfyPage.page.click('.litemenu-entry:has-text("Unpin")') await comfyPage.nextFrame() await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -161,7 +162,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { test('Can move after unpin', async ({ comfyPage }) => { await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -169,7 +170,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { await comfyPage.page.click('.litemenu-entry:has-text("Pin")') await comfyPage.nextFrame() await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -190,7 +191,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { await comfyPage.nodeOps.selectNodes(['CLIP Text Encode (Prompt)']) await comfyPage.page.keyboard.down('Control') await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10) @@ -200,7 +201,7 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => { await comfyPage.nextFrame() await expect(comfyPage.canvas).toHaveScreenshot('selected-nodes-pinned.png') await comfyPage.canvas.click({ - position: { x: 724, y: 645 }, + position: DefaultGraphPositions.emptyLatentWidgetClick, button: 'right' }) await comfyPage.page.mouse.move(10, 10)