fix(shell): set database on initial load COMPASS-9204#7927
Open
fix(shell): set database on initial load COMPASS-9204#7927
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes COMPASS-9204 by ensuring the Shell tab applies the intended database context on first open (from a collection) by deferring the “initial eval applied” state until mongoshVersion is known, and adds an e2e regression test that opens the shell from the collection header.
Changes:
- Gate initial-eval “applied” state on
mongoshVersionso the first Shell render can correctly apply theuse <db>initial eval. - Add e2e coverage for opening Shell from a collection header and verifying db/collection context.
- Refactor e2e shell commands to distinguish opening Shell from the sidebar vs. from a collection header.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/compass-shell/src/plugin.spec.tsx | Tightens unit test to assert the runtime evaluates version() on initial render. |
| packages/compass-shell/src/components/compass-shell/tab-compass-shell.tsx | Adjusts initial-eval gating to wait for mongoshVersion and reorders initialization. |
| packages/compass-e2e-tests/tests/shell.test.ts | Adds regression e2e test for shell opened from collection header and updates existing shell open path. |
| packages/compass-e2e-tests/helpers/selectors.ts | Adds selector for the collection header “open shell” button. |
| packages/compass-e2e-tests/helpers/mongo-clients.ts | Adds dataset helper to create a non-default db/collection for the new e2e. |
| packages/compass-e2e-tests/helpers/commands/shell-eval.ts | Exposes shell output reader and updates shell opening path to sidebar-specific helper. |
| packages/compass-e2e-tests/helpers/commands/open-shell.ts | Splits shell opening into openShellFromSidebar and openShellFromCollectionHeader. |
| packages/compass-collection/src/components/collection-header-actions/collection-header-actions.tsx | Adds data-testid to support e2e opening Shell from the collection header. |
packages/compass-shell/src/components/compass-shell/tab-compass-shell.tsx
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
COMPASS-9204
Previously we wouldn't use the database the user's collection it in when they click the shell button. It would only use the database after the first time the shell was rendered. This ensures we use the intended database.
Added a regression e2e test.