diff --git a/src/test/e2e/webview/WebviewTestUtils.ts b/src/test/e2e/webview/WebviewTestUtils.ts index 6fc7803..53e8b46 100644 --- a/src/test/e2e/webview/WebviewTestUtils.ts +++ b/src/test/e2e/webview/WebviewTestUtils.ts @@ -184,8 +184,12 @@ export class WebviewTestUtils { await databaseName.sendKeys(config.databaseName, Key.TAB); const button = await webView.findWebElement(By.id(config.buttonToClick)); - - await button.click(); + try { + await button.click(); + } catch (error) { + await VSBrowser.instance.takeScreenshot(`${randomUUID()}-click-${config.buttonToClick}-${config.databaseType}`); + throw error; + } }); if (config.buttonToClick === "saveButton") { diff --git a/src/test/suite/DockerTestUtils.ts b/src/test/suite/DockerTestUtils.ts index 57de0dc..ab1f12e 100644 --- a/src/test/suite/DockerTestUtils.ts +++ b/src/test/suite/DockerTestUtils.ts @@ -1,6 +1,8 @@ import { exec } from "child_process"; import { isWindows } from "../../utilities/osUtilities"; import mariadb from "mariadb"; +import { VSBrowser } from "vscode-extension-tester"; +import { randomUUID } from "crypto"; /** * Creates and manages a maria docker container for tests. @@ -117,13 +119,9 @@ export class DockerTestUtils { * Checks the status of the specified container and the availability of the database within it. * * @param containerName - The name of the container to check. - * @param dbExecutable - The executable for the database client. * @returns A Promise that resolves when the container status and database availability are checked. */ - static async checkContainerStatus( - containerName: string = "mariadb", - dbExecutable: string = "mysql-client" - ): Promise { + static async checkContainerStatus(containerName: string = "mariadb"): Promise { const fullContainerName = this.containerNamePrefix + containerName; // check if container is running @@ -134,7 +132,7 @@ export class DockerTestUtils { case "mariadb": // install mysql to the container await this.repeatCommand( - `${this.docker} exec ${fullContainerName} sh -c "apt-get update && apt-get install -y ${dbExecutable}"` + `${this.docker} exec ${fullContainerName} sh -c "apt-get update && apt-get install -y mysql-client"` ); // check if database is available @@ -145,12 +143,22 @@ export class DockerTestUtils { // check if database is available case "postgres": - await this.repeatCommand(`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "SELECT 1;"`); + try { + await this.repeatCommand(`${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "SELECT 1;"`); + } catch (error) { + await VSBrowser.instance.takeScreenshot(`${randomUUID()}-status-check`); + throw error; + } - // - await this.executeCommand( - `${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "CREATE SCHEMA ${this.dbName};"` - ); + // create the needed schema + try { + await this.repeatCommand( + `${this.docker} exec ${fullContainerName} psql ${this.dbName} -c "CREATE SCHEMA ${this.dbName};"` + ); + } catch (error) { + await VSBrowser.instance.takeScreenshot(`${randomUUID()}-create-schema`); + throw error; + } break; default: