Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow templates #938

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as fs from 'fs'
import { NodeBadgeMode } from '../src/types/nodeSource'
import { NodeId } from '../src/types/comfyWorkflow'
import { ManageGroupNode } from './helpers/manageGroupNode'
import { ComfyTemplates } from './helpers/templates'

interface Position {
x: number
Expand Down Expand Up @@ -173,6 +174,10 @@ class WorkflowsSidebarTab extends SidebarTab {
super(page, 'workflows')
}

get browseGalleryButton() {
return this.page.locator('.browse-templates-button')
}

get newBlankWorkflowButton() {
return this.page.locator('.new-blank-workflow-button')
}
Expand Down Expand Up @@ -288,6 +293,7 @@ export class ComfyPage {
public readonly searchBox: ComfyNodeSearchBox
public readonly menu: ComfyMenu
public readonly appMenu: ComfyAppMenu
public readonly templates: ComfyTemplates

constructor(
public readonly page: Page,
Expand All @@ -302,6 +308,7 @@ export class ComfyPage {
this.searchBox = new ComfyNodeSearchBox(page)
this.menu = new ComfyMenu(page)
this.appMenu = new ComfyAppMenu(page)
this.templates = new ComfyTemplates(page)
}

convertLeafToContent(structure: FolderStructure): FolderStructure {
Expand Down
12 changes: 12 additions & 0 deletions browser_tests/helpers/templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Locator, Page } from '@playwright/test'
export class ComfyTemplates {
readonly content: Locator

constructor(readonly page: Page) {
this.content = page.getByTestId('template-workflows-content')
}

async loadTemplate(id: string) {
await this.content.getByTestId(`template-workflow-${id}`).click()
}
}
34 changes: 34 additions & 0 deletions browser_tests/templates.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect } from '@playwright/test'
import { comfyPageFixture as test } from './ComfyPage'

test.describe('Templates', () => {
pythongosssss marked this conversation as resolved.
Show resolved Hide resolved
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.UseNewMenu', 'Floating')
})

test.afterEach(async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled')
})

test('Can load template workflows', async ({ comfyPage }) => {
// This test will need expanding on once the templates are decided

// Clear the workflow
await comfyPage.menu.workflowsTab.open()
await comfyPage.menu.workflowsTab.newBlankWorkflowButton.click()
await expect(async () => {
expect(await comfyPage.getGraphNodesCount()).toBe(0)
}).toPass({ timeout: 250 })

// Load a template
await comfyPage.menu.workflowsTab.browseGalleryButton.click()
await expect(comfyPage.templates.content).toBeVisible()
await comfyPage.templates.loadTemplate('default')
await expect(comfyPage.templates.content).toBeHidden()

// Ensure we now have some nodes
await expect(async () => {
expect(await comfyPage.getGraphNodesCount()).toBeGreaterThan(0)
}).toPass({ timeout: 250 })
})
})
Loading
Loading