Repository navigation
feat: add missing status assertions and .not negation support - #7660
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR refactors Postman response assertion translation from hardcoded patterns to a data-driven approach. A new ChangesResponse Assertion Translator Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
5b3e0c3 to
0e23173
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js (1)
975-1097: ⚡ Quick winNegation coverage is thorough; one alternate-position gap.
You've covered
to.not.be.Xfor every status name and the alias path, butto.be.not.X(the alternate position the translator explicitly supports — see translator lines 505 and 525) is only exercised once forokon line 981. Since the generator emits both forms uniformly, a regression in the alternate-position pattern would currently slip past tests for everything exceptok.A single combined test would close the gap cheaply:
🧪 Suggested addition
+ it('should translate pm.response.to.be.not.* (alternate position) for all status names', () => { + const code = ` + pm.response.to.be.not.success; + pm.response.to.be.not.notFound; + pm.response.to.be.not.withoutBody; + `; + const translatedCode = translateCode(code); + expect(translatedCode).toContain('expect(res.getStatus()).to.not.be.within(200, 299)'); + expect(translatedCode).toContain('expect(res.getStatus()).to.not.equal(404)'); + expect(translatedCode).toContain('expect([204, 304]).to.not.include(res.getStatus())'); + });🤖 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 `@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js` around lines 975 - 1097, Add a test that exercises the alternate negation ordering "to.be.not.X" for multiple status types (not just ok) to mirror existing "to.not.be.X" coverage; update the tests that call translateCode(...) (see translateCode in this file) to include a pm.test block and/or standalone lines using "pm.response.to.be.not.serverError", "pm.response.to.be.not.clientError", and one alias form like "resp.to.be.not.serverError" so the translator paths at the alternate-position branches are exercised; ensure expectations assert the same translated strings used elsewhere (e.g., expect(res.getStatus()).to.not.be.within(500, 599) etc.).packages/bruno-converters/src/utils/postman-to-bruno-translator.js (1)
465-529: 💤 Low valueNice data-driven refactor — one small fragility worth a comment.
The IIFE removes a lot of duplication and the positive/negated/alternate-position fan-out is tidy. One thing that may bite a future contributor:
negateChainuseschain.replace('to.', 'to.not.'), which silently relies on every chain starting withto.and on the first match being the right one. For example, a future entry like'is.true'or a chain starting with something else would yieldis.trueunchanged, and'to.have.to.something'would only flip the first segment.Today every entry starts with
to.so the behavior is correct, but a tiny guard + comment would make the contract obvious:♻️ Suggested clarification
- const negateChain = (chain) => chain.replace('to.', 'to.not.'); + // Inserts `.not` right after the leading `to.` (e.g. `to.be.within` -> `to.not.be.within`). + // All chains in `statusAssertions` are expected to start with `to.`. + const negateChain = (chain) => { + if (!chain.startsWith('to.')) { + throw new Error(`negateChain expects chain to start with "to.", got: ${chain}`); + } + return `to.not.${chain.slice(3)}`; + };🤖 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 `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js` around lines 465 - 529, negateChain currently does chain.replace('to.', 'to.not.') which silently misbehaves for chains not beginning with "to."; update negateChain to explicitly check that the incoming chain startsWith('to.') (or use a /^to\./ regex) and replace only that prefix with 'to.not.' (or throw/assert if the contract is violated), and add a short comment above negateChain explaining the expected "to."-prefixed contract; reference negateChain, buildStatusTransform and statusAssertions when making the change.
🤖 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 `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js`:
- Around line 465-529: negateChain currently does chain.replace('to.',
'to.not.') which silently misbehaves for chains not beginning with "to."; update
negateChain to explicitly check that the incoming chain startsWith('to.') (or
use a /^to\./ regex) and replace only that prefix with 'to.not.' (or
throw/assert if the contract is violated), and add a short comment above
negateChain explaining the expected "to."-prefixed contract; reference
negateChain, buildStatusTransform and statusAssertions when making the change.
In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js`:
- Around line 975-1097: Add a test that exercises the alternate negation
ordering "to.be.not.X" for multiple status types (not just ok) to mirror
existing "to.not.be.X" coverage; update the tests that call translateCode(...)
(see translateCode in this file) to include a pm.test block and/or standalone
lines using "pm.response.to.be.not.serverError",
"pm.response.to.be.not.clientError", and one alias form like
"resp.to.be.not.serverError" so the translator paths at the alternate-position
branches are exercised; ensure expectations assert the same translated strings
used elsewhere (e.g., expect(res.getStatus()).to.not.be.within(500, 599) etc.).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9dcf3752-ae95-41a3-8244-13f29368318e
📒 Files selected for processing (2)
packages/bruno-converters/src/utils/postman-to-bruno-translator.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js`:
- Around line 510-526: The transform created by buildWithBodyTransform currently
wraps the member expression in a j.callExpression which emits
expect(res.getBody()).to.be.ok() and causes a TypeError because ok is a
chainable property, not a function; change buildWithBodyTransform (used by the
three entries with patterns 'pm.response.to.be.withBody',
'pm.response.to.not.be.withBody', 'pm.response.to.be.not.withBody') to return
the j.memberExpression directly (i.e., return
j.memberExpression(j.callExpression(j.identifier('expect'),
[j.callExpression(j.identifier('res.getBody'), [])]), j.identifier(chain)))
instead of wrapping it in j.callExpression so the output is
expect(res.getBody()).to.be.ok without calling it.
In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js`:
- Around line 942-946: The test for "should translate
pm.response.to.be.withBody" currently uses toContain which masks whether the
translator produced `ok` vs `ok()`; update the assertion to use toBe with the
exact expected string "expect(res.getBody()).to.be.ok" (i.e., replace
expect(translatedCode).toContain(...) with expect(translatedCode).toBe(...)) and
apply the identical change to the corresponding "to.not.be.withBody" test so
both tests assert the exact expected output from translateCode.
🪄 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: ea5f4366-a49f-49ed-94e8-305a3d92063a
📒 Files selected for processing (2)
packages/bruno-converters/src/utils/postman-to-bruno-translator.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
2aa2c54 to
80c4879
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js (1)
954-958:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
toContainstill masks theokvsok()regression — tighten totoBe.Both
withBodytests usetoContain, which passes even if the translator emitsok()(broken) instead ofok(correct). Swap totoBewith the exact expected string so the assertion is precise.🔧 Proposed fix
- expect(translatedCode).toContain('expect(res.getBody()).to.be.ok'); + expect(translatedCode).toBe('expect(res.getBody()).to.be.ok;');- expect(translatedCode).toContain('expect(res.getBody()).to.not.be.ok'); + expect(translatedCode).toBe('expect(res.getBody()).to.not.be.ok;');Also applies to: 1069-1073
🤖 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 `@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js` around lines 954 - 958, The tests for translating pm.response.to.be.withBody use toContain which masks regressions between emitting "ok" vs "ok()"; update the assertions in the test cases (e.g., the "should translate pm.response.to.be.withBody" test and the other withBody test around the later block) to use toBe with the exact expected string returned by translateCode (e.g., expect(translatedCode).toBe('<exact expected string>')) so the assertion fails if the translator emits ok() instead of ok; locate the tests by their descriptions and the translateCode call to change the matcher and provide the precise expected string.
🤖 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
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js`:
- Around line 909-981: Add tests for the new pm.response.to.be.withoutBody
assertion mirroring the other new assertions: create a standalone test that
calls translateCode('pm.response.to.be.withoutBody;') and expect the output
toContain a check that res.getStatus() matches 204 or 304 (e.g. expect([204,
304]).to.include(res.getStatus()) or equivalent project style), add a negated
variant if you follow the pattern elsewhere, and include the assertion inside a
pm.test(...) block test similar to the "should handle new status assertions
inside test blocks" case so the translator is exercised both standalone and
inside tests; locate tests near the other pm.response.* assertions and use
translateCode, expect(...).toContain with the unique symbol
pm.response.to.be.withoutBody and the corresponding expected translated status
check.
---
Duplicate comments:
In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js`:
- Around line 954-958: The tests for translating pm.response.to.be.withBody use
toContain which masks regressions between emitting "ok" vs "ok()"; update the
assertions in the test cases (e.g., the "should translate
pm.response.to.be.withBody" test and the other withBody test around the later
block) to use toBe with the exact expected string returned by translateCode
(e.g., expect(translatedCode).toBe('<exact expected string>')) so the assertion
fails if the translator emits ok() instead of ok; locate the tests by their
descriptions and the translateCode call to change the matcher and provide the
precise expected string.
🪄 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: e6904d8d-fbe7-47a7-aa84-4c71bedfc3c0
📒 Files selected for processing (2)
packages/bruno-converters/src/utils/postman-to-bruno-translator.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-converters/src/utils/postman-to-bruno-translator.js
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/bruno-converters/src/utils/postman-to-bruno-translator.js (1)
527-543:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
buildWithBodyTransformstill emitsok()—TypeErrorat runtime in Chai.
okis a chainable property (getter), not a callable method. The ability to use an assertion property as a function was removed in Chai 2.0.0 and is backwards-incompatible. The currentj.callExpression(..., [])wrapper generatesexpect(res.getBody()).to.be.ok()andexpect(res.getBody()).to.not.be.ok(), both of which throwTypeErrorwhen the translated script is executed. The fix already exists right above in this same file — see the single-arg header transform at line 254.🐛 Fix — return `j.memberExpression` directly
- const buildWithBodyTransform = (chain) => (path, j) => { - return j.callExpression( - j.memberExpression( - j.callExpression(j.identifier('expect'), [ - j.callExpression(j.identifier('res.getBody'), []) - ]), - j.identifier(chain) - ), - [] - ); - }; + const buildWithBodyTransform = (chain) => (_path, j) => { + return j.memberExpression( + j.callExpression(j.identifier('expect'), [ + j.callExpression(j.identifier('res.getBody'), []) + ]), + j.identifier(chain) + ); + };🤖 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 `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js` around lines 527 - 543, The transform currently wraps the chain (e.g., "to.be.ok" / "to.not.be.ok") in a callExpression, producing expect(res.getBody()).to.be.ok(), which throws because "ok" is a chainable property, not a function; update buildWithBodyTransform to return the j.memberExpression for expect(res.getBody()) and the identifier chain directly (i.e., do not wrap the final memberExpression in j.callExpression), so the entries for 'pm.response.to.be.withBody', 'pm.response.to.not.be.withBody', and 'pm.response.to.be.not.withBody' produce expect(res.getBody()).to.be.ok and expect(res.getBody()).to.not.be.ok (no parentheses).
🤖 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.
Duplicate comments:
In `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js`:
- Around line 527-543: The transform currently wraps the chain (e.g., "to.be.ok"
/ "to.not.be.ok") in a callExpression, producing
expect(res.getBody()).to.be.ok(), which throws because "ok" is a chainable
property, not a function; update buildWithBodyTransform to return the
j.memberExpression for expect(res.getBody()) and the identifier chain directly
(i.e., do not wrap the final memberExpression in j.callExpression), so the
entries for 'pm.response.to.be.withBody', 'pm.response.to.not.be.withBody', and
'pm.response.to.be.not.withBody' produce expect(res.getBody()).to.be.ok and
expect(res.getBody()).to.not.be.ok (no parentheses).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: af6927be-70f0-4e6a-ba70-2feac125c67f
📒 Files selected for processing (5)
packages/bruno-converters/src/utils/postman-to-bruno-translator.jspackages/bruno-converters/tests/bruno/bruno-to-postman-translations/response.test.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/combined.test.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/multiline-syntax.test.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@packages/bruno-converters/src/utils/postman-to-bruno-translator.js`:
- Around line 550-577: The translation for pm.response.to.be.withBody (and its
negations pm.response.to.not.be.withBody and pm.response.to.be.not.withBody)
incorrectly maps to expect(res.getBody()).to.be.ok which fails for valid falsy
JSON bodies; change the transforms in postman-to-bruno-translator.js to use an
explicit presence check like expect(res.getBody()).to.notEqual(undefined) /
expect(res.getBody()).toEqual(undefined) (or expect(res.getBody() !== undefined)
as appropriate) instead of truthiness, update the three transform blocks that
build the memberExpression/callExpression for expect(res.getBody()) to use the
!== undefined comparisons for positive and negative cases, and add a regression
test that asserts translation handles falsy JSON bodies (false, 0, null) to
ensure behavior is correct.
🪄 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: 5c30734a-4a5a-469c-baf6-a61c999dad6e
📒 Files selected for processing (3)
packages/bruno-converters/src/utils/postman-status-assertions.jspackages/bruno-converters/src/utils/postman-to-bruno-translator.jspackages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
- Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process.
- Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic.
- Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations.
…version - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process.
…version - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process.
- Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process.
- Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process.
778df6e to
d1fd653
Compare
- Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility.
…ecks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process.
…no#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process.
…rialization addition (#8035) * internal emit chain for clearance * fix: crash ui * fix(ErrorBoundary): ensure cache clearing is awaited before force quitting * test(e2e): environment persistence across collections * test: migration test * Update environment.spec.ts * feat: add missing status assertions and .not negation support (#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process. * feat: support newer Postman export format with collection envelope (#8038) - Updated the Postman collection importer to handle collections wrapped in a { collection: { ... } } format. - Enhanced the parsing logic to extract collection info correctly from both legacy and newer formats. - Added a new test case for importing a Postman v2.1 collection with the wrapped format to ensure compatibility. * fix: reduce padding for dark mode app errors --------- Co-authored-by: sanish chirayath <[email protected]>
…no#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process.
…rialization addition (usebruno#8035) * internal emit chain for clearance * fix: crash ui * fix(ErrorBoundary): ensure cache clearing is awaited before force quitting * test(e2e): environment persistence across collections * test: migration test * Update environment.spec.ts * feat: add missing status assertions and .not negation support (usebruno#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process. * feat: support newer Postman export format with collection envelope (usebruno#8038) - Updated the Postman collection importer to handle collections wrapped in a { collection: { ... } } format. - Enhanced the parsing logic to extract collection info correctly from both legacy and newer formats. - Added a new test case for importing a Postman v2.1 collection with the wrapped format to ensure compatibility. * fix: reduce padding for dark mode app errors --------- Co-authored-by: sanish chirayath <[email protected]>
…no#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process.
…rialization addition (usebruno#8035) * internal emit chain for clearance * fix: crash ui * fix(ErrorBoundary): ensure cache clearing is awaited before force quitting * test(e2e): environment persistence across collections * test: migration test * Update environment.spec.ts * feat: add missing status assertions and .not negation support (usebruno#7660) * feat: add new status assertions and negated variants for response checks - Introduced new status assertions: `pm.response.to.be.info`, `pm.response.to.be.accepted`, `pm.response.to.be.badRequest`, `pm.response.to.be.unauthorized`, `pm.response.to.be.forbidden`, `pm.response.to.be.notFound`, `pm.response.to.be.rateLimited`, and `pm.response.to.be.withoutBody`. - Implemented negated variants for existing assertions, allowing checks like `pm.response.to.not.be.ok` and `pm.response.to.not.be.success`. - Enhanced test coverage to validate the translation of these new assertions and their negated forms in the Postman to Bruno conversion process. * refactor: update response translation for body assertions - Changed the translation logic for `pm.response.to.be.withoutBody` to `pm.response.to.be.withBody`, reflecting the actual body content checks. - Updated corresponding test cases to validate the new assertions and ensure correct translation behavior for body presence checks. - Enhanced negated variants for body assertions to align with the updated logic. * feat: add header transformation methods for Postman to Bruno conversion - Introduced new transformations for `pm.request.headers.prepend`, `pm.request.headers.insert`, and `pm.request.headers.insertAfter` to map to `req.headerList.add`, enhancing header management during the conversion process. - Updated the transformation logic to ensure only the first argument is retained for these methods, aligning with the intended behavior of the header list operations. * refactor: update header transformation logic for Postman to Bruno conversion - Simplified the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to use `res.getHeader` instead of `res.getHeaders`, improving clarity and consistency in the assertions. - Adjusted related test cases to validate the new transformation logic, ensuring accurate translation of header checks in the conversion process. * refactor: update header transformation logic for Postman to Bruno conversion - Enhanced the transformation for `pm.response.to.have.header` and `pm.response.to.not.have.header` to utilize `res.getHeaders()` with lowercased header names, improving consistency and accuracy in header assertions. - Updated related test cases to reflect the new transformation logic, ensuring correct translation of header checks in the conversion process. * feat: add data-driven status assertions for response checks - Introduced a new utility to generate data-driven status assertion entries for `pm.response.to.be.*` checks, including positive and negated variants. - Integrated the new status assertions into the Postman to Bruno translation logic, enhancing the capability to handle various response status checks. - Updated tests to validate the translation of new assertions, ensuring accurate conversion of status checks in the response handling process. * feat: enhance response assertion translations for negated variants - Updated the transformation logic for `pm.response.to.have.*` assertions to include negated variants, allowing for patterns like `pm.response.to.have.not.status`, `pm.response.to.have.not.header`, and `pm.response.to.have.not.body`. - Adjusted related test cases to validate the new translations, ensuring accurate conversion of negated assertions in the response handling process. * refactor: convert status assertion utility to ES module syntax - Changed the export of `buildStatusAssertionEntries` to ES module syntax for better compatibility with modern JavaScript practices. - Updated the import statement in the Postman to Bruno translator to reflect the new export format, ensuring seamless integration of the status assertion utility. * feat: update response body assertion translations to use undefined checks - Modified the transformation logic for `pm.response.to.be.withBody`, `pm.response.to.not.be.withBody`, and `pm.response.to.be.not.withBody` to use an undefined check instead of truthiness, allowing for accurate handling of falsy body values. - Updated related test cases to reflect these changes, ensuring correct translation of body presence assertions in the response handling process. * feat: support newer Postman export format with collection envelope (usebruno#8038) - Updated the Postman collection importer to handle collections wrapped in a { collection: { ... } } format. - Enhanced the parsing logic to extract collection info correctly from both legacy and newer formats. - Added a new test case for importing a Postman v2.1 collection with the wrapped format to ensure compatibility. * fix: reduce padding for dark mode app errors --------- Co-authored-by: sanish chirayath <[email protected]>
Jira
Summary
info(1xx),accepted(202),badRequest(400),unauthorized(401),forbidden(403),notFound(404),rateLimited(429),withBody.notnegation support for allpm.response.to.be.*assertions (bothto.not.be.Xandto.be.not.Xpositions).notnegation forto.have.*assertions:status,header,body(bothto.not.have.Xandto.have.not.Xpositions)to.be.*entries into a data-driven approach (postman-status-assertions.js) to reduce duplicationto.have.*positive/negated pairs using.map()to eliminate near-duplicate transform blockswithBodytranslation to useto.not.equal(undefined)instead ofto.be.oktruthiness check, so falsy JSON bodies (false,0,null) are handled correctlyNew status assertions
pm.response.to.be.info;expect(res.getStatus()).to.be.within(100, 199);pm.response.to.be.accepted;expect(res.getStatus()).to.equal(202);pm.response.to.be.badRequest;expect(res.getStatus()).to.equal(400);pm.response.to.be.unauthorized;expect(res.getStatus()).to.equal(401);pm.response.to.be.forbidden;expect(res.getStatus()).to.equal(403);pm.response.to.be.notFound;expect(res.getStatus()).to.equal(404);pm.response.to.be.rateLimited;expect(res.getStatus()).to.equal(429);pm.response.to.be.withBody;expect(res.getBody()).to.not.equal(undefined);Negated
to.be.*assertionspm.response.to.not.be.ok;expect(res.getStatus()).to.not.be.within(200, 299);pm.response.to.not.be.success;expect(res.getStatus()).to.not.be.within(200, 299);pm.response.to.not.be.info;expect(res.getStatus()).to.not.be.within(100, 199);pm.response.to.not.be.redirection;expect(res.getStatus()).to.not.be.within(300, 399);pm.response.to.not.be.clientError;expect(res.getStatus()).to.not.be.within(400, 499);pm.response.to.not.be.serverError;expect(res.getStatus()).to.not.be.within(500, 599);pm.response.to.not.be.error;expect(res.getStatus()).to.not.be.at.least(400);pm.response.to.not.be.accepted;expect(res.getStatus()).to.not.equal(202);pm.response.to.not.be.badRequest;expect(res.getStatus()).to.not.equal(400);pm.response.to.not.be.unauthorized;expect(res.getStatus()).to.not.equal(401);pm.response.to.not.be.forbidden;expect(res.getStatus()).to.not.equal(403);pm.response.to.not.be.notFound;expect(res.getStatus()).to.not.equal(404);pm.response.to.not.be.rateLimited;expect(res.getStatus()).to.not.equal(429);pm.response.to.not.be.withBody;expect(res.getBody()).to.equal(undefined);Negated
to.have.*assertionspm.response.to.not.have.status(404);expect(res.getStatus()).to.not.equal(404);pm.response.to.not.have.header("X-Error");expect(res.getHeaders()).to.not.have.property("X-Error".toLowerCase());pm.response.to.not.have.header("Content-Type", "text/plain");expect(res.getHeaders()).to.not.have.property("Content-Type".toLowerCase(), "text/plain");pm.response.to.not.have.body("error");expect(res.getBody()).to.not.equal("error");Architecture
postman-status-assertions.js— new data-driven module that generates status assertion entries (positive + both negated positions) from a declarative tablepostman-to-bruno-translator.js—to.have.*pairs consolidated via.map(),withBodykept inline as body-content assertions (not status), status assertions spread at the bottom ofcomplexTransformationsContribution 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.