Skip to content

Commit 5c93a7f

Browse files
committed
tests and update message
1 parent 8b28447 commit 5c93a7f

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

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

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('SchemaToolbar', function () {
4040
<MockQueryBarPlugin {...(queryBarProps as any)}>
4141
<SchemaToolbar
4242
analysisState="complete"
43-
errorMessage={''}
43+
error={undefined}
4444
isOutdated={false}
4545
onAnalyzeSchemaClicked={() => {}}
4646
onResetClicked={() => {}}
@@ -60,23 +60,38 @@ describe('SchemaToolbar', function () {
6060
sinon.restore();
6161
});
6262

63-
it("renders errors when they're passed", function () {
64-
renderSchemaToolbar({
65-
analysisState: 'error',
66-
errorMessage: 'test error msg',
67-
});
68-
69-
expect(screen.getByText(testErrorMessage)).to.be.visible;
70-
expect(screen.getByTestId('schema-toolbar-error-message')).to.be.visible;
71-
});
63+
describe('errors', function () {
64+
it('renders general error', function () {
65+
renderSchemaToolbar({
66+
analysisState: 'initial',
67+
error: {
68+
errorType: 'GENERAL',
69+
errorMessage: 'test error msg',
70+
},
71+
});
7272

73-
it('does not render errors when the analysis state is not error', function () {
74-
renderSchemaToolbar({
75-
errorMessage: 'test error msg',
73+
expect(screen.getByText(testErrorMessage)).to.be.visible;
74+
expect(screen.getByTestId('schema-toolbar-error-message')).to.be.visible;
7675
});
7776

78-
expect(screen.queryByText(testErrorMessage)).to.not.exist;
79-
expect(screen.queryByTestId('schema-toolbar-error-message')).to.not.exist;
77+
it('renders complexity abort error', function () {
78+
renderSchemaToolbar({
79+
analysisState: 'initial',
80+
error: {
81+
errorType: 'HIGH_COMPLEXITY',
82+
errorMessage: 'test error msg',
83+
},
84+
});
85+
86+
expect(screen.getByTestId('schema-toolbar-complexity-abort-message')).to
87+
.be.visible;
88+
expect(
89+
screen.getByRole('link', { name: 'Learn more' })
90+
).to.have.attribute(
91+
'href',
92+
'https://www.mongodb.com/docs/manual/data-modeling/design-antipatterns/bloated-documents/'
93+
);
94+
});
8095
});
8196

8297
it('renders the sample size count', function () {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ const SchemaToolbar: React.FunctionComponent<SchemaToolbarProps> = ({
144144
data-testid="schema-toolbar-complexity-abort-message"
145145
dismissible={true}
146146
>
147-
Analysis was aborted due to: Fields count above 1000. Consider
148-
breaking up your data into more collections with smaller documents,
149-
and using references to consolidate the data you need.&nbsp;
150-
<Link href="https://www.mongodb.com/docs/atlas/schema-suggestions/reduce-document-size/">
147+
The analysis was aborted because the number of fields exceeds 1000.
148+
Consider breaking up your data into more collections with smaller
149+
documents, and using references to consolidate the data you
150+
need.&nbsp;
151+
<Link href="https://www.mongodb.com/docs/manual/data-modeling/design-antipatterns/bloated-documents/">
151152
Learn more
152153
</Link>
153154
</Banner>

packages/compass-schema/src/stores/store.spec.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('Schema Store', function () {
100100
});
101101

102102
it('defaults the error to empty', function () {
103-
expect(store.getState().schemaAnalysis.errorMessage).to.equal('');
103+
expect(store.getState().schemaAnalysis.error).to.be.undefined;
104104
});
105105

106106
it('defaults the schema to null', function () {
@@ -112,15 +112,10 @@ describe('Schema Store', function () {
112112
sampleStub.resolves([{ name: 'Hans' }, { name: 'Greta' }]);
113113
await store.dispatch(startAnalysis());
114114
expect(sampleStub).to.have.been.called;
115-
const {
116-
analysisState,
117-
errorMessage,
118-
schema,
119-
resultId,
120-
analysisStartTime,
121-
} = store.getState().schemaAnalysis;
115+
const { analysisState, error, schema, resultId, analysisStartTime } =
116+
store.getState().schemaAnalysis;
122117
expect(analysisState).to.equal('complete');
123-
expect(!!errorMessage).to.be.false;
118+
expect(error).to.be.undefined;
124119
expect(analysisStartTime).to.not.be.undefined;
125120
expect(analysisStartTime).to.be.greaterThan(1000);
126121
expect(schema).not.to.be.null;

0 commit comments

Comments
 (0)