Skip to content

Commit

Permalink
debug e2e test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 25, 2024
1 parent 171bee6 commit c33402c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion tests/e2e-uninstall/get-matomo-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@
$query->execute();

$tables = $query->fetchAll( \PDO::FETCH_COLUMN );
echo json_encode( $tables );
echo json_encode(
[
'dbname' => $dbname,
'tables' => $tables,
]
);
12 changes: 8 additions & 4 deletions tests/e2e-uninstall/uninstall.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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`);
result = await result.text();
try {
Expand All @@ -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

Expand Down Expand Up @@ -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
});
});

0 comments on commit c33402c

Please sign in to comment.