Skip to content

Commit

Permalink
improve test again and remove some unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Nov 27, 2024
1 parent 1883630 commit 33963a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 0 additions & 2 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ function matomo_log_message_no_display($message)
if ( !is_plugin_active('matomo/matomo.php')
// during tests the plugin may temporarily not be active
&& (!defined( 'MATOMO_PHPUNIT_TEST' ) || !MATOMO_PHPUNIT_TEST)
// when uninstalling the plugin may not be active
&& empty( $GLOBALS['MATOMO_UNINSTALLING'] )
) {
exit;
}
Expand Down
23 changes: 16 additions & 7 deletions tests/e2e-uninstall/uninstall.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@ describe('MWP Uninstall', () => {
await Website.login();
});

async function getTablesInstalled(): Promise<any> {
let result: any = await fetch(`${await Website.rootUrl()}/matomo-for-wordpress/tests/e2e-uninstall/get-matomo-tables.php`);
result = await result.text();
try {
result = JSON.parse(result);
} catch (e) {
throw new Error(`Failed to parse get-matomo-tables.php response: ${result}`);
}
return result;
}

it('should uninstall and remove all data when the "remove all data" option is enabled', async () => {
let tablesBeforeUninstall = await getTablesInstalled();
tablesBeforeUninstall = tablesBeforeUninstall.filter((t: string) => t.includes('matomo'));
expect(tablesBeforeUninstall.length).toBeGreaterThan(0); // before uninstalling, check there are tables with "matomo" in the name

await browser.url(`${await Website.baseUrl()}/wp-admin/plugins.php`);

await $('#deactivate-matomo').waitForExist({ timeout: 60000 });
Expand Down Expand Up @@ -46,13 +61,7 @@ describe('MWP Uninstall', () => {
}

// check that no matomo table exists in the database
let result: any = await fetch(`${await Website.rootUrl()}/matomo-for-wordpress/tests/e2e-uninstall/get-matomo-tables.php`);
result = await result.text();
try {
result = JSON.parse(result);
} catch (e) {
throw new Error(`Failed to parse get-matomo-tables.php response: ${result}`);
}
let result = await getTablesInstalled();

expect(result.length).toBeGreaterThan(0); // sanity check

Expand Down

0 comments on commit 33963a4

Please sign in to comment.