Skip to content

Commit

Permalink
fix uninstall e2e test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 25, 2024
1 parent c33402c commit c82a833
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions tests/e2e-uninstall/get-matomo-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e-uninstall/uninstall.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe('MWP Uninstall', () => {
});

async function getTablesInstalled(): Promise<any> {
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);
Expand Down Expand Up @@ -67,7 +66,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
Expand Down
6 changes: 5 additions & 1 deletion wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit c82a833

Please sign in to comment.