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>
151 lines
4.7 KiB
TypeScript
151 lines
4.7 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Workflow tabs', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.Workflow.WorkflowTabsPosition',
|
|
'Topbar'
|
|
)
|
|
await comfyPage.setup()
|
|
})
|
|
|
|
test('Default workflow tab is visible on load', async ({ comfyPage }) => {
|
|
await expect
|
|
.poll(() => comfyPage.menu.topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Creating a new workflow adds a tab', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual(
|
|
expect.arrayContaining([
|
|
expect.stringContaining('Unsaved Workflow (2)')
|
|
])
|
|
)
|
|
})
|
|
|
|
test('Switching tabs changes active workflow', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await expect(topbar.getActiveTab()).toContainText('Unsaved Workflow (2)')
|
|
|
|
await topbar.getTab(0).click()
|
|
await expect(topbar.getActiveTab()).toContainText('Unsaved Workflow')
|
|
await expect(topbar.getActiveTab()).not.toContainText('(2)')
|
|
})
|
|
|
|
test('Closing a tab removes it', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await topbar.closeWorkflowTab('Unsaved Workflow (2)')
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Right-clicking a tab shows context menu', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.getTab(0).click({ button: 'right' })
|
|
|
|
// Reka UI ContextMenuContent gets data-state="open" when active
|
|
const contextMenu = comfyPage.page
|
|
.getByRole('menu')
|
|
.and(comfyPage.page.locator('[data-state="open"]'))
|
|
await expect(contextMenu).toBeVisible()
|
|
|
|
await expect(
|
|
contextMenu.getByRole('menuitem', { name: /Close Tab/i }).first()
|
|
).toBeVisible()
|
|
await expect(
|
|
contextMenu.getByRole('menuitem', { name: /Save/i }).first()
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('Context menu Close Tab action removes the tab', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
|
|
await topbar.getTab(1).click({ button: 'right' })
|
|
const contextMenu = comfyPage.page
|
|
.getByRole('menu')
|
|
.and(comfyPage.page.locator('[data-state="open"]'))
|
|
await expect(contextMenu).toBeVisible()
|
|
|
|
await contextMenu
|
|
.getByRole('menuitem', { name: /Close Tab/i })
|
|
.first()
|
|
.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
})
|
|
|
|
test('Closing the last tab creates a new default workflow', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(1)
|
|
|
|
await topbar.closeWorkflowTab('Unsaved Workflow')
|
|
await expect
|
|
.poll(() => topbar.getTabNames())
|
|
.toEqual([expect.stringContaining('Unsaved Workflow')])
|
|
})
|
|
|
|
test('Modified workflow shows unsaved indicator', async ({ comfyPage }) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
// Modify the graph via litegraph API to trigger unsaved state
|
|
await comfyPage.page.evaluate(() => {
|
|
const graph = window.app?.graph
|
|
const node = window.LiteGraph?.createNode('Note')
|
|
if (graph && node) graph.add(node)
|
|
})
|
|
|
|
// WorkflowTab renders "•" when the workflow has unsaved changes
|
|
const activeTab = topbar.getActiveTab()
|
|
await expect(activeTab.locator('text=•')).toBeVisible()
|
|
})
|
|
|
|
test('Multiple tabs can be created, switched, and closed', async ({
|
|
comfyPage
|
|
}) => {
|
|
const topbar = comfyPage.menu.topbar
|
|
|
|
// Create 2 additional tabs (3 total)
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
await topbar.newWorkflowButton.click()
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(3)
|
|
|
|
// Switch to first tab
|
|
await topbar.getTab(0).click()
|
|
await expect
|
|
.poll(() => topbar.getActiveTabName())
|
|
.toContain('Unsaved Workflow')
|
|
|
|
// Close the middle tab
|
|
await topbar.closeWorkflowTab('Unsaved Workflow (2)')
|
|
await expect.poll(() => topbar.getTabNames()).toHaveLength(2)
|
|
})
|
|
})
|