Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1,321 changes: 578 additions & 743 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
"@types/react-dom": "^17.0.25",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"webdriverio": {
"puppeteer-core": "^23.10.3"
},
"enzyme": {
"cheerio": "1.0.0-rc.10"
},
Expand Down
1 change: 0 additions & 1 deletion packages/compass-e2e-tests/.depcheckrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ignores:
- '@mongodb-js/prettier-config-compass'
- '@mongodb-js/tsconfig-compass'
- '@wdio/types'
- 'ps-list'
# Avoiding recursive deps on monorepo workspaces
- 'mongodb-compass'
Expand Down
15 changes: 13 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/connect-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,13 @@ async function getCheckedRadioValue(
const elements = browser.$$(selector);
for await (const element of elements) {
if (await element.isSelected()) {
return element.getValue();
const val = await element.getValue();
if (typeof val !== 'string') {
throw new TypeError(
`Expected element value to be a string, got ${val}`
);
}
return val;
}
}

Expand Down Expand Up @@ -365,6 +371,9 @@ async function getValue(
}

const value = await element.getValue();
if (typeof value !== 'string') {
throw new TypeError(`Expected element value to be a string, got ${value}`);
}
return value || null;
}

Expand All @@ -374,7 +383,9 @@ async function getMultipleValues(
): Promise<string[] | null> {
const results = (
await browser.$$(selector).map((element) => element.getValue())
).filter((result) => result !== '');
).filter((result): result is string => {
return typeof result === 'string' && result !== '';
});

return results.length ? results : null;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/compass-e2e-tests/helpers/commands/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export async function getConnectFormConnectionString(
return await inputElem.isFocused();
});
}
return await inputElem.getValue();
const val = await inputElem.getValue();
if (typeof val !== 'string') {
throw new TypeError(`Expected element value to be a string, got ${val}`);
}
return val;
}

type ConnectionResultOptions = {
Expand Down
5 changes: 5 additions & 0 deletions packages/compass-e2e-tests/helpers/commands/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export async function disconnectAll(
const connectionName = await connectionItem.getAttribute(
'data-connection-name'
);
if (!connectionName) {
throw new Error(
'Expected connectionItem to have a data-connection-name attribute'
);
}
await browser.disconnectByName(connectionName);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/get-query-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import * as Selectors from '../selectors';
export async function getQueryId(
browser: CompassBrowser,
tabName: string
): Promise<string | undefined> {
): Promise<string | null> {
const queryBarSelector = Selectors.queryBar(tabName);
const queryBarSelectorElement = browser.$(queryBarSelector);
return queryBarSelectorElement.getAttribute('data-result-id');
}

export async function getApplyId(browser: CompassBrowser, tabName: string) {
export async function getApplyId(
browser: CompassBrowser,
tabName: string
): Promise<string | null> {
const queryBarSelector = Selectors.queryBar(tabName);
const queryBarSelectorElement = browser.$(queryBarSelector);
return queryBarSelectorElement.getAttribute('data-apply-id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export async function navigateToConnectTab(
const initialTab = await browser
.$(Selectors.SelectedAdvancedOptionsTab)
.getAttribute('name');

if (!initialTab) {
throw new Error('Expected initialTab to exist');
}

if (initialTab !== tabName) {
await browser.clickVisible(Selectors.advancedOptionsTab(tabName));
await browser
Expand Down
7 changes: 5 additions & 2 deletions packages/compass-e2e-tests/helpers/commands/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function _setFeatureWeb<K extends keyof UserPreferences>(
value: UserPreferences[K]
): Promise<AllPreferences> {
return browser.execute(
(_name, _value) => {
// @ts-expect-error generics in the browser.execute definition mess up with
// the multiple args we're passing here, so we have to just ignore the issue
(_name: K, _value: UserPreferences[K]): AllPreferences => {
const kSandboxPreferencesAccess = Symbol.for(
'@compass-web-sandbox-preferences-access'
);
Expand All @@ -69,7 +71,8 @@ async function _setFeatureDesktop<K extends keyof UserPreferences>(
value: UserPreferences[K]
): Promise<AllPreferences> {
return await browser.execute(
async (_name, _value) => {
// @ts-expect-error see above
async (_name: K, _value: UserPreferences[K]): AllPreferences => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const newPreferences = await require('electron').ipcRenderer.invoke(
'compass:save-preferences',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export async function removeAllConnections(
const connectionName = await connectionItem.getAttribute(
'data-connection-name'
);
if (!connectionName) {
throw new Error(
'Expected connection item to have a data-connection-name attribute'
);
}
await browser.removeConnectionByName(connectionName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ export async function scrollToVirtualItem(
role: 'grid' | 'tree' | 'table'
): Promise<boolean> {
if (role === 'table') {
const countStr = await browser
.$(`${containerSelector} table`)
.getAttribute('aria-rowcount');
// we disable virtual scrolling for tables for now
const expectedRowCount = parseInt(
await browser
.$(`${containerSelector} table`)
.getAttribute('aria-rowcount'),
10
);
if (!countStr) {
throw new Error('Expected table to have an aria-rowcount attribute');
}
const expectedRowCount = parseInt(countStr, 10);
const rowCount = await browser.$$('tbody tr').length;

if (rowCount !== expectedRowCount) {
Expand Down Expand Up @@ -90,21 +91,15 @@ export async function scrollToVirtualItem(
// scroll to the top and return the height of the scrollbar area and the
// scroll content
const [scrollHeight, totalHeight] = await browser.execute(
(selector, getScrollContainerString) => {
(selector, getScrollContainerString): [number, number] | [null, null] => {
// eslint-disable-next-line no-restricted-globals
const container = document.querySelector(selector);
const scrollContainer = eval(getScrollContainerString)(container);
const heightContainer = scrollContainer?.firstChild;
if (!heightContainer) {
return [null, null];
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
scrollContainer.scrollTop = 0;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return [scrollContainer.clientHeight, heightContainer.offsetHeight];
},
containerSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ export async function setComboBoxValue(
return false;
}
});
const controlledMenuId: string = await inputElement.getAttribute(
'aria-controls'
);
const controlledMenuId = await inputElement.getAttribute('aria-controls');
if (!controlledMenuId) {
throw new Error(
'Expected input element of the combobox to have an aria-controls attribute'
);
}
const comboboxListSelectorElement = browser.$(
`[id="${controlledMenuId}"][role="listbox"]`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export async function closeWorkspaceTabs(
// are multiple tabs then another tab will immediately become active and
// trip up the logic that checks that the tab you closed went away.
const id = await currentActiveTab.getAttribute('id');
if (!id) {
throw new Error('Expected current active tab to have an id attribute');
}
debug('closing tab', { numTabsStart, id });
await closeTab(browser, { id }, autoConfirmTabClose);

Expand All @@ -103,6 +106,9 @@ export async function closeLastTab(
const tabs = browser.$$(Selectors.workspaceTab(selectorOptions));
const lastTab = tabs[(await tabs.length) - 1];
const id = await lastTab.getAttribute('id');
if (!id) {
throw new Error('Expected current active tab to have an id attribute');
}
await closeWorkspaceTab(browser, { id });
}

Expand Down
3 changes: 1 addition & 2 deletions packages/compass-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@types/chai-as-promised": "^7.1.4",
"@types/cross-spawn": "^6.0.2",
"@types/yargs": "^17.0.33",
"@wdio/types": "^8.32.2",
"bson": "^6.10.4",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down Expand Up @@ -74,7 +73,7 @@
"tesseract.js": "^6.0.1",
"tree-kill": "^1.2.2",
"ts-node": "^10.9.2",
"webdriverio": "^9.4.1",
"webdriverio": "^9.23.3",
"why-is-node-running": "^2.3.0",
"xvfb-maybe": "^0.2.1",
"yargs": "^17.7.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/tests/data-modeling-tab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function setupDiagram(
// Expect the overview drawer to be opened and close it
const drawer = browser.$(Selectors.SideDrawer);
await drawer.waitForDisplayed();
expect(await drawer.getText()).to.include('Data Model Overview');
await browser.$('span=Data Model Overview').waitForDisplayed();
await closeDrawerIfOpen(browser);
}

Expand All @@ -128,7 +128,7 @@ async function closeDrawerIfOpen(browser: CompassBrowser) {
(await drawer.$(Selectors.SideDrawerCloseButton).isClickable())
) {
await browser.clickVisible(Selectors.SideDrawerCloseButton);
await drawer.waitForDisplayed({ reverse: true });
await drawer.waitForDisplayed({ reverse: true, withinViewport: true });
}
}

Expand Down
Loading