mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Add eslint-plugin-playwright as an oxlint JS plugin scoped to browser_tests/, enforcing Playwright best practices at lint time. ## Changes - **What**: Configure eslint-plugin-playwright@2.10.1 via oxlint's alpha `jsPlugins` field (`.oxlintrc.json` override scoped to `browser_tests/**/*.ts`). 18 recommended rules + `prefer-native-locators` + `require-to-pass-timeout` at error severity. All 173 initial violations resolved (config, auto-fix, manual fixes). `no-force-option` set to off — 28 violations need triage (canvas overlay workarounds vs unnecessary force) in a dedicated PR. - **Dependencies**: `eslint-plugin-playwright@^2.10.1` (devDependency, required by oxlint jsPlugins at runtime) ## Review Focus - `.oxlintrc.json` override structure — this is the first use of oxlint's JS plugins alpha feature in this repo - Manual fixes in spec files: `waitForSelector` → `locator.waitFor`, deprecated page methods → locator equivalents, `toPass()` timeout additions - Compound CSS selectors replaced with `.and()` (Playwright native locator composition) to avoid `prefer-native-locators` suppressions - Lint script changes in `package.json` to include `browser_tests/` in oxlint targets --------- Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com>
172 lines
5.5 KiB
TypeScript
172 lines
5.5 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()
|
|
|
|
// Open the dropdown via its combobox role and verify it expanded.
|
|
// Retry because the PrimeVue Select may re-render during search
|
|
// filtering, causing the first click to land on a stale element.
|
|
const select = settingRow.getByRole('combobox')
|
|
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: 5000 })
|
|
|
|
// 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)
|
|
}
|
|
})
|
|
})
|