Skip to content

Commit 5a3fe53

Browse files
mabaasitgribnoysuppaula-stacho
authored
test(global-writes): add e2e tests COMPASS-8441 (#6430)
* global writes tests * clean up confirmation action * rename func * cr feedback * timeout * fix doc * cr feedback * clean up * sensable selector * use timeout for wait condition as well * chore(e2e): use different collection names between tests * chore(e2e): temporarily skip failing test * update test after incomplete sharding status * try to re-enable the test * remove comment --------- Co-authored-by: Sergey Petushkov <[email protected]> Co-authored-by: Paula Stachova <[email protected]>
1 parent 25ac91d commit 5a3fe53

18 files changed

+279
-108
lines changed

.evergreen/start-atlas-cloud-cluster.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds
1919
#
2020
# - Setup a new org and project. Save the org id and project id for later.
2121
#
22+
# - Add test payment details within the organization (Billing) to be able to
23+
# create clusters.
24+
#
2225
# - Create a new API key (Access Manager > Project Access > Create Application >
2326
# API Key) for the project you created and save the public and private keys.
2427
#
@@ -101,10 +104,11 @@ export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
101104
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"
102105

103106
echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..."
104-
atlascli clusters create $ATLAS_CLUSTER_NAME \
107+
(atlascli clusters create $ATLAS_CLUSTER_NAME \
105108
--provider AWS \
106109
--region US_EAST_1 \
107-
--tier M10
110+
--tier M10 \
111+
--type GEOSHARDED || true) # can error if custom name was provided, will fail on next step if it's not expected failure
108112

109113
echo "Waiting for the deployment to be provisioned..."
110114
atlascli clusters watch $ATLAS_CLUSTER_NAME
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { CompassBrowser } from '../compass-browser';
2+
import * as Selectors from '../selectors';
3+
4+
export async function clickConfirmationAction(
5+
browser: CompassBrowser,
6+
actionButtonSelector: string,
7+
confirmationText?: string,
8+
screenshot?: string
9+
) {
10+
await browser.clickVisible(actionButtonSelector);
11+
12+
const confirmationModal = await browser.$(Selectors.ConfirmationModal);
13+
await confirmationModal.waitForDisplayed();
14+
15+
if (confirmationText) {
16+
await browser.setValueVisible(
17+
Selectors.ConfirmationModalInput,
18+
confirmationText
19+
);
20+
}
21+
22+
if (screenshot) {
23+
await browser.screenshot(screenshot);
24+
}
25+
26+
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
27+
await confirmationModal.waitForDisplayed({ reverse: true });
28+
}

packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import type { CompassBrowser } from '../compass-browser';
22
import * as Selectors from '../selectors';
33
import type { WorkspaceTabSelectorOptions } from '../selectors';
44

5+
type CollectionWorkspaceSubTab =
6+
| 'Documents'
7+
| 'Aggregations'
8+
| 'Schema'
9+
| 'Indexes'
10+
| 'Validation'
11+
| 'GlobalWrites';
12+
513
async function navigateToCollection(
614
browser: CompassBrowser,
715
connectionName: string,
@@ -50,12 +58,8 @@ export async function navigateToCollectionTab(
5058
connectionName: string,
5159
dbName: string,
5260
collectionName: string,
53-
tabName:
54-
| 'Documents'
55-
| 'Aggregations'
56-
| 'Schema'
57-
| 'Indexes'
58-
| 'Validation' = 'Documents',
61+
tabName: CollectionWorkspaceSubTab = 'Documents',
62+
5963
closeExistingTabs = true
6064
): Promise<void> {
6165
await navigateToCollection(
@@ -83,12 +87,7 @@ export async function navigateToCollectionTab(
8387

8488
export async function navigateWithinCurrentCollectionTabs(
8589
browser: CompassBrowser,
86-
tabName:
87-
| 'Documents'
88-
| 'Aggregations'
89-
| 'Schema'
90-
| 'Indexes'
91-
| 'Validation' = 'Documents'
90+
tabName: CollectionWorkspaceSubTab = 'Documents'
9291
): Promise<void> {
9392
const tab = browser.$(Selectors.collectionSubTab(tabName));
9493
const selectedTab = browser.$(Selectors.collectionSubTab(tabName, true));
@@ -108,13 +107,7 @@ async function waitUntilActiveCollectionTab(
108107
connectionName: string,
109108
dbName: string,
110109
collectionName: string,
111-
tabName:
112-
| 'Documents'
113-
| 'Aggregations'
114-
| 'Schema'
115-
| 'Indexes'
116-
| 'Validation'
117-
| null = null
110+
tabName: CollectionWorkspaceSubTab | null = null
118111
) {
119112
const options: WorkspaceTabSelectorOptions = {
120113
type: 'Collection',
@@ -132,12 +125,7 @@ async function waitUntilActiveCollectionTab(
132125

133126
export async function waitUntilActiveCollectionSubTab(
134127
browser: CompassBrowser,
135-
tabName:
136-
| 'Documents'
137-
| 'Aggregations'
138-
| 'Schema'
139-
| 'Indexes'
140-
| 'Validation' = 'Documents'
128+
tabName: CollectionWorkspaceSubTab = 'Documents'
141129
) {
142130
await browser.$(Selectors.collectionSubTab(tabName, true)).waitForDisplayed();
143131
}

packages/compass-e2e-tests/helpers/commands/hide-index.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,11 @@ export async function hideIndex(
1111
await indexComponent.waitForDisplayed();
1212

1313
await browser.hover(indexComponentSelector);
14-
await browser.clickVisible(
15-
`${indexComponentSelector} ${Selectors.HideIndexButton}`
14+
await browser.clickConfirmationAction(
15+
`${indexComponentSelector} ${Selectors.HideIndexButton}`,
16+
undefined,
17+
screenshotName
1618
);
17-
18-
const hideModal = await browser.$(Selectors.ConfirmationModal);
19-
await hideModal.waitForDisplayed();
20-
21-
if (screenshotName) {
22-
await browser.screenshot(screenshotName);
23-
}
24-
25-
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
26-
27-
await hideModal.waitForDisplayed({ reverse: true });
28-
2919
const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName));
3020
await hiddenBadge.waitForDisplayed();
3121
}

packages/compass-e2e-tests/helpers/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ export * from './hide-visible-toasts';
6464
export * from './sidebar-collection';
6565
export * from './read-first-document-content';
6666
export * from './read-stage-operators';
67+
export * from './click-confirmation-action';

packages/compass-e2e-tests/helpers/commands/unhide-index.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,12 @@ export async function unhideIndex(
1111
await indexComponent.waitForDisplayed();
1212

1313
await browser.hover(indexComponentSelector);
14-
await browser.clickVisible(
15-
`${indexComponentSelector} ${Selectors.UnhideIndexButton}`
14+
await browser.clickConfirmationAction(
15+
`${indexComponentSelector} ${Selectors.UnhideIndexButton}`,
16+
undefined,
17+
screenshotName
1618
);
1719

18-
const unhideModal = await browser.$(Selectors.ConfirmationModal);
19-
await unhideModal.waitForDisplayed();
20-
21-
if (screenshotName) {
22-
await browser.screenshot(screenshotName);
23-
}
24-
25-
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
26-
27-
await unhideModal.waitForDisplayed({ reverse: true });
28-
2920
const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName));
3021
await hiddenBadge.waitForDisplayed({ reverse: true });
3122
}

packages/compass-e2e-tests/helpers/insert-data.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ export async function createNumbersStringCollection(
168168
);
169169
}
170170

171-
export async function createGeospatialCollection(): Promise<void> {
171+
export async function createGeospatialCollection(
172+
name = 'geospatial'
173+
): Promise<void> {
172174
await Promise.all(
173175
test_dbs.map(async (db) => {
174176
const lon = () => Math.random() * 360 - 180;
175177
const lat = () => Math.random() * 180 - 90;
176178

177-
await db.collection('geospatial').insertMany(
179+
await db.collection(name).insertMany(
178180
[...Array(1000).keys()].map(() => ({
179181
location: { type: 'Point', coordinates: [lon(), lat()] },
180182
}))

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,3 +1400,23 @@ export const ProxyCustomButton =
14001400

14011401
// Close tab confirmation
14021402
export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]';
1403+
1404+
export const GlobalWrites = {
1405+
tabStatus: (status: string) =>
1406+
`[data-testid="globalwrites-content"] > [data-status="${status.toLowerCase()}"]`,
1407+
1408+
ShardKeyFormSecondKeyInputCombobox:
1409+
'[data-testid="second-shard-key"] [role="combobox"] input',
1410+
ShardKeyFormAdvancedOptionsToggle:
1411+
'[data-testid="advanced-shard-key-configuration"]',
1412+
shardKeyFormIndexType: (type: 'UNIQUE' | 'HASHED') =>
1413+
`[data-testid="${type.toLowerCase()}-index"]`,
1414+
ShardKeyFormSubmitButton: '[data-testid="shard-collection-button"]',
1415+
1416+
CancelShardingButton: '[data-testid="cancel-sharding-btn"]',
1417+
UnmanageNamespaceButton: '[data-testid="unmanage-collection-button"]',
1418+
ManageNamespaceButton: '[data-testid="manage-collection-button"]',
1419+
1420+
SampleFindingDocuments: '[data-testid="sample-finding-documents"]',
1421+
SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]',
1422+
};

packages/compass-e2e-tests/helpers/test-runner-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function buildCommonArgs(yargs: Argv) {
3939
.option('webdriver-waitfor-timeout', {
4040
type: 'number',
4141
description: 'Set a custom default webdriver waitFor timeout',
42-
default: 120_000, // webdriver default is 3000ms
42+
default: 1000 * 60 * 2, // 2min, webdriver default is 3s
4343
})
4444
.option('webdriver-waitfor-interval', {
4545
type: 'number',

0 commit comments

Comments
 (0)