Skip to content

Commit d5c9b51

Browse files
committed
fixup: use the accessors, fix e2e
1 parent 2057090 commit d5c9b51

File tree

14 files changed

+1166
-230
lines changed

14 files changed

+1166
-230
lines changed

package-lock.json

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

packages/compass-aggregations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"mongodb-instance-model": "^12.25.5",
9292
"mongodb-ns": "^2.4.2",
9393
"mongodb-query-parser": "^4.2.3",
94-
"mongodb-schema": "^12.2.0",
94+
"mongodb-schema": "^12.3.2",
9595
"prop-types": "^15.7.2",
9696
"re-resizable": "^6.9.0",
9797
"react": "^17.0.2",

packages/compass-e2e-tests/tests/collection-schema-tab.test.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('Collection schema tab', function () {
114114
await browser.setFeature('enableExportSchema', true);
115115
});
116116

117-
it.only('shows an exported schema to copy', async function () {
117+
it('shows an exported schema to copy', async function () {
118118
await browser.navigateToCollectionTab(
119119
DEFAULT_CONNECTION_NAME_1,
120120
'test',
@@ -131,16 +131,27 @@ describe('Collection schema tab', function () {
131131
const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
132132
await exportModal.waitForDisplayed();
133133

134-
// TODO: Check format and then change it.
135-
// await browser.clickVisible(Selectors.AnalyzeSchemaButton);
136-
137134
const exportSchemaContent = browser.$(Selectors.ExportSchemaOutput);
138135
await exportSchemaContent.waitForDisplayed();
139-
// expect(
140-
// await browser.getCodemirrorEditorText(Selectors.ExportSchemaOutput)
141-
// ).to.match(/{\s+\$set:\s+{\s+},?\s+}/);
142136
const text = await browser.$(Selectors.ExportSchemaOutput).getText();
143-
expect(text).to.match('test');
137+
const parsedText = JSON.parse(text);
138+
delete parsedText.$defs;
139+
expect(parsedText).to.deep.equal({
140+
$schema: 'https://json-schema.org/draft/2020-12/schema',
141+
type: 'object',
142+
required: ['_id', 'i', 'j'],
143+
properties: {
144+
_id: {
145+
$ref: '#/$defs/ObjectId',
146+
},
147+
i: {
148+
type: 'integer',
149+
},
150+
j: {
151+
type: 'integer',
152+
},
153+
},
154+
});
144155
});
145156
});
146157

packages/compass-field-store/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@mongodb-js/compass-logging": "^1.5.5",
7474
"hadron-app-registry": "^9.3.5",
7575
"lodash": "^4.17.21",
76-
"mongodb-schema": "^12.2.0",
76+
"mongodb-schema": "^12.3.2",
7777
"react": "^17.0.2",
7878
"react-redux": "^8.1.3",
7979
"redux": "^4.2.1",

packages/compass-generative-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"compass-preferences-model": "^2.32.5",
6363
"hadron-app-registry": "^9.3.5",
6464
"mongodb": "^6.12.0",
65-
"mongodb-schema": "^12.2.0",
65+
"mongodb-schema": "^12.3.2",
6666
"react": "^17.0.2",
6767
"react-redux": "^8.1.3",
6868
"redux": "^4.2.1",

packages/compass-import-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"mongodb-data-service": "^22.24.5",
6969
"mongodb-ns": "^2.4.2",
7070
"mongodb-query-parser": "^4.2.3",
71-
"mongodb-schema": "^12.2.0",
71+
"mongodb-schema": "^12.3.2",
7272
"papaparse": "^5.3.2",
7373
"react": "^17.0.2",
7474
"react-redux": "^8.1.3",

packages/compass-query-bar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"mongodb-ns": "^2.4.2",
8888
"mongodb-query-parser": "^4.2.3",
8989
"mongodb-query-util": "^2.3.5",
90-
"mongodb-schema": "^12.2.0",
90+
"mongodb-schema": "^12.3.2",
9191
"react": "^17.0.2",
9292
"react-redux": "^8.1.3",
9393
"redux": "^4.2.1",

packages/compass-schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"lodash": "^4.17.21",
9292
"mongodb": "^6.12.0",
9393
"mongodb-query-util": "^2.3.5",
94-
"mongodb-schema": "^12.2.0",
94+
"mongodb-schema": "^12.3.2",
9595
"numeral": "^1.5.6",
9696
"prop-types": "^15.7.2",
9797
"react": "^17.0.2",

packages/compass-schema/src/components/export-schema-modal.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ const contentContainerStyles = css({
3939
paddingBottom: spacing[400],
4040
});
4141

42+
const codeStyles = css({
43+
maxHeight: `${spacing[1600] * 4 - spacing[800]}px`,
44+
overflow: 'auto',
45+
});
46+
47+
const footerStyles = css({
48+
display: 'flex',
49+
gap: spacing[200],
50+
});
51+
4252
const exportSchemaFormatOptions: {
4353
title: string;
4454
id: SchemaFormat;
@@ -135,7 +145,7 @@ const ExportSchemaModal: React.FunctionComponent<{
135145
The JSON Extended format is deprecated and will be removed in a
136146
future release.
137147
</strong>
138-
We&apos;re transitioning to a better format. Discover the new
148+
&nbsp;We&apos;re transitioning to a better format. Discover the new
139149
experience by selecting a relevant format from above.
140150
</Banner>
141151
)}
@@ -154,6 +164,7 @@ const ExportSchemaModal: React.FunctionComponent<{
154164
id="export-schema-content"
155165
data-testid="export-schema-content"
156166
language="json"
167+
className={codeStyles}
157168
copyable={true}
158169
>
159170
{exportedSchema ?? 'Empty'}
@@ -169,7 +180,7 @@ const ExportSchemaModal: React.FunctionComponent<{
169180
)}
170181
</div>
171182
</ModalBody>
172-
<ModalFooter>
183+
<ModalFooter className={footerStyles}>
173184
<Button onClick={onClose} variant="default">
174185
Cancel
175186
</Button>

packages/compass-schema/src/modules/schema-analysis.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expect } from 'chai';
44
import mongoDBSchemaAnalyzeSchema from 'mongodb-schema';
55
import type { Schema } from 'mongodb-schema';
66
import { createNoopLogger } from '@mongodb-js/compass-logging/provider';
7+
import { isInternalFieldPath } from 'hadron-document';
78

89
import {
910
analyzeSchema,
@@ -159,7 +160,12 @@ describe('schema-analysis', function () {
159160
count: 2,
160161
};
161162

162-
expect(schema).to.deep.equal(expectedSchema);
163+
const internalSchema = await schema!.getInternalSchema();
164+
internalSchema.fields = internalSchema.fields.filter(
165+
({ path }) => !isInternalFieldPath(path[0])
166+
);
167+
168+
expect(internalSchema).to.deep.equal(expectedSchema);
163169
});
164170

165171
it('adds promoteValues: false so the analyzer can report more accurate types', async function () {

0 commit comments

Comments
 (0)