mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +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>
135 lines
4.7 KiB
TypeScript
135 lines
4.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
|
|
test.describe('Minimap', { tag: '@canvas' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting('Comfy.Minimap.Visible', true)
|
|
await comfyPage.settings.setSetting('Comfy.Graph.CanvasMenu', true)
|
|
await comfyPage.workflow.loadWorkflow('default')
|
|
await comfyPage.page.waitForFunction(() => window.app && window.app.canvas)
|
|
})
|
|
|
|
test('Validate minimap is visible by default', async ({ comfyPage }) => {
|
|
const minimapContainer = comfyPage.page.locator('.litegraph-minimap')
|
|
|
|
await expect(minimapContainer).toBeVisible()
|
|
|
|
const minimapCanvas = minimapContainer.locator('.minimap-canvas')
|
|
await expect(minimapCanvas).toBeVisible()
|
|
|
|
const minimapViewport = minimapContainer.locator('.minimap-viewport')
|
|
await expect(minimapViewport).toBeVisible()
|
|
|
|
await expect(minimapContainer).toHaveCSS('position', 'relative')
|
|
|
|
// position and z-index validation moved to the parent container of the minimap
|
|
const minimapMainContainer = comfyPage.page.locator(
|
|
'.minimap-main-container'
|
|
)
|
|
await expect(minimapMainContainer).toHaveCSS('position', 'absolute')
|
|
await expect(minimapMainContainer).toHaveCSS('z-index', '1000')
|
|
})
|
|
|
|
test('Validate minimap toggle button state', async ({ comfyPage }) => {
|
|
const toggleButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.toggleMinimapButton
|
|
)
|
|
|
|
await expect(toggleButton).toBeVisible()
|
|
|
|
const minimapContainer = comfyPage.page.locator('.litegraph-minimap')
|
|
await expect(minimapContainer).toBeVisible()
|
|
})
|
|
|
|
test('Validate minimap can be toggled off and on', async ({ comfyPage }) => {
|
|
const minimapContainer = comfyPage.page.locator('.litegraph-minimap')
|
|
const toggleButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.toggleMinimapButton
|
|
)
|
|
|
|
await expect(minimapContainer).toBeVisible()
|
|
|
|
await toggleButton.click()
|
|
await expect(minimapContainer).toBeHidden()
|
|
|
|
await toggleButton.click()
|
|
await expect(minimapContainer).toBeVisible()
|
|
})
|
|
|
|
test('Validate minimap keyboard shortcut Alt+M', async ({ comfyPage }) => {
|
|
const minimapContainer = comfyPage.page.locator('.litegraph-minimap')
|
|
|
|
await expect(minimapContainer).toBeVisible()
|
|
|
|
await comfyPage.page.keyboard.press('Alt+KeyM')
|
|
await expect(minimapContainer).toBeHidden()
|
|
|
|
await comfyPage.page.keyboard.press('Alt+KeyM')
|
|
await expect(minimapContainer).toBeVisible()
|
|
})
|
|
|
|
test('Close button hides minimap', async ({ comfyPage }) => {
|
|
const minimap = comfyPage.page.locator('.litegraph-minimap')
|
|
await expect(minimap).toBeVisible()
|
|
|
|
await comfyPage.page.getByTestId(TestIds.canvas.closeMinimapButton).click()
|
|
await expect(minimap).toBeHidden()
|
|
|
|
const toggleButton = comfyPage.page.getByTestId(
|
|
TestIds.canvas.toggleMinimapButton
|
|
)
|
|
await expect(toggleButton).toBeVisible()
|
|
})
|
|
|
|
test(
|
|
'Panning canvas moves minimap viewport',
|
|
{ tag: '@screenshot' },
|
|
async ({ comfyPage }) => {
|
|
const minimap = comfyPage.page.locator('.litegraph-minimap')
|
|
await expect(minimap).toBeVisible()
|
|
|
|
await expect(minimap).toHaveScreenshot('minimap-before-pan.png')
|
|
|
|
await comfyPage.page.evaluate(() => {
|
|
const canvas = window.app!.canvas
|
|
canvas.ds.scale = 3
|
|
canvas.ds.offset[0] = -800
|
|
canvas.ds.offset[1] = -600
|
|
canvas.setDirty(true, true)
|
|
})
|
|
await comfyPage.nextFrame()
|
|
await expect(minimap).toHaveScreenshot('minimap-after-pan.png')
|
|
}
|
|
)
|
|
|
|
test(
|
|
'Viewport rectangle is visible and positioned within minimap',
|
|
{ tag: '@screenshot' },
|
|
async ({ comfyPage }) => {
|
|
const minimap = comfyPage.page.locator('.litegraph-minimap')
|
|
await expect(minimap).toBeVisible()
|
|
|
|
const viewport = minimap.locator('.minimap-viewport')
|
|
await expect(viewport).toBeVisible()
|
|
|
|
await expect(async () => {
|
|
const vb = await viewport.boundingBox()
|
|
const mb = await minimap.boundingBox()
|
|
expect(vb).toBeTruthy()
|
|
expect(mb).toBeTruthy()
|
|
expect(vb!.width).toBeGreaterThan(0)
|
|
expect(vb!.height).toBeGreaterThan(0)
|
|
expect(vb!.x).toBeGreaterThanOrEqual(mb!.x)
|
|
expect(vb!.y).toBeGreaterThanOrEqual(mb!.y)
|
|
expect(vb!.x + vb!.width).toBeLessThanOrEqual(mb!.x + mb!.width)
|
|
expect(vb!.y + vb!.height).toBeLessThanOrEqual(mb!.y + mb!.height)
|
|
}).toPass({ timeout: 5000 })
|
|
|
|
await expect(minimap).toHaveScreenshot('minimap-with-viewport.png')
|
|
}
|
|
)
|
|
})
|