Fix: binary body lost on importing from postman#8729
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughPostman-to-Bruno conversion now supports file-mode request bodies and examples. Binary file paths are preserved, MIME types are inferred with a fallback, and unit plus Electron import tests cover the new behavior. ChangesBinary body import
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PostmanCollection
participant postmanToBruno
participant mime_types
participant BrunoRequest
participant BrunoUI
PostmanCollection->>postmanToBruno: provide file-mode request and example bodies
postmanToBruno->>mime_types: infer MIME type from file extension
mime_types-->>postmanToBruno: return MIME type or fallback
postmanToBruno->>BrunoRequest: populate selected file entries
BrunoRequest->>BrunoUI: render File / Binary body mode and filename
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…e extensions and adding tests for various file types
…file content type resolution in Postman to Bruno conversion
a35f614 to
69233f0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/import/postman/import-binary-body-mode.spec.ts (1)
44-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove UI selectors into page locators.
Extract the inline
getByText,getByTestId, and.selected-body-modeselectors intotests/utils/page/*; use the existinglocators.fileModesupport for file-mode assertions.🤖 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/postman/import-binary-body-mode.spec.ts` around lines 44 - 62, Move the inline selectors in the test steps into the appropriate page-locator definitions under tests/utils/page: replace the request pane’s getByText('binary-payload.bin'), the page getByTestId('request-item-chevron'), and the .selected-body-mode locator with named locator helpers. Reuse the existing locators.fileMode support for both file-mode assertions, and update the test to call those locators instead of constructing selectors inline.Sources: Coding guidelines, Path instructions
🤖 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.
Inline comments:
In `@tests/import/postman/import-binary-body-mode.spec.ts`:
- Around line 7-9: Replace the test-scoped page usage in the afterAll cleanup
with afterEach or an in-test finally block, ensuring closeAllCollections
receives a valid page instance after each test. In the same test flow, replace
the inline request-item-chevron and .selected-body-mode selectors with the
existing shared locator definitions.
---
Nitpick comments:
In `@tests/import/postman/import-binary-body-mode.spec.ts`:
- Around line 44-62: Move the inline selectors in the test steps into the
appropriate page-locator definitions under tests/utils/page: replace the request
pane’s getByText('binary-payload.bin'), the page
getByTestId('request-item-chevron'), and the .selected-body-mode locator with
named locator helpers. Reuse the existing locators.fileMode support for both
file-mode assertions, and update the test to call those locators instead of
constructing selectors inline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bc625387-f1b9-4637-840f-68752f31351e
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
packages/bruno-converters/package.jsonpackages/bruno-converters/rollup.config.jspackages/bruno-converters/src/postman/postman-to-bruno.jspackages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.jstests/import/postman/fixtures/postman-import-binary-body-mode.jsontests/import/postman/import-binary-body-mode.spec.ts
Jira link: https://usebruno.atlassian.net/browse/BRU-3118
Extension of #8114
Description
Postman's binary body (
mode: "file") was silently dropped on import. This PR adds the missingbodyMode === 'file'branch inpostman-to-bruno.jsfor both requests and Postman examples, mappingbody.file.srcto a Bruno file entry.The content type is inferred from the file extension via
mime-types(e.g..png→image/png,.json→application/json), falling back toapplication/octet-stream(RFC 2046 §4.5.1) when the extension is missing or unknown. This keeps the sentContent-Typeaccurate instead of blanket-tagging every imported binary body as opaque bytes.mime-typesis added as a runtime dep onbruno-convertersTests
packages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.js:mode: fileoriginalRequest) import.json,.png, and.binsrcfalls back cleanly toapplication/octet-streamtests/import/postman/verifying the imported body shows "File / Binary" with the file path preserved.Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
New Features
Bug Fixes
Tests