-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
plugins/Marketplace/tests/UI/expected-screenshots/ManageLicense_invalid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
plugins/Marketplace/tests/UI/expected-screenshots/ManageLicense_loaded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
plugins/Marketplace/tests/UI/expected-screenshots/ManageLicense_remove_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
plugins/Marketplace/tests/UI/expected-screenshots/ManageLicense_removed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
plugins/Marketplace/tests/UI/expected-screenshots/ManageLicense_valid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.