Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/compass-components/src/components/leafygreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ import {
ComboboxGroup,
} from '@leafygreen-ui/combobox';

export { getLgIds as getDrawerIds } from './drawer';

// 2. Wrap and make any changes/workaround to leafygreen components.
const Icon = ({
size,
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-e2e-tests/helpers/commands/connect-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ export async function setConnectFormState(
}

if (state.connectionColor) {
await browser.selectOption(
Selectors.ConnectionFormConnectionColor,
colorValueToName(state.connectionColor)
);
await browser.selectOption({
selectSelector: Selectors.ConnectionFormConnectionColor,
optionText: colorValueToName(state.connectionColor),
});
}

if (state.connectionFavorite) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ChainablePromiseElement } from 'webdriverio';
import type { CompassBrowser } from '../compass-browser';

export async function getInputByLabel(
browser: CompassBrowser,
label: ChainablePromiseElement
): Promise<ChainablePromiseElement> {
await label.waitForDisplayed();
const inputId = await label.getAttribute('for');
return browser.$(`[id="${inputId}"]`);
}
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 @@ -65,3 +65,4 @@ export * from './switch-pipeline-mode';
export * from './read-first-document-content';
export * from './read-stage-operators';
export * from './click-confirmation-action';
export * from './get-input-by-label';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export async function saveFavorite(
Selectors.ConnectionFormConnectionName,
favoriteName
);
await browser.selectOption(Selectors.ConnectionFormConnectionColor, color);
await browser.selectOption({
selectSelector: Selectors.ConnectionFormConnectionColor,
optionText: color,
});

await browser.clickVisible(Selectors.ConnectionModalSaveButton);
await browser.$(Selectors.ConnectionModal).waitForExist({ reverse: true });
Expand Down
29 changes: 21 additions & 8 deletions packages/compass-e2e-tests/helpers/commands/select-option.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import type { ChainablePromiseElement } from 'webdriverio';
import type { CompassBrowser } from '../compass-browser';

type SelectOptionOptions = {
selectSelector: string | ChainablePromiseElement;
} & (
| {
optionText: string;
optionIndex?: never;
}
| {
optionIndex: number;
optionText?: never;
}
);

export async function selectOption(
browser: CompassBrowser,
// selector must match an element (like a div) that contains the leafygreen
// select we want to operate on
selector: string,
optionText: string
{ selectSelector, optionText, optionIndex }: SelectOptionOptions
): Promise<void> {
// click the field's button
const selectButton = browser.$(`${selector}`);
const selectButton = browser.$(selectSelector);
await selectButton.waitForDisplayed();
await selectButton.click();

Expand All @@ -26,9 +37,11 @@ export async function selectOption(
await selectList.waitForDisplayed();

// click the option
const optionSpan = selectList.$(`span=${optionText}`);
await optionSpan.scrollIntoView();
await optionSpan.click();
const option = optionText
? selectList.$(`span=${optionText}`)
: selectList.$(`:nth-child(${optionIndex})`);
await option.scrollIntoView();
await option.click();

// wait for the list to go away again
await selectList.waitForDisplayed({ reverse: true });
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ function redact(value: string): string {
continue;
}

const quoted = `'${process.env[field] as string}'`;
const quoted = `'${process.env[field]}'`;
// /regex/s would be ideal, but we'd have to escape the value to not be
// interpreted as a regex.
while (value.indexOf(quoted) !== -1) {
Expand Down
25 changes: 25 additions & 0 deletions packages/compass-e2e-tests/helpers/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getDrawerIds } from '@mongodb-js/compass-components';

export type WorkspaceTabSelectorOptions = {
id?: string;
connectionName?: string;
Expand Down Expand Up @@ -1445,6 +1447,8 @@ export const DataModelEditor = '[data-testid="diagram-editor-container"]';
export const DataModelPreview = `${DataModelEditor} [data-testid="model-preview"]`;
export const DataModelPreviewCollection = (collectionId: string) =>
`${DataModelPreview} [data-nodeid="${collectionId}"]`;
export const DataModelPreviewRelationship = (relationshipId: string) =>
`${DataModelPreview} [aria-roleDescription="edge"][data-id="${relationshipId}"]`;
export const DataModelApplyEditor = `${DataModelEditor} [data-testid="apply-editor"]`;
export const DataModelEditorApplyButton = `${DataModelApplyEditor} [data-testid="apply-button"]`;
export const DataModelUndoButton = 'button[aria-label="Undo"]';
Expand All @@ -1466,3 +1470,24 @@ export const DataModelsListItem = (diagramName?: string) => {
export const DataModelsListItemActions = (diagramName: string) =>
`${DataModelsListItem(diagramName)} [aria-label="Show actions"]`;
export const DataModelsListItemDeleteButton = `[data-action="delete"]`;
export const DataModelAddRelationshipBtn = 'aria/Add relationship';
export const DataModelNameInput = '//label[text()="Name"]';
export const DataModelRelationshipLocalCollectionSelect =
'//label[text()="Local collection"]';
export const DataModelRelationshipLocalFieldSelect =
'//label[text()="Local field"]';
export const DataModelRelationshipLocalCardinalitySelect =
'//label[text()="Local cardinality"]';
export const DataModelRelationshipForeignCollectionSelect =
'//label[text()="Foreign collection"]';
export const DataModelRelationshipForeignFieldSelect =
'//label[text()="Foreign field"]';
export const DataModelRelationshipForeignCardinalitySelect =
'//label[text()="Foreign cardinality"]';
export const DataModelCollectionRelationshipItem = (relationshipId: string) =>
`li[data-relationship-id="${relationshipId}"]`;
export const DataModelCollectionRelationshipItemEdit = `[aria-label="Edit relationship"]`;
export const DataModelCollectionRelationshipItemDelete = `[aria-label="Delete relationship"]`;

// Side drawer
export const SideDrawer = `[data-testid="${getDrawerIds().root}"]`;
1 change: 1 addition & 0 deletions packages/compass-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"devDependencies": {
"@electron/rebuild": "^4.0.1",
"@mongodb-js/compass-components": "^1.46.0",
"@mongodb-js/compass-test-server": "^0.3.16",
"@mongodb-js/connection-info": "^0.16.3",
"@mongodb-js/eslint-config-compass": "^1.4.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1596,10 +1596,12 @@ describe('Collection aggregations tab', function () {
'name'
);

await browser.selectOption(
`${Selectors.AggregationWizardSortFormDirectionSelect(0)} button`,
'Ascending'
);
await browser.selectOption({
selectSelector: `${Selectors.AggregationWizardSortFormDirectionSelect(
0
)} button`,
optionText: 'Ascending',
});

await browser.clickVisible(Selectors.AggregationWizardApplyButton);

Expand Down
Loading
Loading