Skip to content

Commit d08a392

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents 20ce918 + 93d3a30 commit d08a392

File tree

60 files changed

+2477
-916
lines changed

Some content is hidden

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

60 files changed

+2477
-916
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@ Moses Yang <[email protected]>
109109
Moses Yang <[email protected]>
110110
Jimmy Choi <[email protected]>
111111
112+
Nataly Carbonell <[email protected]>

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Sun Aug 03 2025.
2+
This document was automatically generated on Sun Aug 10 2025.
33

44
## List of dependencies
55

configs/eslint-config-compass/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"@babel/eslint-parser": "^7.14.3",
1919
"@mongodb-js/eslint-config-devtools": "^0.9.9",
2020
"@mongodb-js/eslint-plugin-compass": "^1.2.13",
21-
"@typescript-eslint/eslint-plugin": "^8.38.0",
22-
"@typescript-eslint/parser": "^8.38.0",
21+
"@typescript-eslint/eslint-plugin": "^8.39.0",
22+
"@typescript-eslint/parser": "^8.39.0",
2323
"eslint": "^8.57.1",
2424
"eslint-config-prettier": "^8.3.0",
2525
"eslint-plugin-chai-friendly": "^1.1.0",

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
> the tracking plan for the specific Compass version you can use the following
77
> URL: `https://github.com/mongodb-js/compass/blob/<compass version>/docs/tracking-plan.md`
88
9-
Generated on Sun, Aug 3, 2025
9+
Generated on Sun, Aug 10, 2025
1010

1111
## Table of Contents
1212

package-lock.json

Lines changed: 130 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
"cheerio": "1.0.0-rc.10"
105105
},
106106
"@mongodb-js/eslint-config-devtools": {
107-
"@typescript-eslint/eslint-plugin": "^8.38.0",
108-
"@typescript-eslint/parser": "^8.38.0",
107+
"@typescript-eslint/eslint-plugin": "^8.39.0",
108+
"@typescript-eslint/parser": "^8.39.0",
109109
"eslint": "^8.57.1",
110110
"eslint-plugin-jsx-a11y": "^6.10.2",
111111
"eslint-plugin-react": "^7.37.5",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { MockDataGeneratorStep } from './types';
2+
3+
export const StepButtonLabelMap = {
4+
[MockDataGeneratorStep.AI_DISCLAIMER]: 'Use Natural Language',
5+
[MockDataGeneratorStep.SCHEMA_CONFIRMATION]: 'Confirm',
6+
[MockDataGeneratorStep.SCHEMA_EDITOR]: 'Next',
7+
[MockDataGeneratorStep.DOCUMENT_COUNT]: 'Next',
8+
[MockDataGeneratorStep.PREVIEW_DATA]: 'Generate Script',
9+
[MockDataGeneratorStep.GENERATE_DATA]: 'Done',
10+
} as const;
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { expect } from 'chai';
2+
import React from 'react';
3+
import { render, screen } from '@mongodb-js/testing-library-compass';
4+
import Sinon from 'sinon';
5+
import MockDataGeneratorModal from './mock-data-generator-modal';
6+
import { MockDataGeneratorStep } from './types';
7+
import { StepButtonLabelMap } from './constants';
8+
9+
describe('MockDataGeneratorModal', () => {
10+
const sandbox = Sinon.createSandbox();
11+
let onOpenChange: Sinon.SinonSpy;
12+
13+
beforeEach(() => {
14+
onOpenChange = sandbox.spy();
15+
});
16+
17+
afterEach(() => {
18+
sandbox.restore();
19+
});
20+
21+
function renderModal({
22+
isOpen = true,
23+
currentStep = MockDataGeneratorStep.AI_DISCLAIMER,
24+
} = {}) {
25+
function MockDataGeneratorModalWrapper() {
26+
const [currentStepStateMock, onCurrentStepChangeStateMock] =
27+
React.useState<MockDataGeneratorStep>(currentStep);
28+
return (
29+
<MockDataGeneratorModal
30+
isOpen={isOpen}
31+
onOpenChange={onOpenChange}
32+
currentStep={currentStepStateMock}
33+
onCurrentStepChange={(step) => {
34+
onCurrentStepChangeStateMock(step);
35+
}}
36+
/>
37+
);
38+
}
39+
return render(<MockDataGeneratorModalWrapper />);
40+
}
41+
42+
it('renders the modal when isOpen is true', () => {
43+
renderModal();
44+
45+
expect(screen.getByTestId('generate-mock-data-modal')).to.exist;
46+
});
47+
48+
it('does not render the modal when isOpen is false', () => {
49+
renderModal({ isOpen: false });
50+
51+
expect(screen.queryByTestId('generate-mock-data-modal')).to.not.exist;
52+
});
53+
54+
it('calls onOpenChange(false) when the modal is closed', () => {
55+
renderModal();
56+
57+
screen.getByLabelText('Close modal').click();
58+
59+
expect(onOpenChange.calledOnceWith(false)).to.be.true;
60+
});
61+
62+
it('calls onOpenChange(false) when the cancel button is clicked', () => {
63+
renderModal();
64+
65+
screen.getByText('Cancel').click();
66+
67+
expect(onOpenChange.calledOnceWith(false)).to.be.true;
68+
});
69+
70+
it('disables the Back button on the first step', () => {
71+
renderModal();
72+
73+
expect(
74+
screen.getByRole('button', { name: 'Back' }).getAttribute('aria-disabled')
75+
).to.equal('true');
76+
});
77+
78+
describe('when rendering the modal in a specific step', () => {
79+
const steps = Object.keys(
80+
StepButtonLabelMap
81+
) as unknown as MockDataGeneratorStep[];
82+
83+
steps.forEach((currentStep) => {
84+
it(`renders the button with the correct label when the user is in step "${currentStep}"`, () => {
85+
renderModal({ currentStep });
86+
expect(screen.getByTestId('next-step-button')).to.have.text(
87+
StepButtonLabelMap[currentStep]
88+
);
89+
});
90+
});
91+
});
92+
});
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import React from 'react';
2+
3+
import {
4+
css,
5+
ModalBody,
6+
ModalHeader,
7+
spacing,
8+
} from '@mongodb-js/compass-components';
9+
10+
import {
11+
Button,
12+
Modal,
13+
ModalFooter,
14+
ButtonVariant,
15+
} from '@mongodb-js/compass-components';
16+
import { MockDataGeneratorStep } from './types';
17+
import { StepButtonLabelMap } from './constants';
18+
import { getNextStep, getPreviousStep } from './utils';
19+
20+
const footerStyles = css`
21+
flex-direction: row;
22+
justify-content: space-between;
23+
`;
24+
25+
const rightButtonsStyles = css`
26+
display: flex;
27+
gap: ${spacing[200]}px;
28+
flex-direction: row;
29+
`;
30+
31+
interface Props {
32+
isOpen: boolean;
33+
onOpenChange: (isOpen: boolean) => void;
34+
currentStep: MockDataGeneratorStep;
35+
onCurrentStepChange: (step: MockDataGeneratorStep) => void;
36+
}
37+
38+
const MockDataGeneratorModal = ({
39+
isOpen,
40+
onOpenChange,
41+
currentStep,
42+
onCurrentStepChange,
43+
}: Props) => {
44+
const onNext = () => {
45+
const nextStep = getNextStep(currentStep);
46+
onCurrentStepChange(nextStep);
47+
};
48+
49+
const onBack = () => {
50+
const previousStep = getPreviousStep(currentStep);
51+
onCurrentStepChange(previousStep);
52+
};
53+
54+
const onCancel = () => {
55+
onOpenChange(false);
56+
};
57+
58+
return (
59+
<Modal
60+
open={isOpen}
61+
setOpen={(open) => onOpenChange(open)}
62+
data-testid="generate-mock-data-modal"
63+
>
64+
<ModalHeader title="Generate Mock Data" />
65+
<ModalBody>
66+
{/* TODO: Render actual step content here based on currentStep. (CLOUDP-333851) */}
67+
<div data-testid={`generate-mock-data-step-${currentStep}`} />
68+
</ModalBody>
69+
<ModalFooter className={footerStyles}>
70+
<Button
71+
onClick={onBack}
72+
disabled={currentStep === MockDataGeneratorStep.AI_DISCLAIMER}
73+
>
74+
Back
75+
</Button>
76+
<div className={rightButtonsStyles}>
77+
<Button onClick={onCancel}>Cancel</Button>
78+
<Button
79+
variant={ButtonVariant.Primary}
80+
onClick={onNext}
81+
data-testid="next-step-button"
82+
>
83+
{StepButtonLabelMap[currentStep]}
84+
</Button>
85+
</div>
86+
</ModalFooter>
87+
</Modal>
88+
);
89+
};
90+
91+
export default MockDataGeneratorModal;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export enum MockDataGeneratorStep {
2+
AI_DISCLAIMER = 'AI_DISCLAIMER',
3+
SCHEMA_CONFIRMATION = 'SCHEMA_CONFIRMATION',
4+
SCHEMA_EDITOR = 'SCHEMA_EDITOR',
5+
DOCUMENT_COUNT = 'DOCUMENT_COUNT',
6+
PREVIEW_DATA = 'PREVIEW_DATA',
7+
GENERATE_DATA = 'GENERATE_DATA',
8+
}

0 commit comments

Comments
 (0)