From 78c3235d10e5d48e899dc5d6773cfe64dab13070 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Thu, 18 Jul 2024 11:05:39 +0100 Subject: [PATCH] throw if we didn't find exactly one connection --- .../helpers/commands/sidebar-connection.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts index d0dd14be131..8db1a1c1d94 100644 --- a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts +++ b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts @@ -7,6 +7,16 @@ export async function getConnectionIdByName( connectionName: string ): Promise { // NOTE: this is only supported for multiple connections + const connections = await browser.$$( + Selectors.sidebarConnection(connectionName) + ); + + if (connections.length !== 1) { + throw new Error( + `Found ${connections.length} connections named ${connectionName}.` + ); + } + return await browser .$(Selectors.sidebarConnection(connectionName)) .getAttribute('data-connection-id');