Repository navigation
fix: correctly parse insomnia exported yaml - #7966
Conversation
Co-authored-by: Prateek Sunal <[email protected]>
Co-authored-by: Prateek Sunal <[email protected]>
Co-authored-by: Prateek Sunal <[email protected]>
WalkthroughYAML parsing in both file and URL import paths now uses ChangesInsomnia Date Import Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/import/insomnia/import-insomnia-v5-date-types.spec.ts (1)
11-34: ⚡ Quick winConsider adding
test.stepfor better reporting.The test correctly validates the date preservation fix, but would benefit from using
test.stepto break down the logical phases (import → read file → verify) for clearer test reports.📊 Suggested structure with test.step
test('should keep date-like strings and quoted values intact through the full FileTab.js import flow', async ({ page, createTmpDir }) => { - const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml'); - const collectionName = 'Date Type Test'; - const collectionDir = await createTmpDir('insomnia-dates-test'); - - await importCollection(page, insomniaFile, collectionDir, { - expectedCollectionName: collectionName - }); - - const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml'); - const yamlContent = fs.readFileSync(requestFilePath, 'utf8'); - - expect(yamlContent).toContain('value: 2024-01-01'); - expect(yamlContent).not.toContain('Mon Jan'); - expect(yamlContent).not.toContain('GMT'); - - expect(yamlContent).toMatch(/value:\s*"false"/); - expect(yamlContent).toMatch(/value:\s*"0"/); - expect(yamlContent).toMatch(/value:\s*"2\.0"/); - expect(yamlContent).toContain('value: "42"'); + await test.step('Import Insomnia v5 collection with date-like values', async () => { + const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml'); + const collectionName = 'Date Type Test'; + const collectionDir = await createTmpDir('insomnia-dates-test'); + + await importCollection(page, insomniaFile, collectionDir, { + expectedCollectionName: collectionName + }); + }); + + await test.step('Verify date-like strings are preserved as strings', async () => { + const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml'); + const yamlContent = fs.readFileSync(requestFilePath, 'utf8'); + + expect(yamlContent).toContain('value: 2024-01-01'); + expect(yamlContent).not.toContain('Mon Jan'); + expect(yamlContent).not.toContain('GMT'); + }); + + await test.step('Verify quoted scalar values are preserved', async () => { + const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml'); + const yamlContent = fs.readFileSync(requestFilePath, 'utf8'); + + expect(yamlContent).toMatch(/value:\s*"false"/); + expect(yamlContent).toMatch(/value:\s*"0"/); + expect(yamlContent).toMatch(/value:\s*"2\.0"/); + expect(yamlContent).toContain('value: "42"'); + }); });Note: You'll need to make
collectionDirandcollectionNameavailable across steps, either by declaring them outside or restructuring slightly.Based on coding guidelines: "Promote the use of
test.stepas much as possible so the generated reports are easier to read."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts` around lines 11 - 34, Split the test 'should keep date-like strings and quoted values intact through the full FileTab.js import flow' into clear steps using test.step: wrap the importCollection call in a test.step labeled "import collection", the fs.readFileSync call that loads requestFilePath in "read exported file", and the expect assertions in "verify values"; to make this work declare collectionDir and collectionName in the outer test scope (before the steps) so they are shared across steps and leave function calls/imports (importCollection, path.join, fs.readFileSync) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts`:
- Around line 11-34: Split the test 'should keep date-like strings and quoted
values intact through the full FileTab.js import flow' into clear steps using
test.step: wrap the importCollection call in a test.step labeled "import
collection", the fs.readFileSync call that loads requestFilePath in "read
exported file", and the expect assertions in "verify values"; to make this work
declare collectionDir and collectionName in the outer test scope (before the
steps) so they are shared across steps and leave function calls/imports
(importCollection, path.join, fs.readFileSync) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 784e57a1-6ee8-4686-9b69-ebae80dcce6f
📒 Files selected for processing (5)
packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.jspackages/bruno-app/src/utils/importers/common.jspackages/bruno-converters/src/insomnia/insomnia-to-bruno.jstests/import/insomnia/fixtures/insomnia-v5-dates.yamltests/import/insomnia/import-insomnia-v5-date-types.spec.ts
Co-authored-by: Prateek Sunal <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/import/insomnia/import-insomnia-v5-date-types.spec.ts (1)
11-55: ⚡ Quick winConsider wrapping logical test sections in
test.stepfor improved reporting.The test has three distinct phases (import, verify request, verify environment) that would benefit from
test.stepblocks. This makes test reports easier to understand when failures occur. As per coding guidelines, Playwright tests should promote the use oftest.stepas much as possible.📊 Suggested refactor with test.step blocks
test('should keep date-like strings and quoted values intact through the full FileTab.js import flow', async ({ page, createTmpDir }) => { - const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml'); - const collectionName = 'Date Type Test'; - const collectionDir = await createTmpDir('insomnia-dates-test'); - - await importCollection(page, insomniaFile, collectionDir, { - expectedCollectionName: collectionName - }); - - const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml'); - const yamlContent = fs.readFileSync(requestFilePath, 'utf8'); - - expect(yamlContent).toContain(` params: + await test.step('Import collection from fixture', async () => { + const insomniaFile = path.resolve(__dirname, 'fixtures', 'insomnia-v5-dates.yaml'); + const collectionName = 'Date Type Test'; + const collectionDir = await createTmpDir('insomnia-dates-test'); + + await importCollection(page, insomniaFile, collectionDir, { + expectedCollectionName: collectionName + }); + }); + + await test.step('Verify request params preserve date-like and quoted values', async () => { + const requestFilePath = path.join(collectionDir, collectionName, 'Date Request.yml'); + const yamlContent = fs.readFileSync(requestFilePath, 'utf8'); + + expect(yamlContent).toContain(` params: - name: date value: 2024-01-01 type: query @@ -38,18 +46,21 @@ - name: count value: "42" type: query `); + }); - const envFilePath = path.join(collectionDir, collectionName, 'environments', 'Base.yml'); - const envContent = fs.readFileSync(envFilePath, 'utf8'); - - expect(envContent).toContain(`variables: + await test.step('Verify environment variables preserve date-like and quoted values', async () => { + const envFilePath = path.join(collectionDir, collectionName, 'environments', 'Base.yml'); + const envContent = fs.readFileSync(envFilePath, 'utf8'); + + expect(envContent).toContain(`variables: - name: expiry_date value: 2024-12-31 - name: max_retries value: "3" - name: enabled value: "true" `); + }); });Note: You'll need to move the variable declarations (
insomniaFile,collectionName,collectionDir) outside the first step so they're accessible in subsequent steps.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts` around lines 11 - 55, Split the test 'should keep date-like strings and quoted values intact through the full FileTab.js import flow' into explicit Playwright steps by wrapping the three logical phases (import, verify request file, verify environment file) in test.step blocks; move shared variables (insomniaFile, collectionName, collectionDir) out of the first step so they are declared before the steps and accessible to all, then wrap the call to importCollection(page, insomniaFile, collectionDir, { expectedCollectionName: collectionName }) in the first test.step and put the two expect blocks that read requestFilePath/yamlContent and envFilePath/envContent each in their own test.step for clearer reporting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/import/insomnia/import-insomnia-v5-date-types.spec.ts`:
- Around line 11-55: Split the test 'should keep date-like strings and quoted
values intact through the full FileTab.js import flow' into explicit Playwright
steps by wrapping the three logical phases (import, verify request file, verify
environment file) in test.step blocks; move shared variables (insomniaFile,
collectionName, collectionDir) out of the first step so they are declared before
the steps and accessible to all, then wrap the call to importCollection(page,
insomniaFile, collectionDir, { expectedCollectionName: collectionName }) in the
first test.step and put the two expect blocks that read
requestFilePath/yamlContent and envFilePath/envContent each in their own
test.step for clearer reporting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b3cf838c-3e99-47e3-8c19-aa61f073341f
📒 Files selected for processing (1)
tests/import/insomnia/import-insomnia-v5-date-types.spec.ts
utkarsh-bruno
left a comment
There was a problem hiding this comment.
The changes make sense. Looks good to me.
Description
Jira
Fixes #7687 #6095
Insomnia yaml export didn't had quotes for string so values like: 2024-01-01 were getting parsed as date by our parser.
What this does:
Contribution Checklist:
Summary by CodeRabbit
Bug Fixes
Tests