Skip to content
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

test(global-writes): add e2e tests COMPASS-8441 #6430

Merged
merged 21 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .evergreen/start-atlas-cloud-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds
#
# - Setup a new org and project. Save the org id and project id for later.
#
# - Add test payment details within the organization (Billing) to be able to
# create clusters.
#
# - Create a new API key (Access Manager > Project Access > Create Application >
# API Key) for the project you created and save the public and private keys.
#
Expand Down Expand Up @@ -101,10 +104,11 @@ export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME"
export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD"

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

echo "Waiting for the deployment to be provisioned..."
atlascli clusters watch $ATLAS_CLUSTER_NAME
Expand Down
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
Expand Up @@ -2,6 +2,14 @@ import type { CompassBrowser } from '../compass-browser';
import * as Selectors from '../selectors';
import type { WorkspaceTabSelectorOptions } from '../selectors';

type CollectionWorkspaceSubTab =
| 'Documents'
| 'Aggregations'
| 'Schema'
| 'Indexes'
| 'Validation'
| 'GlobalWrites';

async function navigateToCollection(
browser: CompassBrowser,
connectionName: string,
Expand Down Expand Up @@ -50,12 +58,8 @@ export async function navigateToCollectionTab(
connectionName: string,
dbName: string,
collectionName: string,
tabName:
| 'Documents'
| 'Aggregations'
| 'Schema'
| 'Indexes'
| 'Validation' = 'Documents',
tabName: CollectionWorkspaceSubTab = 'Documents',

closeExistingTabs = true
): Promise<void> {
await navigateToCollection(
Expand Down Expand Up @@ -83,12 +87,7 @@ export async function navigateToCollectionTab(

export async function navigateWithinCurrentCollectionTabs(
browser: CompassBrowser,
tabName:
| 'Documents'
| 'Aggregations'
| 'Schema'
| 'Indexes'
| 'Validation' = 'Documents'
tabName: CollectionWorkspaceSubTab = 'Documents'
): Promise<void> {
const tab = browser.$(Selectors.collectionSubTab(tabName));
const selectedTab = browser.$(Selectors.collectionSubTab(tabName, true));
Expand All @@ -108,13 +107,7 @@ async function waitUntilActiveCollectionTab(
connectionName: string,
dbName: string,
collectionName: string,
tabName:
| 'Documents'
| 'Aggregations'
| 'Schema'
| 'Indexes'
| 'Validation'
| null = null
tabName: CollectionWorkspaceSubTab | null = null
) {
const options: WorkspaceTabSelectorOptions = {
type: 'Collection',
Expand All @@ -132,12 +125,7 @@ async function waitUntilActiveCollectionTab(

export async function waitUntilActiveCollectionSubTab(
browser: CompassBrowser,
tabName:
| 'Documents'
| 'Aggregations'
| 'Schema'
| 'Indexes'
| 'Validation' = 'Documents'
tabName: CollectionWorkspaceSubTab = 'Documents'
) {
await browser.$(Selectors.collectionSubTab(tabName, true)).waitForDisplayed();
}
Expand Down
18 changes: 4 additions & 14 deletions packages/compass-e2e-tests/helpers/commands/hide-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ export async function hideIndex(
await indexComponent.waitForDisplayed();

await browser.hover(indexComponentSelector);
await browser.clickVisible(
`${indexComponentSelector} ${Selectors.HideIndexButton}`
await browser.clickConfirmationAction(
`${indexComponentSelector} ${Selectors.HideIndexButton}`,
undefined,
screenshotName
);

const hideModal = await browser.$(Selectors.ConfirmationModal);
await hideModal.waitForDisplayed();

if (screenshotName) {
await browser.screenshot(screenshotName);
}

await browser.clickVisible(Selectors.confirmationModalConfirmButton());

await hideModal.waitForDisplayed({ reverse: true });

const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName));
await hiddenBadge.waitForDisplayed();
}
1 change: 1 addition & 0 deletions packages/compass-e2e-tests/helpers/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ export * from './hide-visible-toasts';
export * from './sidebar-collection';
export * from './read-first-document-content';
export * from './read-stage-operators';
export * from './click-confirmation-action';
17 changes: 4 additions & 13 deletions packages/compass-e2e-tests/helpers/commands/unhide-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@ export async function unhideIndex(
await indexComponent.waitForDisplayed();

await browser.hover(indexComponentSelector);
await browser.clickVisible(
`${indexComponentSelector} ${Selectors.UnhideIndexButton}`
await browser.clickConfirmationAction(
`${indexComponentSelector} ${Selectors.UnhideIndexButton}`,
undefined,
screenshotName
);

const unhideModal = await browser.$(Selectors.ConfirmationModal);
await unhideModal.waitForDisplayed();

if (screenshotName) {
await browser.screenshot(screenshotName);
}

await browser.clickVisible(Selectors.confirmationModalConfirmButton());

await unhideModal.waitForDisplayed({ reverse: true });

const hiddenBadge = await browser.$(Selectors.HiddenIndexBadge(indexName));
await hiddenBadge.waitForDisplayed({ reverse: true });
}
6 changes: 4 additions & 2 deletions packages/compass-e2e-tests/helpers/insert-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ export async function createNumbersStringCollection(
);
}

export async function createGeospatialCollection(): Promise<void> {
export async function createGeospatialCollection(
name = 'geospatial'
): Promise<void> {
await Promise.all(
test_dbs.map(async (db) => {
const lon = () => Math.random() * 360 - 180;
const lat = () => Math.random() * 180 - 90;

await db.collection('geospatial').insertMany(
await db.collection(name).insertMany(
[...Array(1000).keys()].map(() => ({
location: { type: 'Point', coordinates: [lon(), lat()] },
}))
Expand Down
20 changes: 20 additions & 0 deletions packages/compass-e2e-tests/helpers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,3 +1400,23 @@ export const ProxyCustomButton =

// Close tab confirmation
export const ConfirmTabCloseModal = '[data-testid="confirm-tab-close"]';

export const GlobalWrites = {
tabStatus: (status: string) =>
`[data-testid="globalwrites-content"] > [data-status="${status.toLowerCase()}"]`,

ShardKeyFormSecondKeyInputCombobox:
'[data-testid="second-shard-key"] [role="combobox"] input',
ShardKeyFormAdvancedOptionsToggle:
'[data-testid="advanced-shard-key-configuration"]',
shardKeyFormIndexType: (type: 'UNIQUE' | 'HASHED') =>
`[data-testid="${type.toLowerCase()}-index"]`,
ShardKeyFormSubmitButton: '[data-testid="shard-collection-button"]',

CancelShardingButton: '[data-testid="cancel-sharding-btn"]',
UnmanageNamespaceButton: '[data-testid="unmanage-collection-button"]',
ManageNamespaceButton: '[data-testid="manage-collection-button"]',

SampleFindingDocuments: '[data-testid="sample-finding-documents"]',
SampleInsertingDocuments: '[data-testid="sample-inserting-documents"]',
};
2 changes: 1 addition & 1 deletion packages/compass-e2e-tests/helpers/test-runner-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function buildCommonArgs(yargs: Argv) {
.option('webdriver-waitfor-timeout', {
type: 'number',
description: 'Set a custom default webdriver waitFor timeout',
default: 120_000, // webdriver default is 3000ms
default: 1000 * 60 * 2, // 2min, webdriver default is 3s
})
.option('webdriver-waitfor-interval', {
type: 'number',
Expand Down
Loading
Loading