Skip to content

Commit e0e7275

Browse files
authored
chore(compass-aggregations): stricter validation for configureStore method COMPASS-6462 COMPASS-6563 (#4124)
* chore(compass-aggregations): avoid loading pipeline from disk multiple times; add options to set initial pipeline value; fix sourcePipeline handling * chore(compass-aggregations): stricter validation and types for createStore method * chore(compass-aggregations): small tweaks to option descriptions
1 parent f1edd91 commit e0e7275

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+433
-532
lines changed

packages/compass-aggregations/src/components/aggregations/aggregations.spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mount } from 'enzyme';
33
import { expect } from 'chai';
44

55
import Aggregations from '../aggregations';
6-
import configureStore from '../../stores';
6+
import configureStore from '../../../test/configure-store';
77
import styles from './aggregations.module.less';
88
import { Provider } from 'react-redux';
99

packages/compass-aggregations/src/components/focus-mode/focus-mode-stage-editor.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
44
import { expect } from 'chai';
55
import { Provider } from 'react-redux';
66

7-
import configureStore from '../../stores/store';
7+
import configureStore from '../../../test/configure-store';
88
import { FocusModeStageEditor } from './focus-mode-stage-editor';
99

1010
const renderFocusModeStageEditor = (
@@ -13,11 +13,7 @@ const renderFocusModeStageEditor = (
1313
render(
1414
<Provider
1515
store={configureStore({
16-
sourcePipeline: [
17-
{ $match: { _id: 1 } },
18-
{ $limit: 10 },
19-
{ $out: 'out' },
20-
],
16+
pipeline: [{ $match: { _id: 1 } }, { $limit: 10 }, { $out: 'out' }],
2117
})}
2218
>
2319
<FocusModeStageEditor index={-1} operator={null} {...props} />

packages/compass-aggregations/src/components/focus-mode/focus-mode-stage-preview.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ import {
1313
OUT_STAGE_PREVIEW_TEXT,
1414
} from '../../constants';
1515

16-
import configureStore from '../../stores/store';
16+
import configureStore from '../../../test/configure-store';
1717

1818
const DEFAULT_PIPELINE: Document[] = [{ $match: { _id: 1 } }, { $limit: 10 }];
1919

2020
const renderFocusModePreview = (
2121
props: Partial<ComponentProps<typeof FocusModePreview>> = {},
22-
sourcePipeline = DEFAULT_PIPELINE
22+
pipeline = DEFAULT_PIPELINE
2323
) => {
2424
render(
2525
<Provider
2626
store={configureStore({
27-
sourcePipeline,
27+
pipeline,
2828
})}
2929
>
3030
<FocusModePreview

packages/compass-aggregations/src/components/focus-mode/focus-mode.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expect } from 'chai';
55
import { Provider } from 'react-redux';
66
import sinon from 'sinon';
77

8-
import configureStore from '../../stores/store';
8+
import configureStore from '../../../test/configure-store';
99
import { FocusMode } from './focus-mode';
1010

1111
const renderFocusMode = (
@@ -14,11 +14,7 @@ const renderFocusMode = (
1414
render(
1515
<Provider
1616
store={configureStore({
17-
sourcePipeline: [
18-
{ $match: { _id: 1 } },
19-
{ $limit: 10 },
20-
{ $out: 'out' },
21-
],
17+
pipeline: [{ $match: { _id: 1 } }, { $limit: 10 }, { $out: 'out' }],
2218
})}
2319
>
2420
<FocusMode

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/index.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { render, screen } from '@testing-library/react';
44
import { expect } from 'chai';
55
import { Provider } from 'react-redux';
66

7-
import configureStore from '../../../stores/store';
7+
import configureStore from '../../../../test/configure-store';
88

99
import { PipelineAsTextWorkspace } from '.';
1010

1111
const renderPipelineAsTextWorkspace = (
1212
props: Partial<ComponentProps<typeof PipelineAsTextWorkspace>> = {}
1313
) => {
1414
render(
15-
<Provider store={configureStore({})}>
15+
<Provider store={configureStore()}>
1616
<PipelineAsTextWorkspace isAutoPreview={true} {...props} />
1717
</Provider>
1818
);

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-editor.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { MongoServerError } from 'mongodb';
55
import { expect } from 'chai';
66
import { Provider } from 'react-redux';
77

8-
import configureStore from '../../../stores/store';
8+
import configureStore from '../../../../test/configure-store';
99

1010
import { PipelineEditor } from './pipeline-editor';
1111
import { PipelineParserError } from '../../../modules/pipeline-builder/pipeline-parser/utils';
@@ -14,7 +14,7 @@ const renderPipelineEditor = (
1414
props: Partial<ComponentProps<typeof PipelineEditor>> = {}
1515
) => {
1616
render(
17-
<Provider store={configureStore({})}>
17+
<Provider store={configureStore()}>
1818
<PipelineEditor
1919
pipelineText="[{$match: {}}]"
2020
syntaxErrors={[]}

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-preview.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expect } from 'chai';
55
import { Provider } from 'react-redux';
66
import userEvent from '@testing-library/user-event';
77

8-
import configureStore from '../../../stores/store';
8+
import configureStore from '../../../../test/configure-store';
99

1010
import { PipelinePreview } from './pipeline-preview';
1111

@@ -142,7 +142,7 @@ describe('PipelinePreview', function () {
142142
isOutStage: true,
143143
},
144144
{
145-
sourcePipeline: `[{$limit: 20}, {$out: "users"}]`,
145+
pipeline: [{ $limit: 20 }, { $out: 'users' }],
146146
}
147147
);
148148

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-stages-preview.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import sinon from 'sinon';
66
import { Provider } from 'react-redux';
77
import userEvent from '@testing-library/user-event';
88

9-
import configureStore from '../../../stores/store';
9+
import configureStore from '../../../../test/configure-store';
1010

1111
import { OutputStagePreview } from './pipeline-stages-preview';
1212

1313
const renderStageBanner = (
1414
props: Partial<ComponentProps<typeof OutputStagePreview>> = {}
1515
) => {
1616
render(
17-
<Provider store={configureStore({})}>
17+
<Provider store={configureStore()}>
1818
<OutputStagePreview
1919
stageOperator="$out"
2020
isAtlas={false}

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-ui-workspace.spec.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import { expect } from 'chai';
44
import { Provider } from 'react-redux';
5-
import configureStore from '../../stores/store';
5+
import configureStore from '../../../test/configure-store';
66
import PipelineBuilderUIWorkspace from './pipeline-builder-ui-workspace';
77

88
const SOURCE_PIPELINE = [
@@ -15,7 +15,7 @@ const renderPipelineBuilderUIWorkspace = (props = {}, options = {}) => {
1515
render(
1616
<Provider
1717
store={configureStore({
18-
sourcePipeline: SOURCE_PIPELINE,
18+
pipeline: SOURCE_PIPELINE,
1919
...options,
2020
})}
2121
>
@@ -91,24 +91,24 @@ describe('PipelineBuilderUIWorkspace [Component]', function () {
9191

9292
context('when pipeline is empty', function () {
9393
it('does not render any stage', function () {
94-
renderPipelineBuilderUIWorkspace({}, { sourcePipeline: [] });
94+
renderPipelineBuilderUIWorkspace({}, { pipeline: [] });
9595
expect(screen.queryByTestId('stage-card')).to.not.exist;
9696
});
9797

9898
it('does not render icon buttons', function () {
99-
renderPipelineBuilderUIWorkspace({}, { sourcePipeline: [] });
99+
renderPipelineBuilderUIWorkspace({}, { pipeline: [] });
100100
expect(screen.queryByTestId('add-stage-icon-button')).to.not.exist;
101101
});
102102

103103
it('renders (text) add stage button', function () {
104-
renderPipelineBuilderUIWorkspace({}, { sourcePipeline: [] });
104+
renderPipelineBuilderUIWorkspace({}, { pipeline: [] });
105105
const button = screen.getByTestId('add-stage');
106106
expect(button).to.exist;
107107
expect(button).to.have.text('Add Stage');
108108
});
109109

110110
it('adds a stage when (text) button is clicked', function () {
111-
renderPipelineBuilderUIWorkspace({}, { sourcePipeline: [] });
111+
renderPipelineBuilderUIWorkspace({}, { pipeline: [] });
112112
const button = screen.getByTestId('add-stage');
113113
button.click();
114114
expect(screen.getAllByTestId('stage-card')).to.have.lengthOf(1);

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-workspace.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { Provider } from 'react-redux';
33
import type { ComponentProps } from 'react';
44
import { render, screen, within } from '@testing-library/react';
55
import { expect } from 'chai';
6-
import configureStore from '../../stores/store';
6+
import configureStore from '../../../test/configure-store';
77
import { PipelineBuilderWorkspace } from './pipeline-builder-workspace';
88

99
const renderBuilderWorkspace = (
1010
props: Partial<ComponentProps<typeof PipelineBuilderWorkspace>> = {}
1111
) => {
1212
return render(
13-
<Provider store={configureStore({})}>
13+
<Provider store={configureStore()}>
1414
<PipelineBuilderWorkspace pipelineMode="as-text" {...props} />
1515
</Provider>
1616
);

0 commit comments

Comments
 (0)