mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary - Adds Playwright E2E tests for the Node Library V2 sidebar tab (`Comfy.NodeLibrary.NewDesign: true`) - Adds `NodeLibrarySidebarTabV2` fixture class with V2-specific locators (search input, tab buttons, node cards) - Exposes `menu.nodeLibraryTabV2` on `ComfyPage` for test access - Tests cover: tab visibility, default tab selection, tab switching, folder expansion, search filtering, and sort button presence ## Test plan - [ ] Run `pnpm test:browser:local -- --grep "Node library sidebar V2"` against a running ComfyUI server with the V2 node library - [ ] Verify tests pass in CI Fixes #9079 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10798-test-add-E2E-tests-for-Node-Library-V2-sidebar-3356d73d36508185a11feaf95e32225b) by [Unito](https://www.unito.io) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
127 lines
4.1 KiB
TypeScript
127 lines
4.1 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '../../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)
|
|
})
|
|
})
|