Skip to content

Commit 2057090

Browse files
committed
chore(e2e): add tests for export schema, not complete yet
1 parent e666896 commit 2057090

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

packages/compass-e2e-tests/helpers/selectors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@ export const AggregationWizardSortFormDirectionSelect = (idx: number) =>
10111011

10121012
// Schema tab
10131013
export const AnalyzeSchemaButton = '[data-testid="analyze-schema-button"]';
1014+
export const ExportSchemaButton = '[data-testid="open-schema-export-button"]';
1015+
export const ExportSchemaFormatOptions =
1016+
'[data-testid="export-schema-format-type-box-group"]';
1017+
export const ExportSchemaOutput = '[data-testid="export-schema-content"]';
10141018
export const SchemaFieldList = '[data-testid="schema-field-list"]';
10151019
export const AnalysisMessage =
10161020
'[data-testid="schema-content"] [data-testid="schema-analysis-message"]';

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,41 @@ describe('Collection schema tab', function () {
109109
});
110110
}
111111

112+
describe('with the enableExportSchema feature flag enabled', function () {
113+
beforeEach(async function () {
114+
await browser.setFeature('enableExportSchema', true);
115+
});
116+
117+
it.only('shows an exported schema to copy', async function () {
118+
await browser.navigateToCollectionTab(
119+
DEFAULT_CONNECTION_NAME_1,
120+
'test',
121+
'numbers',
122+
'Schema'
123+
);
124+
await browser.clickVisible(Selectors.AnalyzeSchemaButton);
125+
126+
const element = browser.$(Selectors.SchemaFieldList);
127+
await element.waitForDisplayed();
128+
129+
await browser.clickVisible(Selectors.ExportSchemaButton);
130+
131+
const exportModal = browser.$(Selectors.ExportSchemaFormatOptions);
132+
await exportModal.waitForDisplayed();
133+
134+
// TODO: Check format and then change it.
135+
// await browser.clickVisible(Selectors.AnalyzeSchemaButton);
136+
137+
const exportSchemaContent = browser.$(Selectors.ExportSchemaOutput);
138+
await exportSchemaContent.waitForDisplayed();
139+
// expect(
140+
// await browser.getCodemirrorEditorText(Selectors.ExportSchemaOutput)
141+
// ).to.match(/{\s+\$set:\s+{\s+},?\s+}/);
142+
const text = await browser.$(Selectors.ExportSchemaOutput).getText();
143+
expect(text).to.match('test');
144+
});
145+
});
146+
112147
it('analyzes the schema with a query');
113148
it('can reset the query');
114149
it('can create a geoquery from a map');

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const ExportSchemaModal: React.FunctionComponent<{
152152
{exportStatus === 'complete' && (
153153
<Code
154154
id="export-schema-content"
155-
data-testid="export-to-language-input"
155+
data-testid="export-schema-content"
156156
language="json"
157157
copyable={true}
158158
>
@@ -173,6 +173,14 @@ const ExportSchemaModal: React.FunctionComponent<{
173173
<Button onClick={onClose} variant="default">
174174
Cancel
175175
</Button>
176+
<Button
177+
onClick={() => {
178+
/* TODO(COMPASS-8704) */
179+
}}
180+
variant="primary"
181+
>
182+
Export
183+
</Button>
176184
</ModalFooter>
177185
</Modal>
178186
);

0 commit comments

Comments
 (0)