fix: extract shared COLLECT_COVERAGE, fix type assertion, add comments

- Extract COLLECT_COVERAGE to shared coverageConstants.ts to avoid drift
  between ComfyPage.ts and playwright.config.ts.
- Add coupling comment for COVERAGE_ATTACHMENT magic string.
- Use Object.assign instead of as Record<string, unknown> for source.
- Add comment explaining resetOnNavigation: false.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10930#discussion_r3047998513
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10930#discussion_r3047998518
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10930#discussion_r3054600476
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10930#discussion_r3047998519
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10930#discussion_r3047998521
This commit is contained in:
bymyself
2026-04-08 23:43:10 +00:00
parent e15ba39647
commit 7563a0fcf1
3 changed files with 8 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import { ComfyTemplates } from '@e2e/helpers/templates'
import { ComfyMouse } from '@e2e/fixtures/ComfyMouse'
import { TestIds } from '@e2e/fixtures/selectors'
import { comfyExpect } from '@e2e/fixtures/utils/customMatchers'
import { COLLECT_COVERAGE } from '@e2e/fixtures/utils/coverageConstants'
import { assetPath } from '@e2e/fixtures/utils/paths'
import { sleep } from '@e2e/fixtures/utils/timing'
import { VueNodeHelpers } from '@e2e/fixtures/VueNodeHelpers'
@@ -408,7 +409,7 @@ export class ComfyPage {
export const testComfySnapToGridGridSize = 50
const COLLECT_COVERAGE = process.env.COLLECT_COVERAGE === 'true'
// Must match attachmentName exported by @bgotink/playwright-coverage
const COVERAGE_ATTACHMENT = '@bgotink/playwright-coverage'
export const comfyPageFixture = base.extend<{
@@ -423,6 +424,8 @@ export const comfyPageFixture = base.extend<{
return use(page)
}
// Accumulate coverage across navigations within a single test to capture
// all code paths exercised, including after in-test reloads.
await page.coverage.startJSCoverage({ resetOnNavigation: false })
await use(page)
const entries = await page.coverage.stopJSCoverage()
@@ -432,8 +435,7 @@ export const comfyPageFixture = base.extend<{
if (typeof entry.source !== 'string' && entry.url.startsWith('http')) {
try {
const resp = await fetch(entry.url)
if (resp.ok)
(entry as Record<string, unknown>).source = await resp.text()
if (resp.ok) Object.assign(entry, { source: await resp.text() })
} catch {
// skip unreachable scripts
}

View File

@@ -0,0 +1 @@
export const COLLECT_COVERAGE = process.env.COLLECT_COVERAGE === 'true'

View File

@@ -5,8 +5,9 @@ import { defineCoverageReporterConfig } from '@bgotink/playwright-coverage'
import type { PlaywrightTestConfig } from '@playwright/test'
import { defineConfig, devices } from '@playwright/test'
import { COLLECT_COVERAGE } from './browser_tests/fixtures/utils/coverageConstants'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const COLLECT_COVERAGE = process.env.COLLECT_COVERAGE === 'true'
const maybeLocalOptions: PlaywrightTestConfig = process.env.PLAYWRIGHT_LOCAL
? {