mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-04 21:22:07 +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>
127 lines
4.1 KiB
TypeScript
127 lines
4.1 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
|
|
test.describe('Node library sidebar V2', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
|
|
await comfyPage.settings.setSetting('Comfy.NodeLibrary.NewDesign', true)
|
|
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
await tab.open()
|
|
})
|
|
|
|
test('Can switch between tabs', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
|
|
await tab.blueprintsTab.click()
|
|
await expect(tab.blueprintsTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'false')
|
|
|
|
await tab.allTab.click()
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.blueprintsTab).toHaveAttribute('aria-selected', 'false')
|
|
})
|
|
|
|
test('All tab displays node tree with folders', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.allTab).toHaveAttribute('aria-selected', 'true')
|
|
await expect(tab.getFolder('sampling')).toBeVisible()
|
|
})
|
|
|
|
test('Can expand folder and see nodes in All tab', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible()
|
|
})
|
|
|
|
test('Search filters nodes in All tab', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.getNode('KSampler (Advanced)')).not.toBeVisible()
|
|
|
|
await tab.searchInput.fill('KSampler')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible({
|
|
timeout: 5000
|
|
})
|
|
await expect(tab.getNode('CLIPLoader')).not.toBeVisible()
|
|
})
|
|
|
|
test('Drag node to canvas adds it', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible()
|
|
|
|
const initialCount = await comfyPage.nodeOps.getGraphNodesCount()
|
|
|
|
const canvasBoundingBox = await comfyPage.page
|
|
.locator('#graph-canvas')
|
|
.boundingBox()
|
|
expect(canvasBoundingBox).not.toBeNull()
|
|
const targetPosition = {
|
|
x: canvasBoundingBox!.x + canvasBoundingBox!.width / 2,
|
|
y: canvasBoundingBox!.y + canvasBoundingBox!.height / 2
|
|
}
|
|
|
|
const nodeLocator = tab.getNode('KSampler (Advanced)')
|
|
await nodeLocator.dragTo(comfyPage.page.locator('#graph-canvas'), {
|
|
targetPosition
|
|
})
|
|
|
|
await expect
|
|
.poll(() => comfyPage.nodeOps.getGraphNodesCount(), { timeout: 5000 })
|
|
.toBe(initialCount + 1)
|
|
})
|
|
|
|
test('Right-click node shows context menu with bookmark option', async ({
|
|
comfyPage
|
|
}) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.expandFolder('sampling')
|
|
const node = tab.getNode('KSampler (Advanced)')
|
|
await expect(node).toBeVisible()
|
|
|
|
await node.click({ button: 'right' })
|
|
|
|
const contextMenu = comfyPage.page.getByRole('menuitem', {
|
|
name: /Bookmark Node/
|
|
})
|
|
await expect(contextMenu).toBeVisible({ timeout: 3000 })
|
|
})
|
|
|
|
test('Search clear restores folder view', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await expect(tab.getFolder('sampling')).toBeVisible()
|
|
|
|
await tab.searchInput.fill('KSampler')
|
|
await expect(tab.getNode('KSampler (Advanced)')).toBeVisible({
|
|
timeout: 5000
|
|
})
|
|
|
|
await tab.searchInput.clear()
|
|
await tab.searchInput.press('Enter')
|
|
|
|
await expect(tab.getFolder('sampling')).toBeVisible({ timeout: 5000 })
|
|
})
|
|
|
|
test('Sort dropdown shows sorting options', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.nodeLibraryTabV2
|
|
|
|
await tab.sortButton.click()
|
|
|
|
// Reka UI DropdownMenuRadioItem renders with role="menuitemradio"
|
|
const options = comfyPage.page.getByRole('menuitemradio')
|
|
await expect(options.first()).toBeVisible({ timeout: 3000 })
|
|
await expect
|
|
.poll(() => options.count(), { timeout: 3000 })
|
|
.toBeGreaterThanOrEqual(2)
|
|
})
|
|
})
|