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

chore(e2e): webdriverio 9 #6559

Merged
merged 11 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3,344 changes: 1,674 additions & 1,670 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions packages/compass-e2e-tests/.depcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ ignores:
- '@mongodb-js/mocha-config-compass'
- 'compass-e2e-tests'
- '@mongodb-js/compass-web'
# TODO(COMPASS-8312): depcheck doesn't count this dependency because it's a
# types only import and the depcheck parser is resolving the @types/<name>
# package as a dep instead
- 'puppeteer'
# needed for getPuppeteer() to work
- 'puppeteer-core'
10 changes: 4 additions & 6 deletions packages/compass-e2e-tests/helpers/commands/add-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function addCollection(
collectionOptions?: AddCollectionOptions,
screenshotPath?: string
): Promise<void> {
const createModalElement = await browser.$(Selectors.CreateCollectionModal);
const createModalElement = browser.$(Selectors.CreateCollectionModal);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.$() now returns a chainable promise element which isn't a promise itself anymore.

await createModalElement.waitForDisplayed();

await browser.setValueVisible(
Expand Down Expand Up @@ -141,7 +141,7 @@ export async function addCollection(

// scroll to the locale one so the screenshot will include it.
// (for debugging)
const localeButton = await browser.$(
const localeButton = browser.$(
Selectors.createCollectionCustomCollationFieldButton('locale')
);
await localeButton.scrollIntoView();
Expand All @@ -168,13 +168,11 @@ export async function addCollection(
await browser.clickVisible(
Selectors.CreateCollectionTimeseriesGranularityButton
);
const menu = await browser.$(
const menu = browser.$(
Selectors.CreateCollectionTimeseriesGranularityMenu
);
await menu.waitForDisplayed();
const span = await menu.$(
`span=${collectionOptions.timeseries.granularity}`
);
const span = menu.$(`span=${collectionOptions.timeseries.granularity}`);
await span.waitForDisplayed();
await span.click();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/add-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export async function addDatabase(
collectionOptions?: AddCollectionOptions,
screenshotPath?: string
): Promise<void> {
const createModalElement = await browser.$(Selectors.CreateDatabaseModal);
const createModalElement = browser.$(Selectors.CreateDatabaseModal);
await createModalElement.waitForDisplayed();
await browser.setValueVisible(Selectors.CreateDatabaseDatabaseName, dbName);
await browser.setValueVisible(
Selectors.CreateDatabaseCollectionName,
collectionName
);
const createButton = await browser.$(Selectors.CreateDatabaseCreateButton);
const createButton = browser.$(Selectors.CreateDatabaseCreateButton);
await createButton.waitForEnabled();

if (screenshotPath) {
Expand Down
4 changes: 1 addition & 3 deletions packages/compass-e2e-tests/helpers/commands/add-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export async function addWizard(
await browser.toggleAggregationSidePanel('opened');
await browser.clickVisible(Selectors.AggregationWizardUseCase(usecaseId));

const wizardCard = await browser.$(
Selectors.AggregationWizardCardAtIndex(index)
);
const wizardCard = browser.$(Selectors.AggregationWizardCardAtIndex(index));
await wizardCard.waitForDisplayed();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function clickConfirmationAction(
) {
await browser.clickVisible(actionButtonSelector);

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

if (confirmationText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export async function clickParent(
browser: CompassBrowser,
selector: string
): Promise<void> {
const element = await browser.$(selector).parentElement();
const element = browser.$(selector).parentElement();
await element.waitForExist();
await element.click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ClickOptions {

export async function clickVisible(
browser: CompassBrowser,
selector: string | ChainablePromiseElement<WebdriverIO.Element>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChainablePromiseElement is not generic anymore

selector: string | ChainablePromiseElement,
options?: ClickOptions
): Promise<void> {
const waitOptions = { timeout: options?.timeout };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function closeConnectModal(
browser: CompassBrowser
): Promise<void> {
await browser.clickVisible(Selectors.CancelConnectionButton);
const connectionModalContentElement = await browser.$(
const connectionModalContentElement = browser.$(
Selectors.ConnectionStatusModalContent
);
await connectionModalContentElement.waitForExist({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function closeSettingsModal(
return;
}

const settingsModalElement = await browser.$(Selectors.SettingsModal);
const settingsModalElement = browser.$(Selectors.SettingsModal);

await settingsModalElement.waitForDisplayed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function closeWelcomeModal(
return;
}

const welcomeModalElement = await browser.$(Selectors.WelcomeModal);
const welcomeModalElement = browser.$(Selectors.WelcomeModal);
await welcomeModalElement.waitForDisplayed();

await browser.clickVisible(Selectors.CloseWelcomeModalButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function navigateToCollection(
Selectors.SidebarFilterInput,
`^(${dbName}|${collectionName})$`
);
const collectionElement = await browser.$(collectionSelector);
const collectionElement = browser.$(collectionSelector);

await collectionElement.waitForDisplayed();

Expand Down
22 changes: 10 additions & 12 deletions packages/compass-e2e-tests/helpers/commands/connect-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function resetConnectForm(browser: CompassBrowser): Promise<void> {

const connectionTitleSelector = Selectors.ConnectionModalTitle;

const connectionTitle = await browser.$(connectionTitleSelector);
const connectionTitle = browser.$(connectionTitleSelector);
await connectionTitle.waitUntil(async () => {
return (await connectionTitle.getText()) === 'New Connection';
});
Expand Down Expand Up @@ -305,9 +305,7 @@ export async function getConnectFormState(
await browser.clickVisible(Selectors.ConnectionFormAdvancedToggle);

await browser.waitUntil(async () => {
const advancedButton = await browser.$(
Selectors.ConnectionFormAdvancedToggle
);
const advancedButton = browser.$(Selectors.ConnectionFormAdvancedToggle);
return (await advancedButton.getAttribute('aria-expanded')) === 'false';
});
}
Expand All @@ -319,8 +317,8 @@ async function getCheckedRadioValue(
browser: CompassBrowser,
selector: string
): Promise<string | null> {
const elements = await browser.$$(selector);
for (const element of elements) {
const elements = browser.$$(selector);
for await (const element of elements) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.$$ returns a chainable element promise array so a) it isn't a promise itself anymore and b) we have to async iterate over the result.

if (await element.isSelected()) {
return element.getValue();
}
Expand All @@ -333,7 +331,7 @@ async function getCheckboxValue(
browser: CompassBrowser,
selector: string
): Promise<boolean | null> {
const element = await browser.$(selector);
const element = browser.$(selector);
if (!(await element.isExisting())) {
return null; // as opposed to true for checked and false for not
}
Expand All @@ -345,7 +343,7 @@ async function getText(
browser: CompassBrowser,
selector: string
): Promise<string | null> {
const element = await browser.$(selector);
const element = browser.$(selector);
if (!(await element.isExisting())) {
return null;
}
Expand All @@ -366,7 +364,7 @@ async function getValue(
browser: CompassBrowser,
selector: string
): Promise<string | null> {
const element = await browser.$(selector);
const element = browser.$(selector);
if (!(await element.isExisting())) {
return null;
}
Expand Down Expand Up @@ -880,8 +878,8 @@ export async function setConnectFormState(
// for whatever reasons sometimes the first one or two come through as empty strings
await browser.waitUntil(async () => {
allText = [];
const options = await browser.$$('#select-key-menu [role="option"]');
for (const option of options) {
const options = browser.$$('#select-key-menu [role="option"]');
for await (const option of options) {
const _text = await option.getText();
const text = _text.trim();
allText.push(text);
Expand All @@ -904,7 +902,7 @@ export async function setConnectFormState(
).to.be.true;

// make sure the menu goes away once we clicked on the option
const menu = await browser.$('#select-key-menu');
const menu = browser.$('#select-key-menu');
await menu.waitForExist({ reverse: true });

// value
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getConnectFormConnectionString(
browser: CompassBrowser,
shouldFocusInput = false
): Promise<string> {
const inputElem = await browser.$(Selectors.ConnectionFormStringInput);
const inputElem = browser.$(Selectors.ConnectionFormStringInput);
await inputElem.waitForDisplayed();
if (shouldFocusInput) {
await browser.waitUntil(async () => {
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function waitForConnectionResult(
await browser
.$(Selectors.ConnectionToastErrorText)
.waitForDisplayed(waitOptions);
return await browser.$(Selectors.LGToastTitle).getText();
return browser.$(Selectors.LGToastTitle).getText();
} else {
const exhaustiveCheck: never = connectionStatus;
throw new Error(`Unhandled connectionStatus case: ${exhaustiveCheck}`);
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-e2e-tests/helpers/commands/create-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function createIndex(
} else {
await browser.clickVisible(Selectors.CreateIndexButton);
}
const createModal = await browser.$(Selectors.CreateIndexModal);
const createModal = browser.$(Selectors.CreateIndexModal);
await createModal.waitForDisplayed();

// Select / type field name
Expand All @@ -62,12 +62,12 @@ export async function createIndex(
await browser.keys(['Enter']);

// Select field type
const fieldTypeSelect = await browser.$(
const fieldTypeSelect = browser.$(
Selectors.createIndexModalFieldTypeSelectButton(createRowIndex)
);
await fieldTypeSelect.waitForDisplayed();
await fieldTypeSelect.click();
const fieldTypeSelectMenu = await browser.$(
const fieldTypeSelectMenu = browser.$(
Selectors.createIndexModalFieldTypeSelectMenu(createRowIndex)
);
await fieldTypeSelectMenu.waitForDisplayed();
Expand Down Expand Up @@ -119,7 +119,7 @@ export async function createIndex(

// Assert that index does come in table
const indexComponentSelector = Selectors.indexComponent(indexName);
const indexComponent = await browser.$(indexComponentSelector);
const indexComponent = browser.$(indexComponentSelector);
await indexComponent.waitForDisplayed();

// Wait for index to get ready before proceeding
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export async function disconnectAll(
// The potential problem here is that the list is virtual, so it is possible
// that not every connection is rendered. Collapsing them all helps a little
// bit, though.
const connectionItems = await browser.$$(
const connectionItems = browser.$$(
Selectors.Multiple.ConnectedConnectionItems
);
for (const connectionItem of connectionItems) {
for await (const connectionItem of connectionItems) {
const connectionName = await connectionItem.getAttribute(
'data-connection-name'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export async function dropCollectionFromSidebar(
databaseName,
collectionName
);
const collectionElement = await browser.$(collectionSelector);
const collectionElement = browser.$(collectionSelector);
await collectionElement.waitForExist({ reverse: true });
}
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/drop-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export async function dropIndex(
screenshotName?: string
) {
const indexComponentSelector = Selectors.indexComponent(indexName);
const indexComponent = await browser.$(indexComponentSelector);
const indexComponent = browser.$(indexComponentSelector);
await indexComponent.waitForDisplayed();

await browser.hover(indexComponentSelector);
await browser.clickVisible(
`${indexComponentSelector} ${Selectors.IndexesTableDropIndexButton}`
);

const dropModal = await browser.$(Selectors.DropIndexModal);
const dropModal = browser.$(Selectors.DropIndexModal);
await dropModal.waitForDisplayed();

await browser.setValueVisible(
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/drop-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export async function dropNamespace(
browser: CompassBrowser,
collectionName: string
): Promise<void> {
const dropModalElement = await browser.$(Selectors.DropNamespaceModal);
const dropModalElement = browser.$(Selectors.DropNamespaceModal);
await dropModalElement.waitForDisplayed();
await browser.setValueVisible(
Selectors.DropNamespaceConfirmNameInput,
collectionName
);
const confirmButton = await browser.$(Selectors.DropNamespaceDropButton);
const confirmButton = browser.$(Selectors.DropNamespaceDropButton);
await confirmButton.waitForEnabled();

await confirmButton.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function existsEventually(
): Promise<boolean> {
try {
// return true if it exists before the timeout expires
const element = await browser.$(selector);
const element = browser.$(selector);
await element.waitForDisplayed(
typeof timeout !== 'undefined' ? { timeout } : undefined
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export async function expandAccordion(
browser: CompassBrowser,
selector: string
): Promise<boolean> {
const expandButton = await browser.$(selector);
const expandButton = browser.$(selector);
await expandButton.waitForDisplayed();

if ((await expandButton.getAttribute('aria-expanded')) === 'false') {
Expand Down
20 changes: 9 additions & 11 deletions packages/compass-e2e-tests/helpers/commands/export-to-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function exportToLanguage(
language: string,
options?: ExportToLanguageOptions
): Promise<string> {
const exportModal = await browser.$(Selectors.ExportToLanguageModal);
const exportModal = browser.$(Selectors.ExportToLanguageModal);
await exportModal.waitForDisplayed();

// pick the language
Expand All @@ -22,39 +22,37 @@ export async function exportToLanguage(
return (await button.getAttribute('aria-expanded')) === 'true';
});

const listBox = await browser.$(Selectors.ExportToLanguageLanguageListbox);
const listBox = browser.$(Selectors.ExportToLanguageLanguageListbox);
await listBox.waitForDisplayed();
const languageElement = await listBox.$(`[value="${language}"]`);
const languageElement = listBox.$(`[value="${language}"]`);
await languageElement.waitForDisplayed();
await languageElement.click();

if (options?.includeImportStatements === true) {
const importsCheckbox = await browser.$(
const importsCheckbox = browser.$(
Selectors.ExportToLanguageImportsCheckbox
);
const importsLabel = await importsCheckbox.parentElement();
const importsLabel = importsCheckbox.parentElement();
if (!(await importsCheckbox.isSelected())) {
await importsLabel.click();
}
}

// not C#
if (options?.includeDriverSyntax === true) {
const driverCheckbox = await browser.$(
Selectors.ExportToLanguageDriverCheckbox
);
const driverLabel = await driverCheckbox.parentElement();
const driverCheckbox = browser.$(Selectors.ExportToLanguageDriverCheckbox);
const driverLabel = driverCheckbox.parentElement();
if (!(await driverCheckbox.isSelected())) {
await driverLabel.click();
}
}

// only Java, only when exporting from Documents tab
if (options?.useBuilders === true) {
const buildersCheckbox = await browser.$(
const buildersCheckbox = browser.$(
Selectors.ExportToLanguageBuildersCheckbox
);
const buildersLabel = await buildersCheckbox.parentElement();
const buildersLabel = buildersCheckbox.parentElement();
if (!(await buildersCheckbox.isSelected())) {
await buildersLabel.click();
}
Expand Down
Loading
Loading