Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 50 additions & 59 deletions packages/compass-e2e-tests/tests/collection-schema-tab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
screenshotIfFailed,
skipForWeb,
DEFAULT_CONNECTION_NAME_1,
TEST_COMPASS_WEB,
} from '../helpers/compass';
import type { Compass } from '../helpers/compass';
import * as Selectors from '../helpers/selectors';
Expand Down Expand Up @@ -115,12 +114,7 @@ describe('Collection schema tab', function () {
});
}

describe('with the enableExportSchema feature flag enabled', function () {
beforeEach(async function () {
if (!TEST_COMPASS_WEB)
await browser.setFeature('enableExportSchema', true);
});

describe('with exporting schema', function () {
const filename = 'schema-test-numbers-mongoDBJSON.json';

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

const element = browser.$(Selectors.SchemaFieldList);
await element.waitForDisplayed();

await browser.clickVisible(Selectors.ExportSchemaButton);

const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
Expand Down Expand Up @@ -171,58 +162,58 @@ describe('Collection schema tab', function () {
},
},
});
});

it('can download schema (MongoDB $jsonSchema)', async function () {
await browser.navigateToCollectionTab(
DEFAULT_CONNECTION_NAME_1,
'test',
'numbers',
'Schema'
);
await browser.clickVisible(Selectors.AnalyzeSchemaButton);

const element = browser.$(Selectors.SchemaFieldList);
await element.waitForDisplayed();

await browser.clickVisible(Selectors.ExportSchemaButton);

const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
await exportModal.waitForDisplayed();

await browser.clickVisible(
Selectors.exportSchemaFormatOption('mongoDBJSON')
);

const exportSchemaButton = browser.$(
Selectors.ExportSchemaDownloadButton
);
await exportSchemaButton.waitForEnabled();
await exportSchemaButton.click();

const { fileExists, filePath } = await waitForFileDownload(
filename,
browser
);
expect(fileExists).to.be.true;

const content = readFileSync(filePath, 'utf-8');
expect(JSON.parse(content)).to.deep.equal({
$jsonSchema: {
bsonType: 'object',
required: ['_id', 'i', 'j'],
properties: {
_id: {
bsonType: 'objectId',
},
i: {
bsonType: 'int',
},
j: {
bsonType: 'int',
it('can download schema (MongoDB $jsonSchema)', async function () {
await browser.navigateToCollectionTab(
DEFAULT_CONNECTION_NAME_1,
'test',
'numbers',
'Schema'
);
await browser.clickVisible(Selectors.AnalyzeSchemaButton);

const element = browser.$(Selectors.SchemaFieldList);
await element.waitForDisplayed();

await browser.clickVisible(Selectors.ExportSchemaButton);

const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
await exportModal.waitForDisplayed();

await browser.clickVisible(
Selectors.exportSchemaFormatOption('mongoDBJSON')
);

const exportSchemaButton = browser.$(
Selectors.ExportSchemaDownloadButton
);
await exportSchemaButton.waitForEnabled();
await exportSchemaButton.click();

const { fileExists, filePath } = await waitForFileDownload(
filename,
browser
);
expect(fileExists).to.be.true;

const content = readFileSync(filePath, 'utf-8');
expect(JSON.parse(content)).to.deep.equal({
$jsonSchema: {
bsonType: 'object',
required: ['_id', 'i', 'j'],
properties: {
_id: {
bsonType: 'objectId',
},
i: {
bsonType: 'int',
},
j: {
bsonType: 'int',
},
},
},
},
});
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-preferences-model/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const featureFlags: Required<{
* Feature flag for export schema. Epic: COMPASS-6862.
*/
enableExportSchema: {
stage: 'development',
stage: 'released',
description: {
short: 'Enable schema export',
},
Expand Down
22 changes: 2 additions & 20 deletions packages/compass-schema/src/components/schema-toolbar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,11 @@ describe('SchemaToolbar', function () {
expect(screen.getByTestId('query-bar')).to.be.visible;
});

it('does not render the export schema button', function () {
it('renders the export schema button', function () {
renderSchemaToolbar({
sampleSize: 100,
});
expect(screen.getByText(/documents/)).to.be.visible;

expect(screen.queryByTestId(exportSchemaTestId)).to.not.exist;
});

describe('when rendered with the enableExportSchema feature flag true', function () {
beforeEach(function () {
renderSchemaToolbar(
{
sampleSize: 100,
},
{
enableExportSchema: true,
}
);
});

it('renders the export schema button', function () {
expect(screen.getByTestId(exportSchemaTestId)).to.be.visible;
});
expect(screen.getByTestId(exportSchemaTestId)).to.be.visible;
});
});
Loading