mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Stabilize flaky Playwright tests by improving test reliability. This PR aims to identify and fix flaky e2e tests. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10817-test-stabilize-flaky-Playwright-tests-3366d73d365081ada40de73ce11af625) by [Unito](https://www.unito.io) --------- Co-authored-by: Amp <amp@ampcode.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import type { Locator, Page } from '@playwright/test'
|
|
import { expect } from '@playwright/test'
|
|
import path from 'path'
|
|
|
|
import type {
|
|
TemplateInfo,
|
|
WorkflowTemplates
|
|
} from '../../src/platform/workflow/templates/types/template'
|
|
import { TestIds } from '../fixtures/selectors'
|
|
|
|
export class ComfyTemplates {
|
|
readonly content: Locator
|
|
readonly allTemplateCards: Locator
|
|
|
|
constructor(readonly page: Page) {
|
|
this.content = page.getByTestId(TestIds.templates.content)
|
|
this.allTemplateCards = page.locator('[data-testid^="template-workflow-"]')
|
|
}
|
|
|
|
async expectMinimumCardCount(count: number) {
|
|
await expect
|
|
.poll(() => this.allTemplateCards.count())
|
|
.toBeGreaterThanOrEqual(count)
|
|
}
|
|
|
|
async loadTemplate(id: string) {
|
|
const templateCard = this.content.getByTestId(
|
|
TestIds.templates.workflowCard(id)
|
|
)
|
|
await templateCard.scrollIntoViewIfNeeded()
|
|
await templateCard.getByRole('img').click()
|
|
}
|
|
|
|
async getAllTemplates(): Promise<TemplateInfo[]> {
|
|
const templates: WorkflowTemplates[] = await this.page.evaluate(() =>
|
|
window.app!.api.getCoreWorkflowTemplates()
|
|
)
|
|
return templates.flatMap((t) => t.templates)
|
|
}
|
|
|
|
getTemplatePath(filename: string): string {
|
|
return path.join('public', 'templates', filename)
|
|
}
|
|
}
|