Skip to content

fix: allow users to clear the cache, adds environment tests and re-serialization addition - #8035

Merged
bijin-bruno merged 9 commits into
usebruno:mainfrom
sid-bruno:fix/boundary-clear-snapshot
May 19, 2026
Merged

bijin-bruno merged 9 commits into
usebruno:mainfrom
sid-bruno:fix/boundary-clear-snapshot

Conversation

@sid-bruno

@sid-bruno sid-bruno commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Implements internal events to delegate clear cache handling to snapshots
  • re-serialization addition for environment path when restoring non-mounted collections

JIRA

JIRA 2

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

    • Added "Clear caches on quit" checkbox to the error recovery dialog so caches can be cleared when quitting.
    • Environment selections now persist per collection across app restarts.
  • Bug Fixes

    • Improved environment state preservation when switching between collections.
  • Tests

    • Added end-to-end snapshot tests validating collection environment persistence and migration.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR adds a "Clear caches on quit" option to ErrorBoundary that invokes an IPC to clear persisted snapshot state; the main process emits an internal reset event handled by snapshot IPC which calls SnapshotManager.resetSnapshot(); middleware tweaks preserve environment selections; Playwright tests validate persistence across restarts.

Changes

Cache-clear on force quit with environment persistence

Layer / File(s) Summary
Frontend UI and IPC invocation
packages/bruno-app/src/pages/ErrorBoundary/index.js
ErrorBoundary state includes clearCaches boolean; new async clearCache() invokes main:cache-clear; UI adds "Clear caches on quit" checkbox and quit handler that conditionally awaits cache clear before calling forceQuit().
Electron main process cache-clear and snapshot reset
packages/bruno-electron/src/index.js, packages/bruno-electron/src/ipc/snapshot.js, packages/bruno-electron/src/services/snapshot/index.js
Main registers main:cache-clear handler that emits internal:snapshot:reset; snapshot IPC listens and calls snapshotManager.resetSnapshot(); SnapshotManager rewrites/deletes persisted workspace and collection fields (activeWorkspacePath, lastActiveCollectionPathname, tabs, activeTab).
Snapshot middleware collection and environment preservation
packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/middleware.js
Prefer snapshot lookup by workspace+collection key with fallback to path; preserve existing environment values when collection unmounted and Redux lacks environment data; serialized selectedEnvironment is derived from computed selectedEnvironmentName.
Playwright tests for environment persistence across restarts
tests/snapshots/environment/environment.spec.ts, tests/snapshots/environment/fixtures/collection/*, tests/snapshots/environment/init-user-data/*
Adds helper to read ui-state-snapshot.json, fixtures for collection/request/environment, and three tests validating legacy migration and multi-collection selected-environment persistence across app restarts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🧹 When errors come and the app must depart,
A checkbox whispers: "Clear caches, restart."
IPC calls travel from UI to main,
Snapshot reset clears state without pain,
Tests hum a tune as environments remain.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main changes: cache clearing functionality, environment tests, and snapshot re-serialization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sid-bruno
sid-bruno marked this pull request as ready for review May 19, 2026 12:45
Copilot AI review requested due to automatic review settings May 19, 2026 12:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 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-app/src/pages/ErrorBoundary/index.js`:
- Around line 83-89: The onClick handler currently returns immediately after
awaiting clearCache() when this.state.clearCaches is true, preventing
this.forceQuit() from running; change the control flow in the onClick handler
(the async arrow function attached to the button) so that after awaiting
this.clearCache() it still calls this.forceQuit() (e.g., await
this.clearCache(); this.forceQuit(); or call this.forceQuit() in a finally
block) ensuring both clearCache() and forceQuit() execute for the clear-caches
path.
- Around line 72-83: The new quit controls in ErrorBoundary (the checkbox bound
to this.state.clearCaches and the Force Quit anchor with the onClick handler)
lack stable selectors for Playwright; add data-testid attributes to both
elements (e.g., add data-testid="quit-clear-caches-checkbox" to the <input> tied
to this.setState({ clearCaches: ... }) and data-testid="force-quit-button" to
the <a> that triggers the Force Quit onClick) so tests can reliably target them
while leaving existing behavior and classNames untouched.

In `@packages/bruno-electron/src/services/snapshot/index.js`:
- Around line 190-200: resetSnapshot currently clears per-collection tabs but
leaves collection.activeTab intact and doesn't invalidate this._lookupCache,
which can cause stale or inconsistent reads; update resetSnapshot to also clear
any activeTab fields (e.g., set collection.activeTab = undefined or null
alongside tabs = []) for each collection and remove or reset this._lookupCache
(e.g., this._lookupCache = new Map() or delete/clear it) after updating store
entries so the in-memory lookup state is consistent with the cleared store.
🪄 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: f18f6711-69cd-49c4-a848-a8016f61a4ba

📥 Commits

Reviewing files that changed from the base of the PR and between cea883e and 804a634.

📒 Files selected for processing (4)
  • packages/bruno-app/src/pages/ErrorBoundary/index.js
  • packages/bruno-electron/src/index.js
  • packages/bruno-electron/src/ipc/snapshot.js
  • packages/bruno-electron/src/services/snapshot/index.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a “clear caches on quit” flow from the renderer error boundary into the Electron main process, delegating the actual persisted UI-state reset to the snapshot service so the app can restart with a cleaner slate after a forced quit.

Changes:

  • Added resetSnapshot() to clear parts of the persisted UI snapshot (workspace + tab state).
  • Added an internal IPC event to trigger snapshot reset, and a public main:cache-clear handler callable from the renderer.
  • Updated the ErrorBoundary UI to optionally clear caches before force-quitting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/bruno-electron/src/services/snapshot/index.js Introduces resetSnapshot() to reset persisted snapshot state (workspaces/collections).
packages/bruno-electron/src/ipc/snapshot.js Adds an internal IPC event to invoke snapshot reset from main process code.
packages/bruno-electron/src/index.js Registers main:cache-clear IPC handler and delegates to internal snapshot reset event.
packages/bruno-app/src/pages/ErrorBoundary/index.js Adds “Clear caches on quit” option and invokes main:cache-clear before force quit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tests/snapshots/environment.spec.ts (2)

52-53: ⚡ Quick win

Replace fixed sleeps with event-driven waits.

The waitForTimeout(2000) calls make this suite slower and flaky; prefer waiting on a deterministic state change (UI or snapshot condition) instead.

As per coding guidelines: "Replace magic timeouts with event-driven waits in E2E tests."

Also applies to: 147-155

🤖 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/snapshots/environment.spec.ts` around lines 52 - 53, Replace the fixed
2s sleep by waiting for a deterministic condition: replace the
page.waitForTimeout(2000) calls with event-driven waits (e.g.,
page.waitForSelector(...) for a UI element that indicates the test snapshot is
ready, page.waitForFunction(...) for a JS state flag, or
page.waitForResponse(...) if waiting on network); only call
closeElectronApp(app) after that condition resolves. Update every occurrence
(including the other occurrences around the 147-155 block) to wait on a specific
UI/state/response signal instead of using page.waitForTimeout, referencing the
existing page.waitForTimeout and closeElectronApp(app) calls to locate and
modify them.

46-49: ⚡ Quick win

Use stable locators (and reuse locator variables) for environment assertions.

Using .current-environment ties tests to CSS class structure; prefer role/label/test-id selectors and store the locator in a variable for reuse.

As per coding guidelines: "Replace brittle text/index selectors with role, label, test id, or stable user-facing selectors."

Also applies to: 73-77, 113-120, 146-155

🤖 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/snapshots/environment.spec.ts` around lines 46 - 49, The assertions use
a brittle CSS selector page.locator('.current-environment'); change them to a
stable user-facing locator (e.g., use page.getByTestId or
page.getByRole/getByLabel) and store that locator in a variable for reuse before
the assertions (e.g., const env = page.getByTestId('current-environment') or
similar), then replace the three occurrences (the ones around the openCollection
calls and the other ranges noted) to use env and env.toContainText('local-a') /
env.toContainText('local-b'); keep the existing openCollection(page, 'Collection
B') calls untouched.
🤖 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/snapshots/environment.spec.ts`:
- Around line 52-53: Replace the fixed 2s sleep by waiting for a deterministic
condition: replace the page.waitForTimeout(2000) calls with event-driven waits
(e.g., page.waitForSelector(...) for a UI element that indicates the test
snapshot is ready, page.waitForFunction(...) for a JS state flag, or
page.waitForResponse(...) if waiting on network); only call
closeElectronApp(app) after that condition resolves. Update every occurrence
(including the other occurrences around the 147-155 block) to wait on a specific
UI/state/response signal instead of using page.waitForTimeout, referencing the
existing page.waitForTimeout and closeElectronApp(app) calls to locate and
modify them.
- Around line 46-49: The assertions use a brittle CSS selector
page.locator('.current-environment'); change them to a stable user-facing
locator (e.g., use page.getByTestId or page.getByRole/getByLabel) and store that
locator in a variable for reuse before the assertions (e.g., const env =
page.getByTestId('current-environment') or similar), then replace the three
occurrences (the ones around the openCollection calls and the other ranges
noted) to use env and env.toContainText('local-a') /
env.toContainText('local-b'); keep the existing openCollection(page, 'Collection
B') calls untouched.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 240105b2-55fe-4046-8bf8-6056e5837e0a

📥 Commits

Reviewing files that changed from the base of the PR and between 1d0a61a and cb01d6e.

📒 Files selected for processing (4)
  • packages/bruno-app/src/pages/ErrorBoundary/index.js
  • packages/bruno-app/src/providers/ReduxStore/middlewares/snapshot/middleware.js
  • packages/bruno-electron/src/services/snapshot/index.js
  • tests/snapshots/environment.spec.ts

@sid-bruno sid-bruno changed the title fix: allow users to clear the cache fix: allow users to clear the cache, adds environment tests and re-serialization addition May 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
tests/snapshots/environment/environment.spec.ts (3)

47-47: ⚡ Quick win

Replace fixed 2s sleeps with event-driven waits.

These waits are brittle and slow; prefer waiting on observable outcomes (UI state or snapshot persistence) instead of time-based delays.

Suggested direction
- await page.waitForTimeout(2000);
+ await expect.poll(() => {
+   const snapshot = readSnapshot(userDataPath);
+   return Array.isArray(snapshot?.collections) ? snapshot.collections.length : 0;
+ }).toBeGreaterThan(0);
As per coding guidelines, "Replace magic timeouts with event-driven waits in E2E tests."

Also applies to: 100-100, 195-195, 199-199, 203-203

🤖 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/snapshots/environment/environment.spec.ts` at line 47, The fixed 2s
sleeps (calls to page.waitForTimeout) are brittle; replace each occurrence
(e.g., the call at tests/snapshots/environment/environment.spec.ts and the other
occurrences around lines referenced) with event-driven waits such as
page.waitForSelector, page.waitForResponse, or page.waitForFunction that assert
the observable outcome you care about (UI element visible/hidden, network
response for snapshot save, or a DOM state change) so tests wait for the
specific condition (snapshot persistence or UI update) instead of a magic
timeout; locate and update each page.waitForTimeout usage in this spec to wait
for the relevant selector/response/function that indicates the operation
completed.

43-43: ⚡ Quick win

Use stable locators (prefer data-testid) instead of raw class selectors.

.current-environment is fragile for UI refactors; use a stable test id/role and a locator variable reused across assertions.

As per coding guidelines, "Replace brittle text/index selectors with role, label, test id, or stable user-facing selectors" and "Add data-testid to testable elements for Playwright in React components".

Also applies to: 94-94, 96-96, 161-161, 164-164, 167-167, 194-194, 198-198, 202-202

🤖 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/snapshots/environment/environment.spec.ts` at line 43, Replace fragile
class-based selectors like page.locator('.current-environment') with stable test
ids and reuse a locator variable: update the React components to add data-testid
attributes (e.g., data-testid="current-environment") and then in the test file
replace direct calls to page.locator('.current-environment') with a single const
currentEnv = page.getByTestId('current-environment') (or
page.locator('[data-testid="current-environment"]')) and use that variable for
all assertions (including the other occurrences mentioned) to make locators
stable and DRY.

35-68: ⚡ Quick win

Guarantee Electron app cleanup with try/finally in each test.

If an assertion fails before the close step, app processes can leak and hurt parallel safety.

As per coding guidelines, "E2E tests must be parallel-safe" and "Every E2E test should follow the Arrange-Act-Assert-Cleanup shape".

Also applies to: 77-128, 139-219

🤖 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/snapshots/environment/environment.spec.ts` around lines 35 - 68, Wrap
the test body that calls launchElectronApp(...) and uses waitForReadyPage(...)
in a try/finally so closeElectronApp(app) is always called (and page cleanup if
needed) — move the assertions and interactions (openCollection, expects,
snapshot reads) into the try block and call closeElectronApp(app) in finally,
guarding against undefined app; apply the same try/finally pattern to the other
tests noted (the blocks covering lines 77-128 and 139-219) to guarantee Electron
process cleanup and parallel-safe E2E tests.
🤖 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/snapshots/environment/environment.spec.ts`:
- Line 32: The test entry uses test.only which will cause the rest of the suite
to be skipped; change the invocation in the "migrates legacy snapshot format and
preserves selected collection environment" test from test.only to test (i.e.,
remove .only) so the full test suite runs, then run the test suite locally to
confirm no accidental focused tests remain; look for the test declaration string
to locate the correct spot.

---

Nitpick comments:
In `@tests/snapshots/environment/environment.spec.ts`:
- Line 47: The fixed 2s sleeps (calls to page.waitForTimeout) are brittle;
replace each occurrence (e.g., the call at
tests/snapshots/environment/environment.spec.ts and the other occurrences around
lines referenced) with event-driven waits such as page.waitForSelector,
page.waitForResponse, or page.waitForFunction that assert the observable outcome
you care about (UI element visible/hidden, network response for snapshot save,
or a DOM state change) so tests wait for the specific condition (snapshot
persistence or UI update) instead of a magic timeout; locate and update each
page.waitForTimeout usage in this spec to wait for the relevant
selector/response/function that indicates the operation completed.
- Line 43: Replace fragile class-based selectors like
page.locator('.current-environment') with stable test ids and reuse a locator
variable: update the React components to add data-testid attributes (e.g.,
data-testid="current-environment") and then in the test file replace direct
calls to page.locator('.current-environment') with a single const currentEnv =
page.getByTestId('current-environment') (or
page.locator('[data-testid="current-environment"]')) and use that variable for
all assertions (including the other occurrences mentioned) to make locators
stable and DRY.
- Around line 35-68: Wrap the test body that calls launchElectronApp(...) and
uses waitForReadyPage(...) in a try/finally so closeElectronApp(app) is always
called (and page cleanup if needed) — move the assertions and interactions
(openCollection, expects, snapshot reads) into the try block and call
closeElectronApp(app) in finally, guarding against undefined app; apply the same
try/finally pattern to the other tests noted (the blocks covering lines 77-128
and 139-219) to guarantee Electron process cleanup and parallel-safe E2E tests.
🪄 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: 237cb745-4303-4db4-9ffa-67c6c8692068

📥 Commits

Reviewing files that changed from the base of the PR and between cb01d6e and 7e8b022.

📒 Files selected for processing (7)
  • packages/bruno-electron/src/ipc/snapshot.js
  • tests/snapshots/environment/environment.spec.ts
  • tests/snapshots/environment/fixtures/collection/bruno.json
  • tests/snapshots/environment/fixtures/collection/environments/local.bru
  • tests/snapshots/environment/fixtures/collection/request.bru
  • tests/snapshots/environment/init-user-data/preferences.json
  • tests/snapshots/environment/init-user-data/ui-state-snapshot.json
✅ Files skipped from review due to trivial changes (4)
  • tests/snapshots/environment/init-user-data/ui-state-snapshot.json
  • tests/snapshots/environment/init-user-data/preferences.json
  • tests/snapshots/environment/fixtures/collection/environments/local.bru
  • tests/snapshots/environment/fixtures/collection/request.bru
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-electron/src/ipc/snapshot.js

bijin-bruno
bijin-bruno previously approved these changes May 19, 2026
sanish-bruno and others added 3 commits May 19, 2026 22:35
…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.
…sebruno#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.
@bijin-bruno
bijin-bruno merged commit e86a036 into usebruno:main May 19, 2026
36 of 40 checks passed
lyh543 pushed a commit to lyh543/bruno that referenced this pull request May 22, 2026
…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]>
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants