mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +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>
211 lines
6.2 KiB
TypeScript
211 lines
6.2 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
|
|
|
|
test.describe('Bottom Panel Shortcuts', { tag: '@ui' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
})
|
|
|
|
test('should toggle shortcuts panel visibility', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
})
|
|
|
|
test('should display essentials shortcuts tab', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await expect(bottomPanel.shortcuts.subcategoryTitles.first()).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.keyBadges.first()).toBeVisible()
|
|
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Workflow' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Node' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Queue' })
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('should display view controls shortcuts tab', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await bottomPanel.shortcuts.viewControlsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await expect(bottomPanel.shortcuts.keyBadges.first()).toBeVisible()
|
|
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'View' })
|
|
).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('heading', { name: 'Panel Controls' })
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('should switch between shortcuts tabs', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await bottomPanel.shortcuts.viewControlsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
await expect(bottomPanel.shortcuts.essentialsTab).not.toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
|
|
await bottomPanel.shortcuts.essentialsTab.click()
|
|
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).not.toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should display formatted keyboard shortcuts', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
const keyBadges = bottomPanel.shortcuts.keyBadges
|
|
await keyBadges.first().waitFor({ state: 'visible' })
|
|
const count = await keyBadges.count()
|
|
expect(count).toBeGreaterThanOrEqual(1)
|
|
|
|
const badgeText = await keyBadges.allTextContents()
|
|
const hasModifiers = badgeText.some((text) =>
|
|
['Ctrl', 'Cmd', 'Shift', 'Alt'].includes(text)
|
|
)
|
|
expect(hasModifiers).toBeTruthy()
|
|
})
|
|
|
|
test('should maintain panel state when switching to terminal', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
|
|
await bottomPanel.toggleButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(
|
|
comfyPage.page.locator('[id*="tab_shortcuts-essentials"]')
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('should handle keyboard navigation', async ({ comfyPage }) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await bottomPanel.shortcuts.essentialsTab.focus()
|
|
|
|
await comfyPage.page.keyboard.press('ArrowRight')
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toBeFocused()
|
|
|
|
await comfyPage.page.keyboard.press('Enter')
|
|
|
|
await expect(bottomPanel.shortcuts.viewControlsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should close panel by clicking shortcuts button again', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
})
|
|
|
|
test('should display shortcuts in organized columns', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(
|
|
comfyPage.page.locator('[data-testid="shortcuts-columns"]')
|
|
).toBeVisible()
|
|
|
|
const subcategoryTitles = bottomPanel.shortcuts.subcategoryTitles
|
|
const titleCount = await subcategoryTitles.count()
|
|
expect(titleCount).toBeGreaterThanOrEqual(2)
|
|
})
|
|
|
|
test('should open shortcuts panel with Ctrl+Shift+K', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await expect(bottomPanel.root).not.toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Control+Shift+KeyK')
|
|
|
|
await expect(bottomPanel.root).toBeVisible()
|
|
await expect(bottomPanel.shortcuts.essentialsTab).toHaveAttribute(
|
|
'aria-selected',
|
|
'true'
|
|
)
|
|
})
|
|
|
|
test('should open settings dialog when clicking manage shortcuts button', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { bottomPanel } = comfyPage
|
|
|
|
await bottomPanel.keyboardShortcutsButton.click()
|
|
|
|
await expect(bottomPanel.shortcuts.manageButton).toBeVisible()
|
|
await bottomPanel.shortcuts.manageButton.click()
|
|
|
|
await expect(comfyPage.page.getByRole('dialog')).toBeVisible()
|
|
await expect(
|
|
comfyPage.page.getByRole('option', { name: 'Keybinding' })
|
|
).toBeVisible()
|
|
})
|
|
})
|