Skip to content

Commit

Permalink
override wordpress folder in multisite e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 29, 2024
1 parent 767e868 commit a98ed29
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 1 addition & 5 deletions classes/WpMatomo.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,7 @@ public function init_plugin() {
if ( $installer->looks_like_it_is_installed() ) {
if ( is_admin() && ( ! defined( 'MATOMO_ENABLE_AUTO_UPGRADE' ) || MATOMO_ENABLE_AUTO_UPGRADE ) ) {
$updater = new Updater( self::$settings );
try {
$updater->update_if_needed();
} catch (\Exception $ex) {
print "install failed: " . print_r(\Piwik\Config::getInstance()->PluginsInstalled, true);@ob_flush();exit;
}
$updater->update_if_needed();
}
} else {
if ( matomo_is_app_request() ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/mwp-admin.multisite.general.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { expect, browser } from '@wdio/globals';
import Website from './website.js';
import GlobalSetup from './global-setup.js';
import GetStartedPage from './pageobjects/mwp-admin/get-started.page.js';
import SettingsPage from './pageobjects/mwp-admin/settings.page.js';

Expand All @@ -20,12 +19,13 @@ describe('MultiSite General', function() {
throw new Error('Unexpected: PHP_VERSION environment variable cannot be found.');
}

await GlobalSetup.setUp();
Website.overrideWordPressFolder(`${await Website.getWpFolder()}-multi`);
await Website.login();
});

after(async () => {
Website.unsetSite();
Website.removeWordPressFolderOverride();
});

it('should display the MWP admin pages for a single site correctly', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/mwp-admin.multisite.network-admin.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { expect, browser } from '@wdio/globals'
import Website from './website.js';
import GlobalSetup from './global-setup.js';
import NetworkMultiSitePage from './pageobjects/mwp-network-admin/multisite.page.js';
import NetworkSettingsPage from './pageobjects/mwp-network-admin/settings.page.js';
import NetworkDiagnosticsPage from './pageobjects/mwp-network-admin/diagnostics.page.js';
Expand All @@ -23,12 +22,13 @@ describe('Network Admin', function() {
throw new Error('Unexpected: PHP_VERSION environment variable cannot be found.');
}

await GlobalSetup.setUp();
Website.overrideWordPressFolder(`${await Website.getWpFolder()}-multi`);
await Website.login();
});

after(async () => {
Website.unsetSite();
Website.removeWordPressFolderOverride();
});

it('should display the multisite get started page correctly', async () => {
Expand Down
16 changes: 15 additions & 1 deletion tests/e2e/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Website {
private loggedIn: boolean = false;
private isWooCommerceSetup: boolean = false;
private site: string|null = null;
private wordPressFolderOverride: string|null = null;

rootUrl() {
let defaultHostname = 'localhost';
Expand All @@ -40,9 +41,14 @@ class Website {
return `${process.env.WORDPRESS_URL || `http://${defaultHostname}`}`;
}

async baseUrl() {
async getWpFolder() {
const wordpressVersion = process.env.WORDPRESS_VERSION || (await getLatestWordpressVersion());
const wordpressFolder = process.env.WORDPRESS_FOLDER || wordpressVersion;
return wordpressFolder;
}

async baseUrl() {
const wordpressFolder = await this.getWpFolder();
const wordpressVersionUrlPart = wordpressFolder ? `/${wordpressFolder}` : '';

let path = wordpressVersionUrlPart;
Expand Down Expand Up @@ -221,6 +227,14 @@ class Website {
throw new Error(`unable to set user profile language to ${locale}`);
}
}

overrideWordPressFolder(folder: string) {
this.wordPressFolderOverride = folder;
}

removeWordPressFolderOverride() {
this.wordPressFolderOverride = null;
}
}

export default new Website();

0 comments on commit a98ed29

Please sign in to comment.