mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
fix: preserve non-page fixtures when rewriting async destructuring
Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10694#pullrequestreview-2856476290
This commit is contained in:
@@ -52,6 +52,18 @@ describe('transformRules', () => {
|
||||
expect(result).toContain('async ({ comfyPage })')
|
||||
expect(result).not.toContain('{ page }')
|
||||
})
|
||||
|
||||
it('preserves non-page fixtures when rewriting', () => {
|
||||
const input = `test('my test', async ({ page, context }) => {`
|
||||
const result = applyRule('replace-page-destructure', input)
|
||||
expect(result).toContain('async ({ comfyPage, context })')
|
||||
})
|
||||
|
||||
it('preserves multiple non-page fixtures', () => {
|
||||
const input = `test('my test', async ({ page, context, browser }) => {`
|
||||
const result = applyRule('replace-page-destructure', input)
|
||||
expect(result).toContain('async ({ comfyPage, context, browser })')
|
||||
})
|
||||
})
|
||||
|
||||
describe('locator transforms', () => {
|
||||
|
||||
@@ -34,9 +34,17 @@ export const transformRules: TransformRule[] = [
|
||||
// === Fixture transforms ===
|
||||
{
|
||||
name: 'replace-page-destructure',
|
||||
description: 'Use comfyPage fixture instead of page',
|
||||
pattern: /async\s*\(\s*\{\s*page\s*(?:,\s*\w+\s*)*\}\s*\)/g,
|
||||
replacement: 'async ({ comfyPage })',
|
||||
description:
|
||||
'Use comfyPage fixture instead of page, preserving other fixtures',
|
||||
pattern: /async\s*\(\s*\{\s*([^}]*\bpage\b[^}]*)\}\s*\)/g,
|
||||
replacement: (_match: string, fixtures: string) => {
|
||||
const mapped = fixtures
|
||||
.split(',')
|
||||
.map((f) => f.trim())
|
||||
.filter(Boolean)
|
||||
.map((f) => (f === 'page' ? 'comfyPage' : f))
|
||||
return `async ({ ${mapped.join(', ')} })`
|
||||
},
|
||||
category: 'fixture'
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user