import type { CompassBrowser } from '../compass-browser'; import delay from '../delay'; import * as Selectors from '../selectors'; export async function disconnect(browser: CompassBrowser): Promise { const cancelConnectionButtonElement = await browser.$( Selectors.CancelConnectionButton ); // If we are still connecting, let's try cancelling the connection first if (await cancelConnectionButtonElement.isDisplayed()) { try { await browser.closeConnectModal(); } catch (e) { // If that failed, the button was probably gone before we managed to // click it. Let's go through the whole disconnecting flow now } } await delay(100); await browser.execute(() => { // eslint-disable-next-line @typescript-eslint/no-var-requires require('electron').ipcRenderer.emit('app:disconnect'); }); const element = await browser.$(Selectors.ConnectSection); await element.waitForDisplayed(); await browser.clickVisible(Selectors.SidebarNewConnectionButton); await delay(100); }