From c35ae8800fedf0a26eded191c34bfadeb6c88311 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 25 Dec 2024 00:48:12 -0800 Subject: [PATCH] fix uninstall e2e test failure --- tests/e2e-uninstall/get-matomo-tables.php | 7 +++++++ tests/e2e-uninstall/uninstall.e2e.ts | 5 +---- wdio.conf.ts | 6 +++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/e2e-uninstall/get-matomo-tables.php b/tests/e2e-uninstall/get-matomo-tables.php index 2f5bf5030..4fce7878a 100644 --- a/tests/e2e-uninstall/get-matomo-tables.php +++ b/tests/e2e-uninstall/get-matomo-tables.php @@ -19,6 +19,13 @@ exit; } +$multi = isset( $_GET['multi'] ) ? ( (int) $_GET['multi'] ) : 0; + +$dbname = preg_replace( '/_multi$/', '', $dbname ); +if ( $multi ) { + $dbname .= '_multi'; +} + $pdo = new \PDO( "mysql:host=$host;dbname={$dbname}", 'root', 'pass' ); $query = $pdo->prepare( 'SHOW TABLES' ); $query->execute(); diff --git a/tests/e2e-uninstall/uninstall.e2e.ts b/tests/e2e-uninstall/uninstall.e2e.ts index cfd7dff44..f60b4f0aa 100644 --- a/tests/e2e-uninstall/uninstall.e2e.ts +++ b/tests/e2e-uninstall/uninstall.e2e.ts @@ -16,8 +16,7 @@ describe('MWP Uninstall', () => { }); async function getTablesInstalled(): Promise { - console.log('root url: ' + `${await Website.rootUrl()}/matomo-for-wordpress/tests/e2e-uninstall/get-matomo-tables.php`); - let result: any = await fetch(`${await Website.rootUrl()}/matomo-for-wordpress/tests/e2e-uninstall/get-matomo-tables.php`); + let result: any = await fetch(`${await Website.rootUrl()}/matomo-for-wordpress/tests/e2e-uninstall/get-matomo-tables.php?multi=0`); result = await result.text(); try { result = JSON.parse(result); @@ -66,8 +65,6 @@ describe('MWP Uninstall', () => { expect(result.tables).toBeInstanceOf(Array); // sanity check - console.log(`result.dbname is: ${result.dbname}`); - let tables = result.tables; tables = tables.filter((t: string) => t.includes('matomo')); expect(tables).toEqual([]); // check there are no tables with "matomo" in the name diff --git a/wdio.conf.ts b/wdio.conf.ts index 5b108ce7c..8d3f6ccc7 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -46,7 +46,11 @@ function checkWpDebugLogsForError() { throw new Error(`Found Matomo related errors/warnings in debug.log:\n- ${matomoErrors.join("\n- ")}`); } } finally { - fs.unlinkSync(wpDebugLogPath); // reset the wp-debug log file + try { + fs.unlinkSync(wpDebugLogPath); // reset the wp-debug log file + } catch (e) { + // ignore + } } }