Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Theme_spec.js « specs « UI « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 23620a8ca733493fbf0c406e17ff223008f47cbb (plain)
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
/*!
 * Piwik - free/libre analytics platform
 *
 * Tests that theming works.
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

var fs = require('fs'),
    path = require('../../lib/screenshot-testing/support/path');

var removeTree = function(path) {
    if (fs.existsSync(path)) {
        fs.readdirSync(path).forEach(function (file, index) {
            var curPath = path + "/" + file;
            if (fs.lstatSync(curPath).isDirectory()) { // recurse
                removeTree(curPath);
            } else { // delete file
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}

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

    function clearAssets() {
        removeTree(path.join(PIWIK_INCLUDE_PATH, 'tmp', 'assets'));
    }

    before(function () {
        testEnvironment.pluginsToLoad = ['ExampleTheme'];

        // Enable development mode to be able to see the UI demo page
        testEnvironment.overrideConfig('Development', 'enabled', true);
        testEnvironment.save();

        clearAssets();
    });

    after(function () {
        
        clearAssets();
    });

    it("should use the current theme", async function () {
        await page.goto("?module=CoreHome&action=index&idSite=1&period=year&date=2012-08-09");
        await page.waitFor(500); // wait for angular finished rendering
        expect(await page.screenshot({ fullPage: true })).to.matchImage('home');
    });

    it("should theme the UI demo page", async function () {
        await page.goto("?module=Morpheus&action=demo");
        await page.waitFor('.progressbar img');
        await page.evaluate(() => {
            $('img[src~=loading],.progressbar img').each(function () {
                $(this).hide();
            });
        });
        await page.waitFor(500); // wait for angular finished rendering
        await page.waitForNetworkIdle();
        expect(await page.screenshot({ fullPage: true })).to.matchImage('demo');
    });
});