mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 22:39:39 +00:00
## Summary Adds e2e Save As tests for #10679. Refactors tests to remove getByX and other locators in tests to instead be in fixtures. ## Changes - **What**: - extract app mode fixtures - add test ids where required - add new tests ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10680-test-refactor-App-mode-Refactor-Save-As-tests-3316d73d3650815b9d49ccfbb6d54416) by [Unito](https://www.unito.io)
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import type { Locator, Page } from '@playwright/test'
|
|
|
|
import type { ComfyPage } from '../ComfyPage'
|
|
|
|
export class BuilderSaveAsHelper {
|
|
constructor(private readonly comfyPage: ComfyPage) {}
|
|
|
|
private get page(): Page {
|
|
return this.comfyPage.page
|
|
}
|
|
|
|
/** The save-as dialog (scoped by aria-labelledby). */
|
|
get dialog(): Locator {
|
|
return this.page.locator('[aria-labelledby="builder-save"]')
|
|
}
|
|
|
|
/** The post-save success dialog (scoped by aria-labelledby). */
|
|
get successDialog(): Locator {
|
|
return this.page.locator('[aria-labelledby="builder-save-success"]')
|
|
}
|
|
|
|
get title(): Locator {
|
|
return this.dialog.getByText('Save as')
|
|
}
|
|
|
|
get radioGroup(): Locator {
|
|
return this.dialog.getByRole('radiogroup')
|
|
}
|
|
|
|
get nameInput(): Locator {
|
|
return this.dialog.getByRole('textbox')
|
|
}
|
|
|
|
viewTypeRadio(viewType: 'App' | 'Node graph'): Locator {
|
|
return this.dialog.getByRole('radio', { name: viewType })
|
|
}
|
|
|
|
get saveButton(): Locator {
|
|
return this.dialog.getByRole('button', { name: 'Save' })
|
|
}
|
|
|
|
get successMessage(): Locator {
|
|
return this.successDialog.getByText('Successfully saved')
|
|
}
|
|
|
|
get viewAppButton(): Locator {
|
|
return this.successDialog.getByRole('button', { name: 'View app' })
|
|
}
|
|
|
|
get closeButton(): Locator {
|
|
return this.successDialog
|
|
.getByRole('button', { name: 'Close', exact: true })
|
|
.filter({ hasText: 'Close' })
|
|
}
|
|
|
|
/** The X button to dismiss the success dialog without any action. */
|
|
get dismissButton(): Locator {
|
|
return this.successDialog.locator('button.p-dialog-close-button')
|
|
}
|
|
|
|
get exitBuilderButton(): Locator {
|
|
return this.successDialog.getByRole('button', { name: 'Exit builder' })
|
|
}
|
|
|
|
get overwriteDialog(): Locator {
|
|
return this.page.getByRole('dialog', { name: 'Overwrite existing file?' })
|
|
}
|
|
|
|
get overwriteButton(): Locator {
|
|
return this.overwriteDialog.getByRole('button', { name: 'Overwrite' })
|
|
}
|
|
|
|
async fillAndSave(workflowName: string, viewType: 'App' | 'Node graph') {
|
|
await this.nameInput.fill(workflowName)
|
|
await this.viewTypeRadio(viewType).click()
|
|
await this.saveButton.click()
|
|
}
|
|
}
|