-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): port shell e2e usage to multiple connections COMPASS-8004 (…
- Loading branch information
Showing
28 changed files
with
546 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/compass-e2e-tests/helpers/commands/close-shell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; | ||
import type { CompassBrowser } from '../compass-browser'; | ||
import retryWithBackoff from '../retry-with-backoff'; | ||
import * as Selectors from '../selectors'; | ||
|
||
export async function closeShell( | ||
browser: CompassBrowser, | ||
connectionName: string | ||
): Promise<void> { | ||
if (TEST_MULTIPLE_CONNECTIONS) { | ||
await browser.closeWorkspaceTab({ | ||
connectionName, | ||
type: 'Shell', | ||
}); | ||
} else { | ||
await retryWithBackoff(async function () { | ||
const shellContentElement = await browser.$(Selectors.ShellContent); | ||
if (await shellContentElement.isDisplayed()) { | ||
await browser.clickVisible(Selectors.ShellExpandButton); | ||
} | ||
}); | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
packages/compass-e2e-tests/helpers/commands/close-workspace-tabs.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; | ||
import type { CompassBrowser } from '../compass-browser'; | ||
import retryWithBackoff from '../retry-with-backoff'; | ||
import * as Selectors from '../selectors'; | ||
|
||
export async function openShell( | ||
browser: CompassBrowser, | ||
connectionName: string | ||
): Promise<void> { | ||
if (TEST_MULTIPLE_CONNECTIONS) { | ||
await browser.selectConnectionMenuItem( | ||
connectionName, | ||
Selectors.Multiple.OpenShellItem | ||
); | ||
|
||
// try and make sure the shell tab is active and ready | ||
await browser.waitUntil(async () => { | ||
const currentActiveTab = await browser.$( | ||
Selectors.workspaceTab({ active: true }) | ||
); | ||
const activeType = await currentActiveTab.getAttribute('data-type'); | ||
const activeConnectionName = await currentActiveTab.getAttribute( | ||
'data-connectionName' | ||
); | ||
return activeType === 'Shell' && activeConnectionName === connectionName; | ||
}); | ||
|
||
await browser.clickVisible(Selectors.ShellInputEditor); | ||
} else { | ||
// Expand the shell | ||
await retryWithBackoff(async function () { | ||
const shellContentElement = await browser.$(Selectors.ShellContent); | ||
if (!(await shellContentElement.isDisplayed())) { | ||
// The toasts may be covering the shell, so we need to close them. | ||
await browser.hideAllVisibleToasts(); | ||
await browser.clickVisible(Selectors.ShellExpandButton); | ||
} | ||
|
||
await browser.clickVisible(Selectors.ShellInputEditor); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
packages/compass-e2e-tests/helpers/commands/workspace-tabs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import type { CompassBrowser } from '../compass-browser'; | ||
import * as Selectors from '../selectors'; | ||
import type { WorkspaceTabSelectorOptions } from '../selectors'; | ||
|
||
export async function navigateToMyQueries(browser: CompassBrowser) { | ||
await browser.clickVisible(Selectors.SidebarMyQueriesTab); | ||
await browser | ||
.$(Selectors.workspaceTab({ title: 'My Queries', active: true })) | ||
.waitForDisplayed(); | ||
} | ||
|
||
async function closeTab( | ||
browser: CompassBrowser, | ||
selectorOptions: WorkspaceTabSelectorOptions, | ||
autoConfirmTabClose: boolean | ||
): Promise<void> { | ||
await browser | ||
.$(Selectors.workspaceTab(selectorOptions)) | ||
.$(Selectors.CloseWorkspaceTab) | ||
.click(); | ||
|
||
// wait until the tab goes away and if the confirmation modal opens, maybe confirm | ||
await browser.waitUntil(async () => { | ||
if (autoConfirmTabClose) { | ||
// Tabs in "dirty" state can't be closed without confirmation | ||
if (await browser.$(Selectors.ConfirmTabCloseModal).isExisting()) { | ||
await browser.clickVisible( | ||
browser.$(Selectors.ConfirmTabCloseModal).$('button=Close tab') | ||
); | ||
await browser | ||
.$(Selectors.ConfirmTabCloseModal) | ||
.waitForDisplayed({ reverse: true }); | ||
} | ||
} | ||
return ( | ||
(await browser | ||
.$(Selectors.workspaceTab(selectorOptions)) | ||
.isExisting()) === false | ||
); | ||
}); | ||
} | ||
|
||
export async function closeWorkspaceTabs( | ||
browser: CompassBrowser, | ||
autoConfirmTabClose = true | ||
): Promise<void> { | ||
const countTabs = async () => { | ||
return (await browser.$$(Selectors.workspaceTab())).length; | ||
}; | ||
|
||
while ((await countTabs()) > 0) { | ||
const currentActiveTab = await browser.$( | ||
Selectors.workspaceTab({ active: true }) | ||
); | ||
await currentActiveTab.click(); | ||
// Close this exact active tab rather than "the active one" because if there | ||
// are multiple tabs then another tab will immediately become active and | ||
// trip up the logic that checks that the tab you closed went away. | ||
const id = await currentActiveTab.getAttribute('id'); | ||
await closeTab(browser, { id }, autoConfirmTabClose); | ||
} | ||
} | ||
|
||
export async function closeWorkspaceTab( | ||
browser: CompassBrowser, | ||
selectorOptions: WorkspaceTabSelectorOptions | ||
): Promise<void> { | ||
const currentTabId = await browser | ||
.$(Selectors.workspaceTab({ active: true })) | ||
.getAttribute('id'); | ||
const targetTabId = await browser | ||
.$(Selectors.workspaceTab(selectorOptions)) | ||
.getAttribute('id'); | ||
|
||
if (currentTabId !== targetTabId) { | ||
// The tab we want to close isn't the active one so the close button isn't | ||
// visible. We can either focus it which would have the side-effect of | ||
// changing the tab focus or we can try and hover over it. | ||
await browser.hover(Selectors.workspaceTab(selectorOptions)); | ||
} | ||
|
||
await closeTab(browser, selectorOptions, true); | ||
} |
Oops, something went wrong.