mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-11 08:20:53 +00:00
## Summary
Internalize `nextFrame()` calls into fixture/helper methods so spec
authors don't need to remember to call it after common operations.
`nextFrame()` waits for one `requestAnimationFrame` (~16ms) — an extra
call is always safe, making this a low-risk refactor.
## Changes
### Phase 1: `SettingsHelper.setSetting()`
`setSetting()` now calls `nextFrame()` internally. Removed 15 redundant
calls across 7 files.
### Phase 2: `CommandHelper.executeCommand()`
`executeCommand()` now calls `nextFrame()` internally. Removed 15
redundant calls across 7 files, including the now-redundant call in
`AppModeHelper.toggleAppMode()`.
### Phase 3: `WorkflowHelper.loadGraphData()`
New helper wraps `page.evaluate(loadGraphData)` + `nextFrame()`.
Migrated `SubgraphHelper.serializeAndReload()` and `groupNode.spec.ts`.
### Phase 4: `NodeReference` cleanup
Removed redundant `nextFrame()` from `copy()`, `convertToGroupNode()`,
`resizeNode()`, `dragTextEncodeNode2()`, and
`convertDefaultKSamplerToSubgraph()`. Removed 6 spec-level calls after
`node.click('title')`.
### Phase 5: `KeyboardHelper.press()` and `delete()`
New convenience methods that press a key and wait one frame. Converted
40 `canvas.press(key)` + `nextFrame()` pairs across 13 spec files.
### Phase 6: `ComfyPage.expectScreenshot()`
New helper combines `nextFrame()` + `toHaveScreenshot()`. Converted 45
pairs across 12 spec files.
## Total impact
- **~130 redundant `nextFrame()` calls eliminated** across ~35
spec/helper files
- **3 new helper methods** added (`loadGraphData`, `press`/`delete`,
`expectScreenshot`)
- **2 existing methods** enhanced (`setSetting`, `executeCommand`)
## What was NOT changed
- `performance.spec.ts` frame-counting loops (intentional)
- `ComfyMouse.ts` / `CanvasHelper.ts` (already internalized)
- `SubgraphHelper.packAllInteriorNodes()` (deliberate orchestration)
- Builder helpers (already internalized)
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-11166-refactor-internalize-nextFrame-into-fixture-helper-methods-33f6d73d3650817bb5f6fb46e396085e)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Amp <amp@ampcode.com>
184 lines
6.0 KiB
TypeScript
184 lines
6.0 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { mockSystemStats } from '@e2e/fixtures/data/systemStats'
|
|
|
|
const MOCK_COMFYUI_VERSION = '9.99.0-e2e-test'
|
|
|
|
test.describe('Settings dialog', { tag: '@ui' }, () => {
|
|
test('About panel renders mocked version from server', async ({
|
|
comfyPage
|
|
}) => {
|
|
const stats = {
|
|
...mockSystemStats,
|
|
system: {
|
|
...mockSystemStats.system,
|
|
comfyui_version: MOCK_COMFYUI_VERSION
|
|
}
|
|
}
|
|
await comfyPage.page.route('**/system_stats**', async (route) => {
|
|
await route.fulfill({ json: stats })
|
|
})
|
|
await comfyPage.setup()
|
|
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
await dialog.goToAboutPanel()
|
|
|
|
const aboutPanel = comfyPage.page.getByTestId('about-panel')
|
|
await expect(aboutPanel).toBeVisible()
|
|
await expect(aboutPanel).toContainText(MOCK_COMFYUI_VERSION)
|
|
await expect(aboutPanel).toContainText('ComfyUI_frontend')
|
|
})
|
|
|
|
test('Toggling a boolean setting through UI persists the value', async ({
|
|
comfyPage
|
|
}) => {
|
|
const settingId = 'Comfy.Validation.Workflows'
|
|
const initialValue = await comfyPage.settings.getSetting<boolean>(settingId)
|
|
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
|
|
try {
|
|
await dialog.searchBox.fill('Validate workflows')
|
|
const settingRow = dialog.root.locator(`[data-setting-id="${settingId}"]`)
|
|
await expect(settingRow).toBeVisible()
|
|
|
|
await settingRow.locator('.p-toggleswitch').click()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.settings.getSetting<boolean>(settingId))
|
|
.toBe(!initialValue)
|
|
} finally {
|
|
await comfyPage.settings.setSetting(settingId, initialValue)
|
|
}
|
|
})
|
|
|
|
test('Can be closed via close button', async ({ comfyPage }) => {
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
await expect(dialog.root).toBeVisible()
|
|
|
|
await dialog.close()
|
|
await expect(dialog.root).toBeHidden()
|
|
})
|
|
|
|
test('Escape key closes dialog', async ({ comfyPage }) => {
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
await expect(dialog.root).toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Escape')
|
|
await expect(dialog.root).toBeHidden()
|
|
})
|
|
|
|
test('Search filters settings list', async ({ comfyPage }) => {
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
|
|
const settingItems = dialog.root.locator('[data-setting-id]')
|
|
const countBeforeSearch = await settingItems.count()
|
|
|
|
await dialog.searchBox.fill('Validate workflows')
|
|
await expect
|
|
.poll(() => settingItems.count())
|
|
.toBeLessThan(countBeforeSearch)
|
|
})
|
|
|
|
test('Search can be cleared to restore all settings', async ({
|
|
comfyPage
|
|
}) => {
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
|
|
const settingItems = dialog.root.locator('[data-setting-id]')
|
|
const countBeforeSearch = await settingItems.count()
|
|
|
|
await dialog.searchBox.fill('Validate workflows')
|
|
await expect
|
|
.poll(() => settingItems.count())
|
|
.toBeLessThan(countBeforeSearch)
|
|
|
|
await dialog.searchBox.clear()
|
|
await expect.poll(() => settingItems.count()).toBe(countBeforeSearch)
|
|
})
|
|
|
|
test('Category navigation changes content area', async ({ comfyPage }) => {
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
|
|
const firstCategory = dialog.categories.first()
|
|
const firstCategoryName = await firstCategory.textContent()
|
|
await firstCategory.click()
|
|
const firstContent = await dialog.contentArea.textContent()
|
|
|
|
// Find a different category to click
|
|
const categoryCount = await dialog.categories.count()
|
|
let switched = false
|
|
for (let i = 1; i < categoryCount; i++) {
|
|
const cat = dialog.categories.nth(i)
|
|
const catName = await cat.textContent()
|
|
if (catName !== firstCategoryName) {
|
|
await cat.click()
|
|
await expect
|
|
.poll(() => dialog.contentArea.textContent())
|
|
.not.toBe(firstContent)
|
|
switched = true
|
|
break
|
|
}
|
|
}
|
|
expect(switched).toBe(true)
|
|
})
|
|
|
|
test('Dropdown setting can be changed and persists', async ({
|
|
comfyPage
|
|
}) => {
|
|
const settingId = 'Comfy.UseNewMenu'
|
|
const initialValue = await comfyPage.settings.getSetting<string>(settingId)
|
|
|
|
const dialog = comfyPage.settingDialog
|
|
await dialog.open()
|
|
|
|
try {
|
|
await dialog.searchBox.fill('Use new menu')
|
|
const settingRow = dialog.root.locator(`[data-setting-id="${settingId}"]`)
|
|
await expect(settingRow).toBeVisible()
|
|
|
|
// Wait for the search filter to fully settle — PrimeVue re-renders
|
|
// the entire settings list after typing, and the combobox element is
|
|
// replaced during re-render. Wait until the filtered list stabilises
|
|
// before interacting with the combobox.
|
|
const settingItems = dialog.root.locator('[data-setting-id]')
|
|
await expect
|
|
.poll(() => settingItems.count(), { timeout: 5000 })
|
|
.toBeLessThanOrEqual(5)
|
|
|
|
const select = settingRow.getByRole('combobox')
|
|
await expect(select).toBeVisible()
|
|
await expect(select).toBeEnabled()
|
|
|
|
// Open the dropdown via its combobox role and verify it expanded.
|
|
// Retry because the PrimeVue Select may still re-render after the
|
|
// filter settles, causing the first click to land on a stale element.
|
|
await expect(async () => {
|
|
const expanded = await select.getAttribute('aria-expanded')
|
|
if (expanded !== 'true') await select.click()
|
|
await expect(select).toHaveAttribute('aria-expanded', 'true')
|
|
}).toPass({ timeout: 10_000 })
|
|
|
|
// Pick the option that is not the current value
|
|
const targetValue = initialValue === 'Top' ? 'Disabled' : 'Top'
|
|
await comfyPage.page
|
|
.getByRole('option', { name: targetValue, exact: true })
|
|
.click()
|
|
|
|
await expect
|
|
.poll(() => comfyPage.settings.getSetting<string>(settingId))
|
|
.toBe(targetValue)
|
|
} finally {
|
|
await comfyPage.settings.setSetting(settingId, initialValue)
|
|
}
|
|
})
|
|
})
|