Skip to content

Commit

Permalink
Adds UI tests for Custom Logos (#13311)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl authored and diosmosis committed Aug 30, 2018
1 parent 06091e6 commit f5fdde3
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 0 deletions.
73 changes: 73 additions & 0 deletions plugins/CoreAdminHome/tests/UI/CustomLogo_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*!
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://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 () {
this.timeout(0);

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.exists(file)) {
fs.remove(file);
}
});
testEnvironment.testUseMockAuth = 1;
testEnvironment.save();
});

var copyLogo = function(svg) {
fs.copy(path.join(PIWIK_INCLUDE_PATH, "/tests/resources/customlogo/logo.png"), path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo.png"));
fs.copy(path.join(PIWIK_INCLUDE_PATH, "/tests/resources/customlogo/logo-header.png"), path.join(PIWIK_INCLUDE_PATH, "/misc/user/logo-header.png"));

if (svg) {
fs.copy(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', function (done) {
expect.screenshot('admin'+appendName).to.be.captureSelector('.nav-wrapper', function (page) {
copyLogo(useSvg);
page.load("?idSite=1&period=year&date=2012-08-09&module=CoreAdminHome&action=index");
}, done);
});

it('should show the custom'+appendTitle+' logo in login header', function (done) {
testEnvironment.testUseMockAuth = 0;
testEnvironment.save();

expect.screenshot('login'+appendName).to.be.captureSelector('.nav-wrapper', function (page) {
copyLogo(useSvg);
page.load("");
}, done);
});

it('should show the custom'+appendTitle+' logo in unsubscribe email header', function (done) {
expect.screenshot('unsubscribe'+appendName).to.be.captureSelector('.nav-wrapper', function (page) {
copyLogo(useSvg);
page.load("?module=ScheduledReports&action=unsubscribe&token=");
}, done);
});
});
});
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/resources/customlogo/logo-header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/resources/customlogo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/resources/customlogo/logo.svg
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 f5fdde3

Please sign in to comment.