Skip to content

Commit

Permalink
add UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Dec 6, 2023
1 parent c81b103 commit 92eb44c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
70 changes: 70 additions & 0 deletions plugins/Marketplace/tests/UI/ManageLicense_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*!
* Matomo - free/libre analytics platform
*
* Screenshot tests for Marketplace.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

describe("ManageLicense", function () {
this.timeout(0);

this.fixture = "Piwik\\Plugins\\Marketplace\\tests\\Fixtures\\SimpleFixtureTrackFewVisits";

const urlBase = '?module=Marketplace&action=manageLicenseKey';

async function captureSelector(screenshotName, selector)
{
await page.evaluate(function () {
$('#secondNavBar').css('visibility', 'hidden'); // hide navbar so shadow isn't shown on screenshot
});
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage(screenshotName);
}

it('should show manage license key page', async function () {
await page.goto(urlBase);
await page.mouse.move(-10, -10);

await captureSelector('loaded', '.pageWrap,#notificationContainer');
});

it('should not accept invalid license key', async function () {
await page.type('#license_key', 'invalid_key');
await page.click('#submit_license_key input');

await captureSelector('invalid', '.pageWrap,#notificationContainer');
});

it('should accept valid license key', async function () {
await page.goto(urlBase);
await page.type('#license_key', 'valid');
await page.waitForTimeout(200);

testEnvironment.consumer = 'validLicense';
testEnvironment.mockMarketplaceApiService = 1;
testEnvironment.save();

await page.click('#submit_license_key input');

await captureSelector('valid', '.pageWrap,#notificationContainer');
});

it('should show dialog before removing license', async function () {
await page.click('#remove_license_key input');

await captureSelector('remove_dialog', '.modal.open');
});

it('should remove license on confirm', async function () {
delete testEnvironment.consumer;
delete testEnvironment.mockMarketplaceApiService;
testEnvironment.save();

const button = await page.jQuery('.modal.open .modal-footer a:contains(Yes)');
await button.click();

await captureSelector('removed', '.pageWrap,#notificationContainer');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 92eb44c

Please sign in to comment.