Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Dec 20, 2024
1 parent 6a9ff1a commit dee83d9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/compass-e2e-tests/helpers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions packages/compass-e2e-tests/tests/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dee83d9

Please sign in to comment.