From dee83d9821c61c313929934e5ebdf088328ba94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Thu, 19 Dec 2024 23:05:59 +0100 Subject: [PATCH] Add a test --- .../compass-e2e-tests/helpers/selectors.ts | 10 +++++ .../tests/connection.test.ts | 45 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index f6ade8701fd..a04aa6a68c3 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -282,6 +282,8 @@ export const Single = { export const Multiple = { ConnectionsTitle: '[data-testid="connections-header"]', ConnectButton: '[data-action="connection-connect"]', + ConnectInNewWindowButton: '[data-action="connection-connect-in-new-window"]', + ConnectDropdownButton: '[aria-label="see more connection options"]', SidebarNewConnectionButton: '[data-action="add-new-connection"]', ConnectionMenu: '[data-testid="sidebar-navigation-item-actions"]', CreateDatabaseButton: @@ -406,6 +408,14 @@ export const sidebarConnectionButton = (connectionName: string): string => { return `${sidebarConnection(connectionName)} ${Multiple.ConnectButton}`; }; +export const sidebarConnectionDropdownButton = ( + connectionName: string +): string => { + return `${sidebarConnection(connectionName)} ${ + Multiple.ConnectDropdownButton + }`; +}; + export const sidebarConnectionActionButton = ( connectionName: string, selector: string diff --git a/packages/compass-e2e-tests/tests/connection.test.ts b/packages/compass-e2e-tests/tests/connection.test.ts index a679b038df1..77641dd9b61 100644 --- a/packages/compass-e2e-tests/tests/connection.test.ts +++ b/packages/compass-e2e-tests/tests/connection.test.ts @@ -20,6 +20,7 @@ import { import type { Compass } from '../helpers/compass'; import type { ConnectFormState } from '../helpers/connect-form-state'; import * as Selectors from '../helpers/selectors'; +import { DEFAULT_CONNECTION_NAMES } from '../helpers/test-runner-context'; async function disconnect(browser: CompassBrowser) { try { @@ -643,6 +644,50 @@ describe('Connection string', function () { }); }); +describe('Connect in a new window', () => { + let compass: Compass; + let browser: CompassBrowser; + + before(async function () { + compass = await init(this.test?.fullTitle(), { + firstRun: false, + }); + browser = compass.browser; + await browser.setupDefaultConnections(); + }); + + after(async function () { + await cleanup(compass); + }); + + it('can connect in new window', async function (this) { + skipForWeb(this, 'connecting in new window is not supported on web'); + const connectionName = DEFAULT_CONNECTION_NAMES[0]; + const connectionSelector = Selectors.sidebarConnection(connectionName); + await browser.hover(connectionSelector); + + expect((await browser.getWindowHandles()).length).equals(1); + + const connectionElement = browser.$(connectionSelector); + await browser.clickVisible( + connectionElement.$(Selectors.Multiple.ConnectDropdownButton) + ); + await browser.clickVisible( + connectionElement.$(Selectors.Multiple.ConnectInNewWindowButton) + ); + + const windowsAfter = await browser.getWindowHandles(); + expect(windowsAfter.length).equals(2); + const [, newWindowHandle] = windowsAfter; + await browser.switchToWindow(newWindowHandle); + await browser.waitForConnectionResult(connectionName, { + connectionStatus: 'success', + }); + }); + + // TODO: Add a test for we to ensure the SplitButton isn't visible on Web +}); + describe('Connection form', function () { let compass: Compass; let browser: CompassBrowser;