File size: 4,470 Bytes
f1bab00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /*!
* Matomo - free/libre analytics platform
*
* Screenshot integration tests.
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("SystemSettings", function () {
this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite";
var baseUrl = '?module=CoreAdminHome&action=generalSettings';
async function screenshotPageWrap() {
const pageWrap = await page.$('.pageWrap');
const screenshot = await pageWrap.screenshot();
return screenshot;
}
async function setCnilPolicyEnforced(enforced) {
if (enforced) {
testEnvironment.overrideConfig('CnilPolicy', 'cnil_v1_policy_enabled', 1);
} else {
delete testEnvironment.configOverride.CnilPolicy;
}
await testEnvironment.save();
}
it('should load the system settings correctly', async function () {
await page.goto(baseUrl);
expect(await screenshotPageWrap()).to.matchImage('settings');
});
it('should display compliance info for policy controlled settings', async function () {
await setCnilPolicyEnforced(true);
await page.goto(baseUrl);
await page.waitForNetworkIdle();
await setCnilPolicyEnforced(false);
expect(await screenshotPageWrap()).to.matchImage('compliance_info');
});
describe('mail settings password confirmation', function () {
var smtpSaveButton = '[vue-entry="CoreAdminHome.SmtpSettings"] .matomo-save-button';
async function openMailSettingsConfirmation() {
// ensure no leftover modal/overlay from a previous interaction can swallow the click
await page.waitForFunction(
() => $('.modal.open').length === 0 && $('.modal-overlay').length === 0
);
await page.click(smtpSaveButton);
await page.waitForSelector('.modal.open #currentUserPassword', { visible: true });
await page.waitForTimeout(250);
}
it('should require password confirmation when saving the mail settings', async function () {
await page.goto(baseUrl);
await page.waitForNetworkIdle();
await openMailSettingsConfirmation();
const passwordFieldVisible = await page.evaluate(
() => $('.modal.open #currentUserPassword:visible').length > 0
);
expect(passwordFieldVisible).to.equal(true);
});
it('should not save the mail settings when the confirmation is aborted', async function () {
await (await page.jQuery('.confirm-password-modal .modal-close.modal-no:visible')).click();
await page.waitForFunction(() => $('.modal.open').length === 0);
const hasSuccessNotification = await page.evaluate(
() => $('.notification-success').length > 0
);
expect(hasSuccessNotification).to.equal(false);
});
it('should not save the mail settings when the confirmed password is wrong', async function () {
await openMailSettingsConfirmation();
await page.type('.modal.open #currentUserPassword', 'wrongpassword');
await (await page.jQuery('.confirm-password-modal .confirm-password-btn:visible')).click();
await page.waitForNetworkIdle();
await page.waitForSelector('.notification-error', { visible: true });
const notificationHtml = await page.evaluate(
() => $('.notification-error>div>div').html()
);
expect(notificationHtml).to.equal('The current password you entered is not correct.');
});
it('should save the mail settings when the correct password is confirmed', async function () {
await page.evaluate(() => $('.notification-error .close').click());
await openMailSettingsConfirmation();
await page.type('.modal.open #currentUserPassword', superUserPassword);
await (await page.jQuery('.confirm-password-modal .confirm-password-btn:visible')).click();
await page.waitForNetworkIdle();
await page.waitForSelector('.notification-success', { visible: true });
const hasSuccessNotification = await page.evaluate(
() => $('.notification-success').length > 0
);
expect(hasSuccessNotification).to.equal(true);
});
});
});
|