mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
## Summary Major refactoring of browser tests to improve reliability, maintainability, and type safety. ## Changes ### Test Infrastructure Decomposition - Decomposed `ComfyPage.ts` (~1000 lines) into focused helpers: - `CanvasHelper`, `DebugHelper`, `SubgraphHelper`, `NodeOperationsHelper` - `SettingsHelper`, `WorkflowHelper`, `ClipboardHelper`, `KeyboardHelper` - Created `ContextMenu` page object, `BaseDialog` base class, and `BottomPanel` page object - Extracted `DefaultGraphPositions` constants ### Locator Stability - Added `data-testid` attributes to Vue components (sidebar, dialogs, node library) - Created centralized `selectors.ts` with test ID constants - Replaced fragile CSS selectors (`.nth()`, `:nth-child()`) with `getByTestId`/`getByRole` ### Performance & Reliability - Removed `setTimeout` anti-patterns (replaced with `waitForFunction`) - Replaced `waitForTimeout` with retrying assertions - Replaced hardcoded coordinates with computed `NodeReference` positions - Enforced LF line endings for all text files ### Type Safety - Enabled `no-explicit-any` lint rule for browser_tests via oxlint - Purged `as any` casts from browser_tests - Added Window type augmentation for standardized window access - Added proper type annotations throughout ### Bug Fixes - Restored `ExtensionManager` API contract - Removed test-only settings from production schema - Fixed flaky selectors and missing test setup ## Testing - All browser tests pass - Typecheck passes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Overhauled browser E2E test infrastructure with many new helpers/fixtures, updated test APIs, and CI test container image bumped for consistency. * **Chores** * Standardized line endings and applied stricter lint rules for browser tests; workspace dependency version updated. * **Documentation** * Updated Playwright and TypeScript testing guidance and test-run commands. * **UI** * Added stable data-testids to multiple components to improve testability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
132 lines
3.9 KiB
TypeScript
132 lines
3.9 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyApp } from '../../src/scripts/app'
|
|
import { NodeBadgeMode } from '../../src/types/nodeSource'
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Node Badge', { tag: ['@screenshot', '@smoke', '@node'] }, () => {
|
|
test('Can add badge', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge.png')
|
|
})
|
|
|
|
test('Can add multiple badges', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [
|
|
new LGraphBadge({ text: 'Test Badge 1' }),
|
|
new LGraphBadge({ text: 'Test Badge 2' })
|
|
]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-multiple.png')
|
|
})
|
|
|
|
test('Can add badge left-side', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
// @ts-expect-error - Enum value
|
|
node.badgePosition = 'top-left'
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-left.png')
|
|
})
|
|
})
|
|
|
|
test.describe(
|
|
'Node source badge',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
Object.values(NodeBadgeMode).forEach(async (mode) => {
|
|
test(`Shows node badges (${mode})`, async ({ comfyPage }) => {
|
|
// Execution error workflow has both custom node and core node.
|
|
await comfyPage.workflow.loadWorkflow('nodes/execution_error')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeSourceBadgeMode',
|
|
mode
|
|
)
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
mode
|
|
)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.canvasOps.resetView()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
`node-badge-${mode}.png`
|
|
)
|
|
})
|
|
})
|
|
}
|
|
)
|
|
|
|
test.describe(
|
|
'Node badge color',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
test('Can show node badge with unknown color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'unknown')
|
|
await comfyPage.nextFrame()
|
|
// Click empty space to trigger canvas re-render.
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-unknown-color-palette.png'
|
|
)
|
|
})
|
|
|
|
test('Can show node badge with light color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'light')
|
|
await comfyPage.nextFrame()
|
|
// Click empty space to trigger canvas re-render.
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-light-color-palette.png'
|
|
)
|
|
})
|
|
}
|
|
)
|