Skip to content

Commit 71b6a53

Browse files
authored
chore(e2e): port shell e2e usage to multiple connections COMPASS-8004 (#6005)
1 parent e5637dc commit 71b6a53

28 files changed

+546
-321
lines changed

packages/compass-components/src/components/workspace-tabs/tab.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ const selectedCloseButtonStyles = css({
184184
type IconGlyph = Extract<keyof typeof glyphs, string>;
185185

186186
type TabProps = {
187+
connectionName?: string;
188+
type: string;
187189
title: string;
188190
isSelected: boolean;
189191
isDragging: boolean;
@@ -196,6 +198,8 @@ type TabProps = {
196198
};
197199

198200
function Tab({
201+
connectionName,
202+
type,
199203
title,
200204
isSelected,
201205
isDragging,
@@ -254,6 +258,8 @@ function Tab({
254258
tabIndex={isSelected ? 0 : -1}
255259
aria-controls={tabContentId}
256260
data-testid="workspace-tab-button"
261+
data-connectionName={connectionName}
262+
data-type={type}
257263
title={subtitle ? subtitle : title}
258264
{...tabProps}
259265
>

packages/compass-components/src/components/workspace-tabs/workspace-tabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ type WorkspaceTabsProps = {
170170

171171
export type TabProps = {
172172
id: string;
173+
type: string;
173174
title: string;
174175
subtitle?: string;
175176
connectionId?: string;

packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,10 @@ describe('ConnectionsNavigationTree', function () {
572572
userEvent.click(otherActions);
573573

574574
expect(screen.getByText('Open MongoDB shell')).to.be.visible;
575-
if (name !== 'when connection is datalake') {
575+
if (
576+
name !== 'when connection is datalake' &&
577+
name !== 'when connection is not writable'
578+
) {
576579
expect(
577580
screen.getByTestId(
578581
'sidebar-navigation-item-actions-open-shell-action'

packages/compass-connections-navigation/src/tree-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const connectedConnectionToItems = ({
170170
const colorCode = connectionInfo.favorite?.color;
171171
const hasWriteActionsDisabled =
172172
preferencesReadOnly || isDataLake || !isWritable;
173-
const isShellEnabled = !preferencesReadOnly && isWritable;
173+
const isShellEnabled = !preferencesReadOnly;
174174
const connectionTI: ConnectedConnectionTreeItem = {
175175
id: connectionInfo.id,
176176
level: 1,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { TEST_MULTIPLE_CONNECTIONS } from '../compass';
2+
import type { CompassBrowser } from '../compass-browser';
3+
import retryWithBackoff from '../retry-with-backoff';
4+
import * as Selectors from '../selectors';
5+
6+
export async function closeShell(
7+
browser: CompassBrowser,
8+
connectionName: string
9+
): Promise<void> {
10+
if (TEST_MULTIPLE_CONNECTIONS) {
11+
await browser.closeWorkspaceTab({
12+
connectionName,
13+
type: 'Shell',
14+
});
15+
} else {
16+
await retryWithBackoff(async function () {
17+
const shellContentElement = await browser.$(Selectors.ShellContent);
18+
if (await shellContentElement.isDisplayed()) {
19+
await browser.clickVisible(Selectors.ShellExpandButton);
20+
}
21+
});
22+
}
23+
}

packages/compass-e2e-tests/helpers/commands/close-workspace-tabs.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function waitUntilActiveCollectionSubTab(
113113

114114
export async function getActiveTabNamespace(browser: CompassBrowser) {
115115
const activeWorkspaceNamespace = await browser
116-
.$(Selectors.workspaceTab(null, true))
116+
.$(Selectors.workspaceTab({ active: true }))
117117
.getAttribute('data-namespace');
118118
return activeWorkspaceNamespace || null;
119119
}

packages/compass-e2e-tests/helpers/commands/connect-with-connection-string.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function connectWithConnectionString(
7171

7272
// some connection should be expanded (ie. connected) by now
7373
await browser
74-
.$(`${Selectors.SidebarTreeItems} [aria-expanded=true]`)
75-
.waitForExist({ reverse: true });
74+
.$(`${Selectors.SidebarTreeItems}[aria-expanded=true]`)
75+
.waitForExist();
7676
}
7777
}

packages/compass-e2e-tests/helpers/commands/disconnect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function disconnect(browser: CompassBrowser): Promise<void> {
4444
// no active connections left. Use a different command if you expect to
4545
// disconnect just one connection and still keep others around.
4646
await browser
47-
.$(`${Selectors.SidebarTreeItems} [aria-expanded=true]`)
47+
.$(`${Selectors.SidebarTreeItems}[aria-expanded=true]`)
4848
.waitForExist({ reverse: true });
4949

5050
// The potential problem here is that the list is virtual, so it is possible

packages/compass-e2e-tests/helpers/commands/hide-shell.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)