mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Complete the @e2e/ path alias migration started in #10735 by converting all 354 remaining relative imports and adding a lint rule to prevent backsliding. ## Changes - **What**: Migrate all relative imports in browser_tests/ to use `@e2e/` (intra-directory) and `@/` (src/ imports) path aliases. Add `no-restricted-imports` ESLint rule banning `./` and `../` imports in `browser_tests/**/*.ts`. Suppress pre-existing oxlint `no-eval` and `no-console` warnings exposed by touching those files. ## Review Focus - ESLint flat-config merging: the `@playwright/test` ban and relative-import ban are in two separate blocks to avoid last-match-wins collision with the `useI18n`/`useVirtualList` blocks higher in the config. - The `['./**', '../**']` glob patterns (not `['./*', '../*']`) are needed to catch multi-level relative paths like `../../../src/foo`. Follows up on #10735 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10958-test-migrate-browser_tests-to-e2e-path-alias-and-add-lint-rule-33c6d73d365081649d1be771eac986fd) by [Unito](https://www.unito.io) Co-authored-by: Amp <amp@ampcode.com>
132 lines
3.9 KiB
TypeScript
132 lines
3.9 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import type { ComfyApp } from '@/scripts/app'
|
|
import { NodeBadgeMode } from '@/types/nodeSource'
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Node Badge', { tag: ['@screenshot', '@smoke', '@node'] }, () => {
|
|
test('Can add badge', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge.png')
|
|
})
|
|
|
|
test('Can add multiple badges', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [
|
|
new LGraphBadge({ text: 'Test Badge 1' }),
|
|
new LGraphBadge({ text: 'Test Badge 2' })
|
|
]
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-multiple.png')
|
|
})
|
|
|
|
test('Can add badge left-side', async ({ comfyPage }) => {
|
|
await comfyPage.page.evaluate(() => {
|
|
const LGraphBadge = window.LGraphBadge!
|
|
const app = window.app as ComfyApp
|
|
const graph = app.graph
|
|
const nodes = graph.nodes
|
|
|
|
for (const node of nodes) {
|
|
node.badges = [new LGraphBadge({ text: 'Test Badge' })]
|
|
// @ts-expect-error - Enum value
|
|
node.badgePosition = 'top-left'
|
|
}
|
|
|
|
graph.setDirtyCanvas(true, true)
|
|
})
|
|
|
|
await expect(comfyPage.canvas).toHaveScreenshot('node-badge-left.png')
|
|
})
|
|
})
|
|
|
|
test.describe(
|
|
'Node source badge',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
Object.values(NodeBadgeMode).forEach(async (mode) => {
|
|
test(`Shows node badges (${mode})`, async ({ comfyPage }) => {
|
|
// Execution error workflow has both custom node and core node.
|
|
await comfyPage.workflow.loadWorkflow('nodes/execution_error')
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeSourceBadgeMode',
|
|
mode
|
|
)
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
mode
|
|
)
|
|
await comfyPage.nextFrame()
|
|
await comfyPage.canvasOps.resetView()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
`node-badge-${mode}.png`
|
|
)
|
|
})
|
|
})
|
|
}
|
|
)
|
|
|
|
test.describe(
|
|
'Node badge color',
|
|
{ tag: ['@screenshot', '@smoke', '@node'] },
|
|
() => {
|
|
test('Can show node badge with unknown color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'unknown')
|
|
await comfyPage.nextFrame()
|
|
// Click empty space to trigger canvas re-render.
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-unknown-color-palette.png'
|
|
)
|
|
})
|
|
|
|
test('Can show node badge with light color palette', async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.settings.setSetting(
|
|
'Comfy.NodeBadge.NodeIdBadgeMode',
|
|
NodeBadgeMode.ShowAll
|
|
)
|
|
await comfyPage.settings.setSetting('Comfy.ColorPalette', 'light')
|
|
await comfyPage.nextFrame()
|
|
// Click empty space to trigger canvas re-render.
|
|
await comfyPage.canvasOps.clickEmptySpace()
|
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
|
'node-badge-light-color-palette.png'
|
|
)
|
|
})
|
|
}
|
|
)
|