Files
ComfyUI_frontend/browser_tests/fixtures/utils/vueNodeFixtures.ts
Johnpaul 08e6852741 test: replace raw CSS selectors with TestIds in context menu spec
- Add pinIndicator, innerWrapper, titleEditorInput, mainImage to TestIds.node
- Add pinIndicator getter to VueNodeFixture
- Add data-testid to TitleEditor overlay via input-attrs
- Replace .lg-node-header with [data-testid^="node-header-"]
- Replace .p-contextmenu with comfyPage.contextMenu.primeVueMenu
- Replace .node-title-editor input with getByTestId(TestIds.node.titleEditorInput)
- Replace hardcoded PIN_INDICATOR with TestIds.node.pinIndicator
- Replace .image-preview img with TestIds.node.mainImage
- Use NodeLibrarySidebarTab fixture for node library interaction

Fixes #10750
Fixes #10749
2026-03-30 21:49:17 +01:00

72 lines
1.7 KiB
TypeScript

import type { Locator } from '@playwright/test'
import { TestIds } from '../selectors'
/** DOM-centric helper for a single Vue-rendered node on the canvas. */
export class VueNodeFixture {
constructor(private readonly locator: Locator) {}
get header(): Locator {
return this.locator.locator('[data-testid^="node-header-"]')
}
get title(): Locator {
return this.locator.locator('[data-testid="node-title"]')
}
get titleInput(): Locator {
return this.locator.locator('[data-testid="node-title-input"]')
}
get body(): Locator {
return this.locator.locator('[data-testid^="node-body-"]')
}
get pinIndicator(): Locator {
return this.locator.getByTestId(TestIds.node.pinIndicator)
}
get collapseButton(): Locator {
return this.locator.locator('[data-testid="node-collapse-button"]')
}
get collapseIcon(): Locator {
return this.collapseButton.locator('i')
}
get root(): Locator {
return this.locator
}
async getTitle(): Promise<string> {
return (await this.title.textContent()) ?? ''
}
async setTitle(value: string): Promise<void> {
await this.header.dblclick()
const input = this.titleInput
await input.waitFor({ state: 'visible' })
await input.fill(value)
await input.press('Enter')
}
async cancelTitleEdit(): Promise<void> {
await this.header.dblclick()
const input = this.titleInput
await input.waitFor({ state: 'visible' })
await input.press('Escape')
}
async toggleCollapse(): Promise<void> {
await this.collapseButton.click()
}
async getCollapseIconClass(): Promise<string> {
return (await this.collapseIcon.getAttribute('class')) ?? ''
}
boundingBox(): ReturnType<Locator['boundingBox']> {
return this.locator.boundingBox()
}
}