-
Notifications
You must be signed in to change notification settings - Fork 245
test(global-writes): add e2e tests COMPASS-8441 #6430
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
+279
−108
Merged
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
90fbc55
global writes tests
mabaasit 84cdf1c
clean up confirmation action
mabaasit 28b6724
rename func
mabaasit 271ceda
cr feedback
mabaasit e11116c
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit cd12414
timeout
mabaasit 8b3da4a
fix doc
mabaasit 06cea26
cr feedback
mabaasit ad2a360
Merge remote-tracking branch 'origin/main' into COMPASS-8441-global0=…
gribnoysup 957f946
Merge branch 'COMPASS-8441-global0=-writes-tests' of https://github.c…
mabaasit 2d6345d
clean up
mabaasit 994044d
sensable selector
mabaasit 86c73ee
Merge branch 'main' of https://github.com/mongodb-js/compass into COM…
mabaasit ee2ee6d
use timeout for wait condition as well
mabaasit c72a44a
chore(e2e): use different collection names between tests
gribnoysup b62535d
Merge remote-tracking branch 'origin/main' into COMPASS-8441-global0=…
gribnoysup 3ada5f4
chore(e2e): temporarily skip failing test
gribnoysup 9e279bc
update test after incomplete sharding status
paula-stacho 9138b22
Merge branch 'main' into COMPASS-8441-global0=-writes-tests
paula-stacho 27c51b8
try to re-enable the test
paula-stacho 50dfc27
remove comment
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
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
28 changes: 28 additions & 0 deletions
28
packages/compass-e2e-tests/helpers/commands/click-confirmation-action.ts
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,28 @@ | ||
| import type { CompassBrowser } from '../compass-browser'; | ||
| import * as Selectors from '../selectors'; | ||
|
|
||
| export async function clickConfirmationAction( | ||
| browser: CompassBrowser, | ||
| actionButtonSelector: string, | ||
| confirmationText?: string, | ||
| screenshot?: string | ||
| ) { | ||
| await browser.clickVisible(actionButtonSelector); | ||
|
|
||
| const confirmationModal = await browser.$(Selectors.ConfirmationModal); | ||
| await confirmationModal.waitForDisplayed(); | ||
|
|
||
| if (confirmationText) { | ||
| await browser.setValueVisible( | ||
| Selectors.ConfirmationModalInput, | ||
| confirmationText | ||
| ); | ||
| } | ||
|
|
||
| if (screenshot) { | ||
| await browser.screenshot(screenshot); | ||
| } | ||
|
|
||
| await browser.clickVisible(Selectors.confirmationModalConfirmButton()); | ||
| await confirmationModal.waitForDisplayed({ reverse: true }); | ||
| } |
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
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
141 changes: 141 additions & 0 deletions
141
packages/compass-e2e-tests/tests/atlas-cloud/global-writes.test.ts
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,141 @@ | ||
| import { expect } from 'chai'; | ||
| import type { Compass } from '../../helpers/compass'; | ||
| import { cleanup, init, Selectors } from '../../helpers/compass'; | ||
| import type { CompassBrowser } from '../../helpers/compass-browser'; | ||
| import { createGeospatialCollection } from '../../helpers/insert-data'; | ||
| import { | ||
| DEFAULT_CONNECTION_NAMES, | ||
| isTestingAtlasCloudSandbox, | ||
| } from '../../helpers/test-runner-context'; | ||
|
|
||
| type GeoShardingFormData = { | ||
| secondShardKey: string; | ||
| keyType?: 'UNIQUE' | 'HASHED'; | ||
| }; | ||
|
|
||
| type GeoShardingStatus = 'UNSHARDED' | 'SHARDING' | 'SHARD_KEY_CORRECT'; | ||
|
|
||
| async function createGeoShardKey( | ||
| browser: CompassBrowser, | ||
| formData: GeoShardingFormData | ||
| ) { | ||
| await browser.setComboBoxValue( | ||
| Selectors.GlobalWrites.ShardKeyFormSecondKeyInputCombobox, | ||
| formData.secondShardKey | ||
| ); | ||
|
|
||
| if (formData.keyType) { | ||
| await browser.clickVisible( | ||
| Selectors.GlobalWrites.ShardKeyFormAdvancedOptionsToggle | ||
| ); | ||
| await browser.clickParent( | ||
| Selectors.GlobalWrites.shardKeyFormIndexType(formData.keyType) | ||
| ); | ||
| } | ||
| await browser.clickVisible(Selectors.GlobalWrites.ShardKeyFormSubmitButton); | ||
| } | ||
|
|
||
| async function waitForGlobalWritesStatus( | ||
| browser: CompassBrowser, | ||
| nextStatus: GeoShardingStatus | ||
| ) { | ||
| await browser.waitUntil(async () => { | ||
| const content = await browser.$( | ||
| Selectors.GlobalWrites.tabStatus(nextStatus) | ||
| ); | ||
| return await content.isDisplayed(); | ||
| }); | ||
| } | ||
|
|
||
| describe('Global writes', function () { | ||
| let compass: Compass; | ||
| let browser: CompassBrowser; | ||
|
|
||
| beforeEach(async function () { | ||
| // Sharding a collection takes a bit longer | ||
| this.timeout(1000 * 60 * 20); | ||
| compass = await init(this.test?.fullTitle()); | ||
| browser = compass.browser; | ||
| await browser.setupDefaultConnections(); | ||
| }); | ||
|
|
||
| before(function () { | ||
| if (!isTestingAtlasCloudSandbox()) { | ||
| this.skip(); | ||
| } | ||
| }); | ||
|
|
||
| after(async function () { | ||
| await cleanup(compass); | ||
| }); | ||
|
|
||
| it('should be able to shard an unsharded namespace and also unmanage it', async function () { | ||
| await createGeospatialCollection(); | ||
| await browser.connectToDefaults(); | ||
| await browser.navigateToCollectionTab( | ||
| DEFAULT_CONNECTION_NAMES[0], | ||
| 'test', | ||
| 'geospatial', | ||
| 'GlobalWrites' | ||
| ); | ||
|
|
||
| // Initial state is loading | ||
| await waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
|
|
||
| await createGeoShardKey(browser, { | ||
| secondShardKey: 'country', | ||
| keyType: 'HASHED', | ||
| }); | ||
|
|
||
| // Wait for the shard key to be correct. | ||
| await waitForGlobalWritesStatus(browser, 'SHARD_KEY_CORRECT'); | ||
|
|
||
| // Expectations to see the shard key in the UI | ||
| const findingDocumentsText = await browser | ||
| .$(Selectors.GlobalWrites.SampleFindingDocuments) | ||
| .getText(); | ||
|
|
||
| const insertedDocumentsText = await browser | ||
| .$(Selectors.GlobalWrites.SampleInsertingDocuments) | ||
| .getText(); | ||
|
|
||
| expect(findingDocumentsText).to.include('country'); | ||
| expect(insertedDocumentsText).to.include('country'); | ||
|
|
||
| // Unmanage the namespace | ||
| await browser.clickVisible(Selectors.GlobalWrites.UnmanageNamespaceButton); | ||
|
|
||
| // It transitions to the unmanaging state | ||
| await waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
| }); | ||
|
|
||
| it('should be able to shard an unsharded namespace and cancel the operation', async function () { | ||
| await createGeospatialCollection(); | ||
| await browser.connectToDefaults(); | ||
| await browser.navigateToCollectionTab( | ||
| DEFAULT_CONNECTION_NAMES[0], | ||
| 'test', | ||
| 'geospatial', | ||
| 'GlobalWrites' | ||
| ); | ||
|
|
||
| // Initial state is loading | ||
| await waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
|
|
||
| await createGeoShardKey(browser, { | ||
| secondShardKey: 'country', | ||
| keyType: 'UNIQUE', | ||
| }); | ||
|
|
||
| // Wait for the shard key to be correct. | ||
| await waitForGlobalWritesStatus(browser, 'SHARDING'); | ||
|
|
||
| // Cancel the sharding operation. | ||
| await browser.clickConfirmationAction( | ||
| Selectors.GlobalWrites.CancelShardingButton | ||
| ); | ||
|
|
||
| // After its cancelled, it should transition back to the unsharded state | ||
| await waitForGlobalWritesStatus(browser, 'UNSHARDED'); | ||
| }); | ||
| }); | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this will be
INCOMPLETE_SHARDING_SETUPafter #6399, but it's quite likely that this will be merged first, so I'll update the test afterwardsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might even add a test to check that the form is not present at this point, it's important that the key cannot be changed after unmanaging. But again, this hangs on my PR.