mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-19 20:09:42 +00:00
## Summary <!-- One sentence describing what changed and why. --> ## Changes - **What**: <!-- Core functionality added/modified --> - **Breaking**: <!-- Any breaking changes (if none, remove this line) --> - **Dependencies**: <!-- New dependencies (if none, remove this line) --> ## Review Focus <!-- Critical design decisions or edge cases that need attention --> <!-- If this PR fixes an issue, uncomment and update the line below --> <!-- Fixes #ISSUE_NUMBER --> ## Screenshots (if applicable) <!-- Add screenshots or video recording to help explain your changes --> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11612-test-add-tests-for-link-related-settings-34c6d73d36508145885bd017162e6fae) by [Unito](https://www.unito.io)
84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
import { expect } from '@playwright/test'
|
|
import type { Locator, Page } from '@playwright/test'
|
|
|
|
export class ContextMenu {
|
|
public readonly primeVueMenu: Locator
|
|
public readonly litegraphMenu: Locator
|
|
public readonly litegraphContextMenu: Locator
|
|
public readonly menuItems: Locator
|
|
|
|
constructor(public readonly page: Page) {
|
|
this.primeVueMenu = page.locator('.p-contextmenu, .p-menu')
|
|
this.litegraphMenu = page.locator('.litemenu')
|
|
this.litegraphContextMenu = page.locator('.litecontextmenu')
|
|
this.menuItems = page.locator('.p-menuitem, .litemenu-entry')
|
|
}
|
|
|
|
async clickMenuItem(name: string): Promise<void> {
|
|
await this.page.getByRole('menuitem', { name }).click()
|
|
}
|
|
|
|
async clickMenuItemExact(name: string): Promise<void> {
|
|
await this.page.getByRole('menuitem', { name, exact: true }).click()
|
|
}
|
|
|
|
/**
|
|
* Click a litegraph menu entry. Selects the most recently opened matching
|
|
* entry so nested submenu items can be reached without being shadowed by
|
|
* the parent menu still visible behind them.
|
|
*/
|
|
async clickLitegraphMenuItem(name: string): Promise<void> {
|
|
await this.page
|
|
.locator('.litemenu-entry:visible', { hasText: name })
|
|
.last()
|
|
.click()
|
|
}
|
|
|
|
async isVisible(): Promise<boolean> {
|
|
const primeVueVisible = await this.primeVueMenu
|
|
.isVisible()
|
|
.catch(() => false)
|
|
const litegraphVisible = await this.litegraphMenu
|
|
.isVisible()
|
|
.catch(() => false)
|
|
const litegraphContextVisible = await this.litegraphContextMenu
|
|
.isVisible()
|
|
.catch(() => false)
|
|
return primeVueVisible || litegraphVisible || litegraphContextVisible
|
|
}
|
|
|
|
async assertHasItems(items: string[]): Promise<void> {
|
|
for (const item of items) {
|
|
await expect
|
|
.soft(this.page.getByRole('menuitem', { name: item }))
|
|
.toBeVisible()
|
|
}
|
|
}
|
|
|
|
async openFor(locator: Locator): Promise<this> {
|
|
await locator.click({ button: 'right' })
|
|
await expect.poll(() => this.isVisible()).toBe(true)
|
|
return this
|
|
}
|
|
|
|
/**
|
|
* Select a Vue node by clicking its header, then right-click to open
|
|
* the context menu. Vue nodes require a selection click before the
|
|
* right-click so the correct per-node menu items appear.
|
|
*/
|
|
async openForVueNode(header: Locator): Promise<this> {
|
|
await header.click()
|
|
await header.click({ button: 'right' })
|
|
await this.primeVueMenu.waitFor({ state: 'visible' })
|
|
return this
|
|
}
|
|
|
|
async waitForHidden(): Promise<void> {
|
|
await Promise.all([
|
|
this.primeVueMenu.waitFor({ state: 'hidden' }),
|
|
this.litegraphMenu.waitFor({ state: 'hidden' }),
|
|
this.litegraphContextMenu.waitFor({ state: 'hidden' })
|
|
])
|
|
}
|
|
}
|