-
Notifications
You must be signed in to change notification settings - Fork 246
feat: diagram creation progress COMPASS-9521 #7638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6cc398e
feat: diagram creation progress COMPASS-9521
paula-stacho c33934f
add tests
paula-stacho fc71466
cleanup
paula-stacho dbe8b94
fix styles
paula-stacho 9d480c9
better tests
paula-stacho 1003b11
cleanup and ellipsis
paula-stacho 158dc75
.
paula-stacho bd016ab
void
paula-stacho 80c78ff
preferences
paula-stacho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
packages/compass-data-modeling/src/components/analysis-progress-status.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import React from 'react'; | ||
| import { expect } from 'chai'; | ||
| import { screen, waitFor } from '@mongodb-js/testing-library-compass'; | ||
| import AnalysisProgressStatus from './analysis-progress-status'; | ||
| import { renderWithStore, testConnections } from '../../test/setup-store'; | ||
| import { | ||
| AnalysisProcessActionTypes, | ||
| startAnalysis, | ||
| } from '../store/analysis-process'; | ||
| import { createSandboxFromDefaultPreferences } from 'compass-preferences-model'; | ||
|
|
||
| describe('AnalysisProgressStatus', () => { | ||
| async function renderAnalysisProgressStatus({ | ||
| automaticallyInferRelations = false, | ||
| } = {}) { | ||
| const preferences = await createSandboxFromDefaultPreferences(); | ||
| const { store } = renderWithStore(<AnalysisProgressStatus />, { | ||
| services: { | ||
| preferences, | ||
| }, | ||
| }); | ||
| void store.dispatch( | ||
| startAnalysis( | ||
| 'My Diagram', | ||
| testConnections[0].id, | ||
| 'testDB', | ||
| ['coll1', 'coll2', 'coll3'], | ||
| { automaticallyInferRelations } | ||
| ) | ||
| ); | ||
| return store; | ||
| } | ||
|
|
||
| it('Allows cancellation', async () => { | ||
| const store = await renderAnalysisProgressStatus(); | ||
| expect(screen.getByText('Sampling collections…')).to.be.visible; | ||
| expect(screen.getByText('Cancel')).to.be.visible; | ||
| screen.getByText('Cancel').click(); | ||
| await waitFor(() => { | ||
| expect(store.getState().analysisProgress.step).to.equal('IDLE'); | ||
| expect(store.getState().diagram).to.be.null; | ||
| }); | ||
| }); | ||
|
|
||
| describe('Keeps showing progress along the way', () => { | ||
| it('Without relationship inferring', async () => { | ||
| const store = await renderAnalysisProgressStatus({ | ||
| automaticallyInferRelations: false, | ||
| }); | ||
| expect(screen.getByText('Sampling collections…')).to.be.visible; | ||
| expect(screen.getByText('0/3')).to.be.visible; | ||
|
|
||
| // 2 out of 3 samples fetched, 1 analyzed | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
|
|
||
| expect(screen.getByText('Sampling collections…')).to.be.visible; | ||
| expect(screen.getByText('2/3')).to.be.visible; | ||
|
|
||
| // Last sample fetched | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
|
|
||
| expect(screen.getByText('Analyzing collection schemas…')).to.be.visible; | ||
| expect(screen.getByText('1/3')).to.be.visible; | ||
|
|
||
| // Finish analyzing | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
|
|
||
| expect(screen.queryByText('Inferring relationships between collections…')) | ||
| .not.to.exist; | ||
| expect(screen.getByText('Preparing diagram…')).to.be.visible; | ||
| }); | ||
|
|
||
| it('With relationship inferring', async () => { | ||
| const store = await renderAnalysisProgressStatus({ | ||
| automaticallyInferRelations: true, | ||
| }); | ||
| expect(screen.getByText('Sampling collections…')).to.be.visible; | ||
| expect(screen.getByText('0/3')).to.be.visible; | ||
|
|
||
| // Fetch and analyze all samples | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SAMPLE_FETCHED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_SCHEMA_ANALYZED, | ||
| }); | ||
|
|
||
| expect(screen.getByText('Inferring relationships between collections…')) | ||
| .to.be.visible; | ||
| expect(screen.queryByText('0/3')).not.to.exist; | ||
paula-stacho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Infer some relationships | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_RELATIONS_INFERRED, | ||
| }); | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_RELATIONS_INFERRED, | ||
| }); | ||
|
|
||
| expect(screen.getByText('Inferring relationships between collections…')) | ||
| .to.be.visible; | ||
| expect(screen.queryByText('2/3')).not.to.exist; | ||
|
|
||
| // Finish inferring | ||
| store.dispatch({ | ||
| type: AnalysisProcessActionTypes.NAMESPACE_RELATIONS_INFERRED, | ||
| }); | ||
|
|
||
| expect(screen.getByText('Preparing diagram…')).to.be.visible; | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.