From f057bc560fa6b0487825a45877cd1a031dcfa4dd Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:27:05 -0400 Subject: [PATCH] Reset app storage on mock-test failure to start app --- ts/test-mock/bootstrap.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ts/test-mock/bootstrap.ts b/ts/test-mock/bootstrap.ts index 7309ea396f..cea49eafda 100644 --- a/ts/test-mock/bootstrap.ts +++ b/ts/test-mock/bootstrap.ts @@ -266,7 +266,11 @@ export class Bootstrap { return path.join(this.backupPath, fileName); } - public async unlink(): Promise { + public unlink(): Promise { + return this.resetAppStorage(); + } + + private async resetAppStorage(): Promise { assert( this.storagePath !== undefined, 'Bootstrap has to be initialized first, see: bootstrap.init()' @@ -349,7 +353,6 @@ export class Bootstrap { debug('starting the app'); const { port } = this.server.address(); - const config = await this.generateConfig(port, extraConfig); let startAttempts = 0; const MAX_ATTEMPTS = 4; @@ -361,11 +364,16 @@ export class Bootstrap { `App failed to start after ${MAX_ATTEMPTS} times, giving up` ); } + + // eslint-disable-next-line no-await-in-loop + const config = await this.generateConfig(port, extraConfig); + const startedApp = new App({ main: ELECTRON, args: [CI_SCRIPT], config, }); + try { // eslint-disable-next-line no-await-in-loop await startedApp.start(); @@ -375,6 +383,9 @@ export class Bootstrap { `Failed to start the app, attempt ${startAttempts}, retrying`, error ); + + // eslint-disable-next-line no-await-in-loop + await this.resetAppStorage(); continue; }