mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +00:00
* Merge temp userfile Basic migration Remove deprecated isFavourite Rename nit nit Rework open/load Refactor save Refactor delete Remove workflow dep on manager WIP Change map to record Fix directory nit isActive Move nit Add unload Add close workflow Remove workflowManager.closeWorkflow nit Remove workflowManager.storePrompt move from commandStore move more from commandStore nit Use workflowservice nit nit implement setWorkflow nit Remove workflows.ts Fix strict errors nit nit Resolves circular dep nit nit Fix workflow switching Add openworkflowPaths Fix store Fix key Serialize by default Fix proxy nit Update path Proper sync Fix tabs WIP nit Resolve merge conflict Fix userfile store tests Update jest test Update tabs patch tests Fix changeTracker init Move insert to service nit Fix insert nit Handle bookmark rename Refactor tests Add delete workflow Add test on deleting workflow Add closeWorkflow tests nit * Fix path * Move load next/previous * Move logic from store to service * nit * nit * nit * nit * nit * Add ChangeTracker.initialState * ChangeTracker load/unload * Remove app.changeWorkflow * Hook to app.ts * Changetracker restore * nit * nit * nit * Add debug logs * Remove unnecessary checkState on graphLoad * nit * Fix strict * Fix temp workflow name * Track ismodified * Fix reactivity * nit * Fix graph equal * nit * update test * nit * nit * Fix modified state * nit * Fix modified state * Sidebar force close * tabs force close * Fix save * Add load remote workflow test * Force save * Add save test * nit * Correctly handle delete last opened workflow * nit * Fix workflow rename * Fix save * Fix tests * Fix strict * Update playwright tests * Fix filename conflict handling * nit * Merge temporary and persisted ref * Update playwright expectations * nit * nit * Fix saveAs * Add playwright test * nit
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { Locator, Page } from '@playwright/test'
|
|
|
|
export class Topbar {
|
|
constructor(public readonly page: Page) {}
|
|
|
|
async getTabNames(): Promise<string[]> {
|
|
return await this.page
|
|
.locator('.workflow-tabs .workflow-label')
|
|
.allInnerTexts()
|
|
}
|
|
|
|
async openSubmenuMobile() {
|
|
await this.page.locator('.p-menubar-mobile .p-menubar-button').click()
|
|
}
|
|
|
|
async getMenuItem(itemLabel: string): Promise<Locator> {
|
|
return this.page.locator(`.p-menubar-item-label:text-is("${itemLabel}")`)
|
|
}
|
|
|
|
async getWorkflowTab(tabName: string): Promise<Locator> {
|
|
return this.page
|
|
.locator(`.workflow-tabs .workflow-label:has-text("${tabName}")`)
|
|
.locator('..')
|
|
}
|
|
|
|
async closeWorkflowTab(tabName: string) {
|
|
const tab = await this.getWorkflowTab(tabName)
|
|
await tab.locator('.close-button').click({ force: true })
|
|
}
|
|
|
|
async saveWorkflow(workflowName: string) {
|
|
await this.triggerTopbarCommand(['Workflow', 'Save'])
|
|
await this.page.locator('.p-dialog-content input').fill(workflowName)
|
|
await this.page.keyboard.press('Enter')
|
|
// Wait for the dialog to close.
|
|
await this.page.waitForTimeout(300)
|
|
}
|
|
|
|
async saveWorkflowAs(workflowName: string) {
|
|
await this.triggerTopbarCommand(['Workflow', 'Save As'])
|
|
await this.page.locator('.p-dialog-content input').fill(workflowName)
|
|
await this.page.keyboard.press('Enter')
|
|
// Wait for the dialog to close.
|
|
await this.page.waitForTimeout(300)
|
|
}
|
|
|
|
async triggerTopbarCommand(path: string[]) {
|
|
if (path.length < 2) {
|
|
throw new Error('Path is too short')
|
|
}
|
|
|
|
const tabName = path[0]
|
|
const topLevelMenu = this.page.locator(
|
|
`.top-menubar .p-menubar-item-label:text-is("${tabName}")`
|
|
)
|
|
await topLevelMenu.waitFor({ state: 'visible' })
|
|
await topLevelMenu.click()
|
|
|
|
for (let i = 1; i < path.length; i++) {
|
|
const commandName = path[i]
|
|
const menuItem = this.page
|
|
.locator(
|
|
`.top-menubar .p-menubar-submenu .p-menubar-item:has-text("${commandName}")`
|
|
)
|
|
.first()
|
|
await menuItem.waitFor({ state: 'visible' })
|
|
await menuItem.hover()
|
|
|
|
if (i === path.length - 1) {
|
|
await menuItem.click()
|
|
}
|
|
}
|
|
}
|
|
}
|