mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: patch demowright register.cjs to use dist/setup.mjs, simplify Phase 2
register.cjs imports ./src/setup.ts (TS source) which doesn't work when installed as a dependency. Patch it to ./dist/setup.mjs after build. Simplify Phase 2 back to --require demowright/register approach (avoids ESM/CJS issues with withDemowright config).
This commit is contained in:
2
.github/workflows/pr-qa.yaml
vendored
2
.github/workflows/pr-qa.yaml
vendored
@@ -208,6 +208,7 @@ jobs:
|
||||
pnpm add -D @google/generative-ai@^0.24.1 @anthropic-ai/claude-agent-sdk@^0.2.85
|
||||
git clone --depth 1 https://github.com/snomiao/demowright.git /tmp/demowright
|
||||
cd /tmp/demowright && npm install && npm install typescript && npm run build
|
||||
sed -i 's|"./src/setup.ts"|"./dist/setup.mjs"|' register.cjs
|
||||
cd "$GITHUB_WORKSPACE" && pnpm add -D /tmp/demowright
|
||||
|
||||
- name: Cache main branch dist
|
||||
@@ -388,6 +389,7 @@ jobs:
|
||||
pnpm add -D @google/generative-ai@^0.24.1
|
||||
git clone --depth 1 https://github.com/snomiao/demowright.git /tmp/demowright
|
||||
cd /tmp/demowright && npm install && npm install typescript && npm run build
|
||||
sed -i 's|"./src/setup.ts"|"./dist/setup.mjs"|' register.cjs
|
||||
cd "$GITHUB_WORKSPACE" && pnpm add -D /tmp/demowright
|
||||
|
||||
- name: Setup ComfyUI server (no launch)
|
||||
|
||||
@@ -1970,60 +1970,13 @@ async function main() {
|
||||
console.warn('Phase 2: Recording demo video with demowright')
|
||||
const projectRoot = process.cwd()
|
||||
const videoTestFile = `${projectRoot}/browser_tests/tests/qa-reproduce.spec.ts`
|
||||
const demowrightConfig = `${projectRoot}/playwright.demowright.config.ts`
|
||||
const testResultsDir = `${opts.outputDir}/test-results`
|
||||
|
||||
// Extract issue title for annotate overlay
|
||||
const issueTitle =
|
||||
issueCtx.match(/Title:\s*(.+)/)?.[1]?.trim() ??
|
||||
'Bug Reproduction'
|
||||
// Write the E2E test as-is — demowright register patches Browser.newContext
|
||||
// to inject cursor overlay, keystroke badges, and action delays
|
||||
writeFileSync(videoTestFile, research.testCode)
|
||||
|
||||
// Write a demowright-aware Playwright config that wraps the project config
|
||||
const configCode = `import { defineConfig } from '@playwright/test'
|
||||
import { withDemowright } from 'demowright/config'
|
||||
|
||||
export default withDemowright(
|
||||
defineConfig({
|
||||
testDir: 'browser_tests/tests',
|
||||
testMatch: 'qa-reproduce.spec.ts',
|
||||
use: {
|
||||
video: 'on',
|
||||
viewport: { width: 1280, height: 720 },
|
||||
baseURL: process.env.COMFYUI_BASE_URL || 'http://127.0.0.1:8188',
|
||||
},
|
||||
timeout: 60000,
|
||||
workers: 1,
|
||||
retries: 0,
|
||||
}),
|
||||
{
|
||||
actionDelay: 300,
|
||||
cursorStyle: 'default',
|
||||
keyFadeMs: 2000,
|
||||
},
|
||||
)
|
||||
`
|
||||
writeFileSync(demowrightConfig, configCode)
|
||||
|
||||
// Inject annotate() title card at the start of the test body
|
||||
let testCode = research.testCode
|
||||
const bodyMatch = testCode.match(
|
||||
/async\s*\(\{\s*comfyPage\s*\}\)\s*=>\s*\{/
|
||||
)
|
||||
if (bodyMatch?.index !== undefined) {
|
||||
const pos = bodyMatch.index + bodyMatch[0].length
|
||||
const titleInject = `
|
||||
// demowright: show issue title as subtitle overlay
|
||||
try {
|
||||
const { annotate: _ann } = await import('demowright/helpers')
|
||||
await _ann(comfyPage.page, ${JSON.stringify(issueTitle)})
|
||||
} catch {}
|
||||
`
|
||||
testCode =
|
||||
testCode.slice(0, pos) + titleInject + testCode.slice(pos)
|
||||
}
|
||||
writeFileSync(videoTestFile, testCode)
|
||||
|
||||
// Also save original E2E test for the report
|
||||
// Also save original test for the report
|
||||
writeFileSync(
|
||||
`${opts.outputDir}/reproduce.spec.ts`,
|
||||
research.testCode
|
||||
@@ -2031,14 +1984,18 @@ export default withDemowright(
|
||||
|
||||
try {
|
||||
const output = execSync(
|
||||
`cd "${projectRoot}" && npx playwright test --config="${demowrightConfig}" --output="${testResultsDir}" 2>&1`,
|
||||
`cd "${projectRoot}" && npx playwright test browser_tests/tests/qa-reproduce.spec.ts --reporter=list --timeout=60000 --retries=0 --workers=1 --output="${testResultsDir}" 2>&1`,
|
||||
{
|
||||
timeout: 120000,
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
COMFYUI_BASE_URL: opts.serverUrl,
|
||||
PLAYWRIGHT_LOCAL: '1'
|
||||
PLAYWRIGHT_LOCAL: '1',
|
||||
NODE_OPTIONS: '--require demowright/register',
|
||||
QA_HUD_DELAY: '300',
|
||||
QA_HUD_CURSOR_STYLE: 'default',
|
||||
QA_HUD_KEY_FADE: '2000'
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -2046,34 +2003,8 @@ export default withDemowright(
|
||||
} catch (e) {
|
||||
const err = e as { stdout?: string }
|
||||
console.warn(
|
||||
`Phase 2: Demo recording failed, falling back to raw replay\n${(err.stdout || '').slice(-300)}`
|
||||
`Phase 2: Demo recording failed\n${(err.stdout || '').slice(-300)}`
|
||||
)
|
||||
// Fallback: run original test with register approach
|
||||
writeFileSync(videoTestFile, research.testCode)
|
||||
try {
|
||||
execSync(
|
||||
`cd "${projectRoot}" && npx playwright test browser_tests/tests/qa-reproduce.spec.ts --reporter=list --timeout=60000 --retries=0 --workers=1 --output="${testResultsDir}" 2>&1`,
|
||||
{
|
||||
timeout: 120000,
|
||||
encoding: 'utf-8',
|
||||
env: {
|
||||
...process.env,
|
||||
COMFYUI_BASE_URL: opts.serverUrl,
|
||||
PLAYWRIGHT_LOCAL: '1',
|
||||
NODE_OPTIONS: '--require demowright/register',
|
||||
QA_HUD_DELAY: '300'
|
||||
}
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
/* fallback also failed */
|
||||
}
|
||||
}
|
||||
// Cleanup config
|
||||
try {
|
||||
execSync(`rm -f "${demowrightConfig}"`)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
// Copy recorded video to outputDir so deploy script finds it
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user