fix: address review nitpicks in test-recorder

- Guard box() against empty lines array (RangeError on Math.max)
- Sanitize testName in recording template to prevent injection
This commit is contained in:
bymyself
2026-04-06 14:36:11 -07:00
parent 0959435d53
commit 7418ce454a
2 changed files with 4 additions and 1 deletions

View File

@@ -25,6 +25,8 @@ export function generateRecordingTemplate(
? ` // Load the selected workflow\n await comfyPage.workflow.loadWorkflow('${options.workflow.replace(/'/g, "\\'")}')\n await comfyPage.nextFrame()\n`
: ''
const safeName = options.testName.replace(/[`$\\]/g, '')
const code = `/**
* Auto-generated recording session.
* This file is temporary — it will be deleted after recording.
@@ -36,7 +38,7 @@ import {
comfyExpect as expect
} from '../fixtures/ComfyPage'
test('recording: ${options.testName}', async ({ comfyPage }) => {
test('recording: ${safeName}', async ({ comfyPage }) => {
${workflowLine}
// ┌────────────────────────────────────────────────────────┐
// │ The Playwright Inspector will open. │

View File

@@ -32,6 +32,7 @@ export function header(text: string) {
}
export function box(lines: string[]) {
if (lines.length === 0) return
const maxLen = Math.max(...lines.map((l) => l.length))
const border = '─'.repeat(maxLen + 4)
console.log(`${border}`)