diff --git a/tests/e2e-uninstall/get-matomo-tables.php b/tests/e2e-uninstall/get-matomo-tables.php index 2a1a26660..2f5bf5030 100644 --- a/tests/e2e-uninstall/get-matomo-tables.php +++ b/tests/e2e-uninstall/get-matomo-tables.php @@ -24,4 +24,9 @@ $query->execute(); $tables = $query->fetchAll( \PDO::FETCH_COLUMN ); -echo json_encode( $tables ); +echo json_encode( + [ + 'dbname' => $dbname, + 'tables' => $tables, + ] +); diff --git a/tests/e2e-uninstall/uninstall.e2e.ts b/tests/e2e-uninstall/uninstall.e2e.ts index bb6be2357..cfd7dff44 100644 --- a/tests/e2e-uninstall/uninstall.e2e.ts +++ b/tests/e2e-uninstall/uninstall.e2e.ts @@ -16,6 +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`); result = await result.text(); try { @@ -27,7 +28,7 @@ describe('MWP Uninstall', () => { } it('should uninstall and remove all data when the "remove all data" option is enabled', async () => { - let tablesBeforeUninstall = await getTablesInstalled(); + let tablesBeforeUninstall = (await getTablesInstalled()).tables; tablesBeforeUninstall = tablesBeforeUninstall.filter((t: string) => t.includes('matomo')); expect(tablesBeforeUninstall.length).toBeGreaterThan(0); // before uninstalling, check there are tables with "matomo" in the name @@ -63,9 +64,12 @@ describe('MWP Uninstall', () => { // check that no matomo table exists in the database let result = await getTablesInstalled(); - expect(result.length).toBeGreaterThan(0); // sanity check + expect(result.tables).toBeInstanceOf(Array); // sanity check - result = result.filter((t: string) => t.includes('matomo')); - expect(result).toEqual([]); // check there are no tables with "matomo" in the name + 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 }); });