diff --git a/.github/workflows/test-ui.yaml b/.github/workflows/test-ui.yaml index fb959d2f5..538eb13c9 100644 --- a/.github/workflows/test-ui.yaml +++ b/.github/workflows/test-ui.yaml @@ -39,7 +39,6 @@ jobs: - name: Build ComfyUI_frontend run: | npm ci - npm run fetch-templates npm run build working-directory: ComfyUI_frontend diff --git a/browser_tests/tests/templates.spec.ts b/browser_tests/tests/templates.spec.ts index 470e62c92..a891cc098 100644 --- a/browser_tests/tests/templates.spec.ts +++ b/browser_tests/tests/templates.spec.ts @@ -1,8 +1,17 @@ -import { expect } from '@playwright/test' -import fs from 'fs' +import { Page, expect } from '@playwright/test' import { comfyPageFixture as test } from '../fixtures/ComfyPage' +async function checkTemplateFileExists( + page: Page, + filename: string +): Promise { + const response = await page.request.head( + new URL(`/templates/${filename}`, page.url()).toString() + ) + return response.ok() +} + test.describe('Templates', () => { test.beforeEach(async ({ comfyPage }) => { await comfyPage.setSetting('Comfy.UseNewMenu', 'Top') @@ -12,32 +21,32 @@ test.describe('Templates', () => { test('should have a JSON workflow file for each template', async ({ comfyPage }) => { + test.slow() const templates = await comfyPage.templates.getAllTemplates() for (const template of templates) { - const workflowPath = comfyPage.templates.getTemplatePath( + const exists = await checkTemplateFileExists( + comfyPage.page, `${template.name}.json` ) - expect( - fs.existsSync(workflowPath), - `Missing workflow: ${template.name}` - ).toBe(true) + expect(exists, `Missing workflow: ${template.name}`).toBe(true) } }) - test.skip('should have all required thumbnail media for each template', async ({ + test('should have all required thumbnail media for each template', async ({ comfyPage }) => { + test.slow() const templates = await comfyPage.templates.getAllTemplates() for (const template of templates) { const { name, mediaSubtype, thumbnailVariant } = template const baseMedia = `${name}-1.${mediaSubtype}` - const basePath = comfyPage.templates.getTemplatePath(baseMedia) // Check base thumbnail - expect( - fs.existsSync(basePath), - `Missing base thumbnail: ${baseMedia}` - ).toBe(true) + const baseExists = await checkTemplateFileExists( + comfyPage.page, + baseMedia + ) + expect(baseExists, `Missing base thumbnail: ${baseMedia}`).toBe(true) // Check second thumbnail for variants that need it if ( @@ -45,9 +54,12 @@ test.describe('Templates', () => { thumbnailVariant === 'hoverDissolve' ) { const secondMedia = `${name}-2.${mediaSubtype}` - const secondPath = comfyPage.templates.getTemplatePath(secondMedia) + const secondExists = await checkTemplateFileExists( + comfyPage.page, + secondMedia + ) expect( - fs.existsSync(secondPath), + secondExists, `Missing second thumbnail: ${secondMedia} required for ${thumbnailVariant}` ).toBe(true) } diff --git a/package.json b/package.json index 72e9ece3a..573a6794d 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "lint:fix": "eslint src --fix", "locale": "lobe-i18n locale", "collect-i18n": "playwright test --config=playwright.i18n.config.ts", - "json-schema": "tsx scripts/generate-json-schema.ts", - "fetch-templates": "tsx scripts/fetch-templates.ts" + "json-schema": "tsx scripts/generate-json-schema.ts" }, "devDependencies": { "@eslint/js": "^9.8.0", diff --git a/scripts/fetch-templates.ts b/scripts/fetch-templates.ts deleted file mode 100644 index bfb2fc171..000000000 --- a/scripts/fetch-templates.ts +++ /dev/null @@ -1,24 +0,0 @@ -import fs from 'fs-extra' -import { execSync } from 'node:child_process' -import path from 'node:path' - -const workflowTemplatesRepo = 'https://github.com/Comfy-Org/workflow_templates' -const tempRepoDir = './templates_repo' - -// Clone the repository -execSync(`git clone ${workflowTemplatesRepo} --depth 1 ${tempRepoDir}`) - -// Create public/templates directory if it doesn't exist -fs.ensureDirSync('public/templates') - -// Copy templates from repo to public/templates -const sourceDir = path.join(tempRepoDir, 'templates') -const targetDir = 'public/templates' - -// Copy entire directory at once -fs.copySync(sourceDir, targetDir) - -// Remove the temporary repository directory -fs.removeSync(tempRepoDir) - -console.log('Templates fetched successfully')