File size: 3,052 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 | /*!
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
var fs = require('fs'),
path = require('../../../../tests/lib/screenshot-testing/support/path');
describe("CustomLogo", function () {
before(function () {
testEnvironment.optionsOverride = {
branding_use_custom_logo: '1'
};
testEnvironment.save();
});
afterEach(function () {
[
path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo.png"),
path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo-header.png"),
path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo.svg")
].forEach(function(file) {
if (fs.existsSync(file)) {
fs.unlinkSync(file);
}
});
testEnvironment.testUseMockAuth = 1;
testEnvironment.save();
});
var copyLogo = function(svg) {
fs.copyFileSync(path.join(PIWIK_INCLUDE_PATH, "/tests/resources/customlogo/logo.png"), path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo.png"));
fs.copyFileSync(path.join(PIWIK_INCLUDE_PATH, "/tests/resources/customlogo/logo-header.png"), path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo-header.png"));
if (svg) {
fs.copyFileSync(path.join(PIWIK_INCLUDE_PATH, "/tests/resources/customlogo/logo.svg"), path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo.svg"));
}
};
[true, false].forEach(function (useSvg) {
var appendName = useSvg ? '_svg' : '';
var appendTitle = useSvg ? ' SVG' : '';
it('should show the custom'+appendTitle+' logo in admin header', async function () {
copyLogo(useSvg);
await page.goto("?idSite=1&period=year&date=2012-08-09&module=CoreAdminHome&action=index");
var navWrap = await page.$('.nav-wrapper');
expect(await navWrap.screenshot()).to.matchImage('admin'+appendName);
});
it('should show the custom'+appendTitle+' logo in login header', async function () {
testEnvironment.testUseMockAuth = 0;
testEnvironment.save();
copyLogo(useSvg);
await page.goto("");
var navWrap = await page.$('.nav-wrapper');
expect(await navWrap.screenshot()).to.matchImage('login'+appendName);
});
it('should show the custom'+appendTitle+' logo in unsubscribe email header', async function () {
copyLogo(useSvg);
await page.goto("?module=ScheduledReports&action=unsubscribe&token=");
var navWrap = await page.$('.nav-wrapper');
expect(await navWrap.screenshot()).to.matchImage('unsubscribe'+appendName);
});
});
// dummy test to ensure custom logo usage is reset
it('should remove the custom logo usage', async function () {
testEnvironment.optionsOverride = {
branding_use_custom_logo: '0'
};
testEnvironment.save();
await page.goto("");
});
});
|