mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
## Summary Changes the Vue node test fixture to not rely on Litegraph internal objects (which should eventually be fully decoupled from Vue nodes) and instead interact with nodes using black-box approach that emulates user actions (preferred appraoch for e2e tests). ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6033-refactor-adjust-Vue-node-fixtures-to-not-be-coupled-to-Litegraph-28a6d73d3650817b8152d27dc4fe0017) by [Unito](https://www.unito.io)
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
import type { Locator } from '@playwright/test'
|
|
|
|
/** 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 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 expect(input).toBeVisible()
|
|
await input.fill(value)
|
|
await input.press('Enter')
|
|
}
|
|
|
|
async cancelTitleEdit(): Promise<void> {
|
|
await this.header.dblclick()
|
|
const input = this.titleInput
|
|
await expect(input).toBeVisible()
|
|
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()
|
|
}
|
|
}
|