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

CoreUpdaterDb_spec.js « UI « tests « CoreUpdater « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2972b473335388a07ce7e1007778e8b77876c4fe (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
68
69
70
71
72
73
74
75
/*!
 * Matomo - free/libre analytics platform
 *
 * CoreUpdater screenshot tests.
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

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

    this.fixture = "Piwik\\Plugins\\CoreUpdater\\tests\\Fixtures\\DbUpdaterTestFixture";

    before(function () {
        testEnvironment.tablesPrefix = 'piwik_';
        testEnvironment.save();
    });

    after(function () {
        if (testEnvironment.configOverride.General) {
            delete testEnvironment.configOverride.General;
            testEnvironment.save();
        }
    });

    function apiUpgradeTest(format) {
        it("should start the updater when an old version of Piwik is detected in the DB with format " + format, async function() {
            await page.goto(""); // page.downloadUrl needs jQuery loaded, so load a page
            const url = '?module=API&method=API.getPiwikVersion&format=' + format;
            var pageContents = await page.downloadUrl(url);

            expect.file('CoreUpdater.API.ErrorMessage' + format + '.txt').to.equal(pageContents);
        });
    }

    var formats = ['CSV', 'TSV', 'XML', 'JSON'];
    formats.forEach(apiUpgradeTest);

    it("should start the updater when an old version of Piwik is detected in the DB", async function() {
        await page.goto("");
        await page.evaluate(function () {
            $('p').each(function () {
                var replace = $(this).html().replace(/(?!1\.0)\d+\.\d+(\.\d+)?([\-a-z]*\d+)?/g, '');
                $(this).html(replace);
            });
        });

        expect(await page.screenshot({ fullPage: true })).to.matchImage('main');
    });

    it("should show instance id in updating screen", async function() {
        testEnvironment.configOverride.General = {
            instance_id: 'custom.instance'
        };
        testEnvironment.save();

        await page.goto("");
        await page.evaluate(function () {
            $('p').each(function () {
                var replace = $(this).html().replace(/(?!1\.0)\d+\.\d+(\.\d+)?([\-a-z]*\d+)?/g, '');
                $(this).html(replace);
            });
        });

        expect(await page.screenshot({ fullPage: true })).to.matchImage('main_instance');
    });

    it("should show the donation form when the update process is complete", async function() {
        await page.click('.btn');
        await page.waitForNetworkIdle();

        expect(await page.screenshot({ fullPage: true })).to.matchImage('updated');
    });
});