Skip to content

Commit

Permalink
fill out multisite e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 29, 2024
1 parent 683d1c4 commit 2a31cdf
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 32 deletions.
37 changes: 31 additions & 6 deletions tests/e2e/mwp-admin.multisite.general.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
*
*/

import { expect, browser } from '@wdio/globals'
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';

describe('MultiSite General', function() {
const trunkSuffix = process.env.WORDPRESS_VERSION === 'trunk' ? '.trunk' : '';
Expand All @@ -22,16 +24,39 @@ describe('MultiSite General', function() {
await Website.login();
});

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

it('should display the MWP admin pages for a single site correctly', async () => {
// TODO
Website.switchSite('test2');

await GetStartedPage.open();

await GetStartedPage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.multisite.summary.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

it('should display the MWP settings page for a single site correctly', async () => {
// TODO
it('should display the MWP settings page for a single site correctly when MWP is network enabled', async () => {
await SettingsPage.open();

await SettingsPage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.multisite.settings.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

it('should display the Matomo reporting pages for a single site correctly', async () => {
// TODO
await browser.refresh();

await browser.execute(() => {
window.jQuery('.wp-submenu a').filter(function () { $(this).attr('href').includes('page=matomo-reporting'); })[0].click();
});

await expect(
await browser.checkFullPageScreen(`mwp-admin.multisite.mtm-reporting.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});
});

45 changes: 39 additions & 6 deletions tests/e2e/mwp-admin.multisite.network-admin.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
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';
import NetworkHelpPage from './pageobjects/mwp-network-admin/help.page.js';
import NetworkMarketplacePage from './pageobjects/mwp-network-admin/marketplace.page.js';

describe('Network Admin', function() {
const trunkSuffix = process.env.WORDPRESS_VERSION === 'trunk' ? '.trunk' : '';
Expand All @@ -22,24 +27,52 @@ describe('Network Admin', function() {
await Website.login();
});

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

it('should display the multisite get started page correctly', async () => {
// TODO
await NetworkMultiSitePage.open();

await NetworkMultiSitePage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.network.multisite.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

// settings, diagnostics, help, marketplace
it('should display the multisite settings page correctly', async () => {
// TODO
await NetworkSettingsPage.open();

await NetworkSettingsPage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.network.settings.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

it('should display the multisite diagnostics page correctly', async () => {
// TODO
await NetworkDiagnosticsPage.open();

await NetworkDiagnosticsPage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.network.diagnostics.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

it('should display the multisite help page correctly', async () => {
// TODO
await NetworkHelpPage.open();

await NetworkHelpPage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.network.help.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});

it('should display the multisite marketplace page correctly', async () => {
// TODO
await NetworkMarketplacePage.open();

await NetworkMarketplacePage.prepareWpAdminForScreenshot();
await expect(
await browser.checkFullPageScreen(`mwp-admin.network.marketplace.${process.env.PHP_VERSION}${trunkSuffix}`)
).toBeLessThan(0.01);
});
});
17 changes: 0 additions & 17 deletions tests/e2e/pageobjects/get-started.page.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/e2e/pageobjects/mwp-admin/get-started.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*
*/

import { $ } from '@wdio/globals';
import MwpPage from './page.js';

class MwpGetStartedPage extends MwpPage {
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/pageobjects/mwp-network-admin/diagnostics.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

import MwpPage from '../mwp-admin/page.js';

class NetworkDiagnosticsPage extends MwpPage {
async open() {
return super.open('/wp-admin/network/admin.php?page=matomo-systemreport');
}
}

export default new NetworkDiagnosticsPage();
17 changes: 17 additions & 0 deletions tests/e2e/pageobjects/mwp-network-admin/help.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

import MwpPage from '../mwp-admin/page.js';

class NetworkHelpPage extends MwpPage {
async open() {
return super.open('/wp-admin/network/admin.php?page=matomo-about');
}
}

export default new NetworkHelpPage();
17 changes: 17 additions & 0 deletions tests/e2e/pageobjects/mwp-network-admin/marketplace.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

import MwpPage from '../mwp-admin/page.js';

class NetworkHelpPage extends MwpPage {
async open() {
return super.open('/wp-admin/network/admin.php?page=matomo-marketplace');
}
}

export default new NetworkHelpPage();
17 changes: 17 additions & 0 deletions tests/e2e/pageobjects/mwp-network-admin/multisite.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

import MwpPage from '../mwp-admin/page.js';

class NetworkMultiSitePage extends MwpPage {
async open() {
return super.open('/wp-admin/network/admin.php?page=matomo-multisite');
}
}

export default new NetworkMultiSitePage();
17 changes: 17 additions & 0 deletions tests/e2e/pageobjects/mwp-network-admin/settings.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

import MwpPage from '../mwp-admin/page.js';

class NetworkSettingsPage extends MwpPage {
async open() {
return super.open('/wp-admin/network/admin.php?page=matomo-settings');
}
}

export default new NetworkSettingsPage();
1 change: 0 additions & 1 deletion tests/e2e/pageobjects/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import {$, browser} from '@wdio/globals';
import Website from '../website.js';
import GlobalSetup from '../global-setup.js';

export default class Page {
async open(path: string) {
Expand Down
16 changes: 15 additions & 1 deletion tests/e2e/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Website {
private wpNonce: string|undefined;
private loggedIn: boolean = false;
private isWooCommerceSetup: boolean = false;
private site: string|null = null;

rootUrl() {
let defaultHostname = 'localhost';
Expand All @@ -44,7 +45,20 @@ class Website {
const wordpressFolder = process.env.WORDPRESS_FOLDER || wordpressVersion;
const wordpressVersionUrlPart = wordpressFolder ? `/${wordpressFolder}` : '';

return `${this.rootUrl()}${wordpressVersionUrlPart}`;
let path = wordpressVersionUrlPart;
if (this.site) {
path = `${wordpressVersionUrlPart}/${this.site}`;
}

return `${this.rootUrl()}${path}`;
}

unsetSite() {
this.site = null;
}

switchSite(siteSlug: string) {
this.site = siteSlug;
}

async login() {
Expand Down

0 comments on commit 2a31cdf

Please sign in to comment.