-
Couldn't load subscription status.
- Fork 239
feat(compass-aggregations): disable search stages for incompatible views COMPASS-9693 #7217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
432a555
fetched is readOnly and serverVersion
DarshanaVenkatesh 642c5b5
add is pipleine search queryable method
DarshanaVenkatesh c50ad1c
Merge branch 'main' into COMPASS-9693
DarshanaVenkatesh 7d234d4
check for incompatibility
DarshanaVenkatesh d49df70
Merge branch 'main' into COMPASS-9693
DarshanaVenkatesh fa480a3
import view pipeline utils
DarshanaVenkatesh 55d219d
update initial state
DarshanaVenkatesh 1d7cdf8
add comment in function
DarshanaVenkatesh f215e0c
Merge branch 'main' into COMPASS-9693
DarshanaVenkatesh 286be91
add test
DarshanaVenkatesh 689c522
remove de seperate check
DarshanaVenkatesh 6c900aa
remove de check and filter out search stages
DarshanaVenkatesh 8de58b2
fix hook issue
DarshanaVenkatesh aa945bd
fix filter on non readonly
DarshanaVenkatesh 19fbf6e
Merge branch 'main' into COMPASS-9693
DarshanaVenkatesh bb161da
fix test syntax
DarshanaVenkatesh f1ed69c
fix lint errors
DarshanaVenkatesh 772d936
have compass and de be same, add new incompatible state
DarshanaVenkatesh 4f9ae4a
change order of stages
DarshanaVenkatesh eb93b6e
Merge branch 'main' into COMPASS-9693
DarshanaVenkatesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
packages/compass-aggregations/src/components/stage-toolbar/stage-operator-select.spec.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import React from 'react'; | ||
| import { | ||
| fireEvent, | ||
| render, | ||
| screen, | ||
| within, | ||
| } from '@mongodb-js/testing-library-compass'; | ||
| import { expect } from 'chai'; | ||
| import type { Stage } from './stage-operator-select'; | ||
| import { StageOperatorSelect } from './stage-operator-select'; | ||
| import Sinon from 'sinon'; | ||
|
|
||
| describe('StageOperatorSelect', () => { | ||
| const mockStages: Stage[] = [ | ||
| { | ||
| name: 'basicStage', | ||
| env: ['on-prem'], | ||
| description: 'basicStage description.', | ||
| }, | ||
| { | ||
| name: 'atlasOnlyStage', | ||
| env: ['atlas'], | ||
| description: 'atlasOnlyStage description.', | ||
| }, | ||
| { | ||
| name: '$search', | ||
| env: ['atlas'], | ||
| description: 'searchStage description.', | ||
| }, | ||
| ]; | ||
|
|
||
| const defaultMockProps = { | ||
| index: 0, | ||
| onChange: Sinon.stub(), | ||
| selectedStage: null, | ||
| isDisabled: false, | ||
| stages: mockStages, | ||
| serverVersion: '8.1.0', | ||
| isReadonlyView: false, | ||
| collectionStats: { | ||
| pipeline: [{ $addFields: { field: 'value' } }], | ||
| }, | ||
| }; | ||
|
|
||
| const renderCombobox = ( | ||
| props: Partial<React.ComponentProps<typeof StageOperatorSelect>> = {} | ||
| ) => { | ||
| return render(<StageOperatorSelect {...defaultMockProps} {...props} />); | ||
| }; | ||
|
|
||
| it('renders the correct descriptions if not in readonly view', () => { | ||
| renderCombobox({ isReadonlyView: false }); | ||
| fireEvent.click(screen.getByRole('combobox')); | ||
| const listbox = screen.getByRole('listbox'); | ||
|
|
||
| expect(within(listbox).getByText('basicStage description.')).to.exist; | ||
| expect(within(listbox).getByText('Atlas only. atlasOnlyStage description.')) | ||
| .to.exist; | ||
| expect(within(listbox).getByText('Atlas only. searchStage description.')).to | ||
| .exist; | ||
| }); | ||
|
|
||
| it('renders the correct descriptions if in readonly view with non queryable pipeline', () => { | ||
| renderCombobox({ | ||
| isReadonlyView: true, | ||
| collectionStats: { | ||
| pipeline: [ | ||
| { $addFields: { field: 'value' } }, | ||
| { project: { newField: 1 } }, | ||
| ], | ||
| }, | ||
| }); | ||
| fireEvent.click(screen.getByRole('combobox')); | ||
| const listbox = screen.getByRole('listbox'); | ||
|
|
||
| expect(within(listbox).getByText('basicStage description.')).to.exist; | ||
| expect(within(listbox).getByText('Atlas only. atlasOnlyStage description.')) | ||
| .to.exist; | ||
| expect( | ||
| within(listbox).getByText( | ||
| 'Atlas only. Only views containing $addFields, $set or $match stages with the $expr operator are compatible with search indexes. searchStage description.' | ||
| ) | ||
| ).to.exist; | ||
| }); | ||
|
|
||
| it('renders the correct descriptions for $search stage in readonly view with incompatible version', () => { | ||
| renderCombobox({ serverVersion: '7.0.0', isReadonlyView: true }); | ||
| fireEvent.click(screen.getByRole('combobox')); | ||
| const listbox = screen.getByRole('listbox'); | ||
|
|
||
| expect(within(listbox).getByText('basicStage description.')).to.exist; | ||
| expect(within(listbox).getByText('Atlas only. atlasOnlyStage description.')) | ||
| .to.exist; | ||
| expect( | ||
| within(listbox).getByText( | ||
| 'Atlas only. Requires MongoDB 8.1+ to run on a view. searchStage description.' | ||
| ) | ||
| ).to.exist; | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this requirement coming from? This is a weird change in compass behavior only for data explorer. Why are you not allowed to see actually working stages in aggregation builder based on a completely different feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this! Sorry for the back and forth. The final implementation will have both of them work the same for compass and de! Will ping you after I update this pr but both will have search stages with the same messages.