Skip to content

Commit dcdac9d

Browse files
committed
Add a test
1 parent b4f0043 commit dcdac9d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ export const ConenctionToastCancelConnectionButton =
244244
// Connections sidebar
245245
export const ConnectionsTitle = '[data-testid="connections-header"]';
246246
export const SidebarNewConnectionButton = '[data-action="add-new-connection"]';
247+
export const ConnectDropdownButton =
248+
'[data-testid="sidebar-navigation-item-actions-connection-connect-action"] + button';
249+
export const ConnectInNewWindowButton =
250+
'[data-action="connection-connect-in-new-window"]';
247251
export const ConnectionMenu = '[data-testid="sidebar-navigation-item-actions"]';
248252
export const CreateDatabaseButton =
249253
'[data-testid="sidebar-navigation-item-actions-create-database-action"]';
@@ -365,6 +369,14 @@ export const sidebarConnectionButton = (connectionName: string): string => {
365369
)} [data-action="connection-connect"]`;
366370
};
367371

372+
export const sidebarConnectionDropdownButton = (
373+
connectionName: string
374+
): string => {
375+
return `${sidebarConnection(connectionName)} ${
376+
Multiple.ConnectDropdownButton
377+
}`;
378+
};
379+
368380
export const sidebarConnectionActionButton = (
369381
connectionName: string,
370382
selector: string

packages/compass-e2e-tests/tests/connection.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
import type { Compass } from '../helpers/compass';
2121
import type { ConnectFormState } from '../helpers/connect-form-state';
2222
import * as Selectors from '../helpers/selectors';
23+
import { DEFAULT_CONNECTION_NAMES } from '../helpers/test-runner-context';
2324

2425
async function disconnect(browser: CompassBrowser) {
2526
try {
@@ -641,6 +642,50 @@ describe('Connection string', function () {
641642
});
642643
});
643644

645+
describe('Connect in a new window', () => {
646+
let compass: Compass;
647+
let browser: CompassBrowser;
648+
649+
before(async function () {
650+
compass = await init(this.test?.fullTitle(), {
651+
firstRun: false,
652+
});
653+
browser = compass.browser;
654+
await browser.setupDefaultConnections();
655+
});
656+
657+
after(async function () {
658+
await cleanup(compass);
659+
});
660+
661+
it('can connect in new window', async function (this) {
662+
skipForWeb(this, 'connecting in new window is not supported on web');
663+
const connectionName = DEFAULT_CONNECTION_NAMES[0];
664+
const connectionSelector = Selectors.sidebarConnection(connectionName);
665+
await browser.hover(connectionSelector);
666+
667+
expect((await browser.getWindowHandles()).length).equals(1);
668+
669+
const connectionElement = browser.$(connectionSelector);
670+
await browser.clickVisible(
671+
connectionElement.$(Selectors.ConnectDropdownButton)
672+
);
673+
await browser.clickVisible(
674+
connectionElement.$(Selectors.ConnectInNewWindowButton)
675+
);
676+
677+
const windowsAfter = await browser.getWindowHandles();
678+
expect(windowsAfter.length).equals(2);
679+
const [, newWindowHandle] = windowsAfter;
680+
await browser.switchToWindow(newWindowHandle);
681+
await browser.waitForConnectionResult(connectionName, {
682+
connectionStatus: 'success',
683+
});
684+
});
685+
686+
// TODO: Add a test for we to ensure the SplitButton isn't visible on Web
687+
});
688+
644689
describe('Connection form', function () {
645690
let compass: Compass;
646691
let browser: CompassBrowser;

0 commit comments

Comments
 (0)