mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
## Summary - Scroll the target card into view before clicking - Hopefully stabilize the locale check by enqueuing the check earlier in the process ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7643-Test-Fix-templates-Spec-scroll-card-into-view-2ce6d73d36508175a009f81502f0fe16) by [Unito](https://www.unito.io)
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'
|
|
|
|
export class ComfyTemplates {
|
|
readonly content: Locator
|
|
readonly allTemplateCards: Locator
|
|
|
|
constructor(readonly page: Page) {
|
|
this.content = page.getByTestId('template-workflows-content')
|
|
this.allTemplateCards = page.locator('[data-testid^="template-workflow-"]')
|
|
}
|
|
|
|
async waitForMinimumCardCount(count: number) {
|
|
return await expect(async () => {
|
|
const cardCount = await this.allTemplateCards.count()
|
|
expect(cardCount).toBeGreaterThanOrEqual(count)
|
|
}).toPass({
|
|
timeout: 1_000
|
|
})
|
|
}
|
|
|
|
async loadTemplate(id: string) {
|
|
const templateCard = this.content.getByTestId(`template-workflow-${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)
|
|
}
|
|
}
|