Skip to content

Commit 45a349f

Browse files
authored
feat(schema): enable export schema feature COMPASS-8819 (#6746)
1 parent 02d6d0d commit 45a349f

File tree

3 files changed

+53
-80
lines changed

3 files changed

+53
-80
lines changed

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

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
screenshotIfFailed,
77
skipForWeb,
88
DEFAULT_CONNECTION_NAME_1,
9-
TEST_COMPASS_WEB,
109
} from '../helpers/compass';
1110
import type { Compass } from '../helpers/compass';
1211
import * as Selectors from '../helpers/selectors';
@@ -115,12 +114,7 @@ describe('Collection schema tab', function () {
115114
});
116115
}
117116

118-
describe('with the enableExportSchema feature flag enabled', function () {
119-
beforeEach(async function () {
120-
if (!TEST_COMPASS_WEB)
121-
await browser.setFeature('enableExportSchema', true);
122-
});
123-
117+
describe('with exporting schema', function () {
124118
const filename = 'schema-test-numbers-mongoDBJSON.json';
125119

126120
before(() => {
@@ -140,9 +134,6 @@ describe('Collection schema tab', function () {
140134
);
141135
await browser.clickVisible(Selectors.AnalyzeSchemaButton);
142136

143-
const element = browser.$(Selectors.SchemaFieldList);
144-
await element.waitForDisplayed();
145-
146137
await browser.clickVisible(Selectors.ExportSchemaButton);
147138

148139
const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
@@ -171,58 +162,58 @@ describe('Collection schema tab', function () {
171162
},
172163
},
173164
});
174-
});
175-
176-
it('can download schema (MongoDB $jsonSchema)', async function () {
177-
await browser.navigateToCollectionTab(
178-
DEFAULT_CONNECTION_NAME_1,
179-
'test',
180-
'numbers',
181-
'Schema'
182-
);
183-
await browser.clickVisible(Selectors.AnalyzeSchemaButton);
184-
185-
const element = browser.$(Selectors.SchemaFieldList);
186-
await element.waitForDisplayed();
187-
188-
await browser.clickVisible(Selectors.ExportSchemaButton);
189165

190-
const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
191-
await exportModal.waitForDisplayed();
192-
193-
await browser.clickVisible(
194-
Selectors.exportSchemaFormatOption('mongoDBJSON')
195-
);
196-
197-
const exportSchemaButton = browser.$(
198-
Selectors.ExportSchemaDownloadButton
199-
);
200-
await exportSchemaButton.waitForEnabled();
201-
await exportSchemaButton.click();
202-
203-
const { fileExists, filePath } = await waitForFileDownload(
204-
filename,
205-
browser
206-
);
207-
expect(fileExists).to.be.true;
208-
209-
const content = readFileSync(filePath, 'utf-8');
210-
expect(JSON.parse(content)).to.deep.equal({
211-
$jsonSchema: {
212-
bsonType: 'object',
213-
required: ['_id', 'i', 'j'],
214-
properties: {
215-
_id: {
216-
bsonType: 'objectId',
217-
},
218-
i: {
219-
bsonType: 'int',
220-
},
221-
j: {
222-
bsonType: 'int',
166+
it('can download schema (MongoDB $jsonSchema)', async function () {
167+
await browser.navigateToCollectionTab(
168+
DEFAULT_CONNECTION_NAME_1,
169+
'test',
170+
'numbers',
171+
'Schema'
172+
);
173+
await browser.clickVisible(Selectors.AnalyzeSchemaButton);
174+
175+
const element = browser.$(Selectors.SchemaFieldList);
176+
await element.waitForDisplayed();
177+
178+
await browser.clickVisible(Selectors.ExportSchemaButton);
179+
180+
const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
181+
await exportModal.waitForDisplayed();
182+
183+
await browser.clickVisible(
184+
Selectors.exportSchemaFormatOption('mongoDBJSON')
185+
);
186+
187+
const exportSchemaButton = browser.$(
188+
Selectors.ExportSchemaDownloadButton
189+
);
190+
await exportSchemaButton.waitForEnabled();
191+
await exportSchemaButton.click();
192+
193+
const { fileExists, filePath } = await waitForFileDownload(
194+
filename,
195+
browser
196+
);
197+
expect(fileExists).to.be.true;
198+
199+
const content = readFileSync(filePath, 'utf-8');
200+
expect(JSON.parse(content)).to.deep.equal({
201+
$jsonSchema: {
202+
bsonType: 'object',
203+
required: ['_id', 'i', 'j'],
204+
properties: {
205+
_id: {
206+
bsonType: 'objectId',
207+
},
208+
i: {
209+
bsonType: 'int',
210+
},
211+
j: {
212+
bsonType: 'int',
213+
},
223214
},
224215
},
225-
},
216+
});
226217
});
227218
});
228219
});

packages/compass-preferences-model/src/feature-flags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const featureFlags: Required<{
106106
* Feature flag for export schema. Epic: COMPASS-6862.
107107
*/
108108
enableExportSchema: {
109-
stage: 'development',
109+
stage: 'released',
110110
description: {
111111
short: 'Enable schema export',
112112
},

packages/compass-schema/src/components/schema-toolbar.spec.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,11 @@ describe('SchemaToolbar', function () {
140140
expect(screen.getByTestId('query-bar')).to.be.visible;
141141
});
142142

143-
it('does not render the export schema button', function () {
143+
it('renders the export schema button', function () {
144144
renderSchemaToolbar({
145145
sampleSize: 100,
146146
});
147-
expect(screen.getByText(/documents/)).to.be.visible;
148-
149-
expect(screen.queryByTestId(exportSchemaTestId)).to.not.exist;
150-
});
151-
152-
describe('when rendered with the enableExportSchema feature flag true', function () {
153-
beforeEach(function () {
154-
renderSchemaToolbar(
155-
{
156-
sampleSize: 100,
157-
},
158-
{
159-
enableExportSchema: true,
160-
}
161-
);
162-
});
163147

164-
it('renders the export schema button', function () {
165-
expect(screen.getByTestId(exportSchemaTestId)).to.be.visible;
166-
});
148+
expect(screen.getByTestId(exportSchemaTestId)).to.be.visible;
167149
});
168150
});

0 commit comments

Comments
 (0)