-
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
Changes from 11 commits
90fbc55
84cdf1c
28b6724
271ceda
e11116c
cd12414
8b3da4a
06cea26
ad2a360
957f946
2d6345d
994044d
86c73ee
ee2ee6d
c72a44a
b62535d
3ada5f4
9e279bc
9138b22
27c51b8
50dfc27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 }); | ||
| } |
| 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'); | ||
| }); | ||
| }); | ||
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.
Small nit: I think you might want to follow @paula-stacho advice here and add both data-testid as a special test selector in addition to the data-status, otherwise the selector you're building is a bit too vague about the context of selection (status of what?) which might make it hard to debug