fix(workspaces): switch to default workspace on close so header shows correct name#8425
fix(workspaces): switch to default workspace on close so header shows correct name#8425ravindra-bruno wants to merge 6 commits into
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:
Walkthrough
ChangesWorkspace Close Cleanup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
26238c9 to
e2d5f26
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/closeWorkspaceAction.spec.js (1)
10-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the pathname fixtures OS-agnostic.
These test fixtures hardcode POSIX separators (
'/default','/team'), which bakes Unix-shaped paths into a cross-platform Electron suite. Build them withpath.join()/path.resolve()instead so the tests exercise realistic Windows/macOS/Linux inputs too. As per path instructions, "File paths must usepath.join()orpath.resolve()instead of hardcoded/or\\separators'."Also applies to: 46-47, 53-54, 60-61, 67-68, 74-75, 81-82
🤖 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-app/src/providers/ReduxStore/slices/workspaces/closeWorkspaceAction.spec.js` at line 10, The workspace pathname fixtures in closeWorkspaceAction.spec.js are hardcoded with POSIX separators, so update the test data to build paths using path.join() or path.resolve() instead of literal slash-based strings. Apply this to DEFAULT_WORKSPACE and the other workspace fixtures in the spec, and ensure the tests reference these path utilities consistently so the suite stays OS-agnostic across Windows, macOS, and Linux.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js`:
- Around line 1003-1009: Switch the active workspace before calling
removeWorkspace so the store never points at a deleted workspace during the
close flow. In the workspace-close logic around removeWorkspace and
switchWorkspace, keep the fallback selection based on
getState().workspaces.workspaces and dispatch
switchWorkspace(defaultWorkspace.uid) first when wasActive is true, then
removeWorkspace(workspaceUid) afterward. This preserves a valid
activeWorkspaceUid for the header immediately after closing the current
workspace.
In
`@packages/bruno-app/src/providers/ReduxStore/slices/workspaces/closeWorkspaceAction.spec.js`:
- Around line 59-64: The workspace-closing spec assertions are too indirect and
can miss the real behavior. Update the tests around closeWorkspaceAction/run so
they assert the exact dispatched action or thunk result: for the
no-scratch-collection case, verify no removeCollection action with a real
payload is dispatched, and for the active-workspace path, spy on or assert
switchWorkspace(DEFAULT_WORKSPACE.uid) directly rather than only checking that
some thunk was dispatched. Use the existing closeWorkspaceAction,
removeCollection, and switchWorkspace symbols to locate the relevant
expectations and make the tests fail on the wrong behavior.
- Around line 27-41: The `run()` helper in `closeWorkspaceAction.spec.js` uses a
stateless `dispatch = jest.fn()`, so `getState()` never reflects reducer updates
and can hide ordering bugs in `closeWorkspaceAction`. Replace it with a small
mocked store/reducer setup that mutates the workspace state when
`removeWorkspace()` and related actions are dispatched, then continue asserting
against the observed `dispatched` and `thunks` from `closeWorkspaceAction` to
verify the real sequencing and fallback behavior.
---
Nitpick comments:
In
`@packages/bruno-app/src/providers/ReduxStore/slices/workspaces/closeWorkspaceAction.spec.js`:
- Line 10: The workspace pathname fixtures in closeWorkspaceAction.spec.js are
hardcoded with POSIX separators, so update the test data to build paths using
path.join() or path.resolve() instead of literal slash-based strings. Apply this
to DEFAULT_WORKSPACE and the other workspace fixtures in the spec, and ensure
the tests reference these path utilities consistently so the suite stays
OS-agnostic across Windows, macOS, and Linux.
🪄 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: 6f2aed2f-b00f-46e8-a3c6-79afb0eda6e8
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/workspaces/closeWorkspaceAction.spec.js
|
@ravindra-bruno Can we get a e2e test for this in place ? |
Added the e2e tests for the closing workspace and returning to default. |
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 `@tests/workspace/close-workspace-returns-to-default.spec.ts`:
- Around line 33-57: The workspace-close spec is using brittle CSS class and
index-based selectors for the workspace switcher and actions menu. Update the
locators in close-workspace-returns-to-default.spec.ts to use stable test ids,
roles, labels, or existing helper-backed selectors instead of .switcher-name,
.workspace-actions-trigger, and .first(). Prefer storing these stable locators
in variables and reusing them in the affected test steps so the assertions and
clicks remain resilient to UI refactors.
🪄 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: beadaed6-90a8-46f9-9bf5-0b8894760112
📒 Files selected for processing (1)
tests/workspace/close-workspace-returns-to-default.spec.ts
…ions in close-workspace e2e
Description
BRU3663
Contribution Checklist:
Summary by CodeRabbit