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
115
116
117
118
119
120
121
122
123
|
/*!
* Matomo - free/libre analytics platform
*
* OneClickUpdate screenshot tests.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
const request = require('request-promise');
const exec = require('child_process').exec;
describe("OneClickUpdate", function () {
this.fixture = "Piwik\\Tests\\Fixtures\\LatestStableInstall";
var latestStableUrl = config.piwikUrl + '/latestStableInstall/index.php';
var settingsUrl = latestStableUrl + '?module=CoreAdminHome&action=home&idSite=1&period=day&date=yesterday';
it('should show the new version available button in the admin screen', async function () {
await page.goto(latestStableUrl);
await page.waitFor('#login_form_login', { visible: true });
await page.type('#login_form_login', 'superUserLogin');
await page.type('#login_form_password', 'superUserPass');
await page.click('#login_form_submit');
await page.waitForNetworkIdle();
await page.waitFor('.pageWrap');
await page.goto(settingsUrl);
const element = await page.waitFor('#header_message', { visible: true });
expect(await element.screenshot()).to.matchImage('latest_version_available');
});
it('should show the one click update screen when the update button is clicked', async function () {
await page.click('#header_message');
await page.waitForNetworkIdle();
await page.waitFor('.content');
expect(await page.screenshot({ fullPage: true })).to.matchImage('update_screen');
});
it('should fail to automatically update when trying to update over https fails', async function () {
await page.click('#updateAutomatically');
await page.waitForNetworkIdle();
await page.waitFor('.content');
expect(await page.screenshot({ fullPage: true })).to.matchImage('update_fail');
});
it('should update successfully and show the finished update screen', async function () {
await page.click('#updateUsingHttp');
await page.waitForNetworkIdle();
await page.waitFor('.content');
expect(await page.screenshot({ fullPage: true })).to.matchImage('update_success');
});
it('should login successfully after the update', async function () {
await page.click('.footer a');
await page.waitForNetworkIdle();
// in case a db upgrade is required
while (true) {
const submitButton = await page.$('.content input[type=submit]');
if (submitButton) {
await submitButton.click();
await page.waitForNetworkIdle();
await page.waitFor(250);
await page.click('.footer a');
await page.waitForNetworkIdle();
} else {
break;
}
}
await page.waitFor('#login_form_login', { visible: true });
await page.type('#login_form_login', 'superUserLogin');
await page.type('#login_form_password', 'superUserPass');
await page.click('#login_form_submit');
await page.waitFor('.site-without-data', { visible: true });
await page.waitForNetworkIdle();
const element = await page.$('.site-without-data');
expect(await element.screenshot()).to.matchImage('login');
});
it('should have a working cron archiving process', async function () {
// track one action
const trackerUrl = config.piwikUrl + "latestStableInstall/piwik.php?";
await request({
method: 'POST',
uri: trackerUrl,
form: {
idsite: 1,
url: 'http://piwik.net/test/url',
action_name: 'test page',
},
});
// run cron archiving
const output = await new Promise((resolve, reject) => {
exec(`${config.php} ${PIWIK_INCLUDE_PATH}/latestStableInstall/console --matomo-domain=${config.phpServer.HTTP_HOST} core:archive`, (error, stdout, stderr) => {
const output = stdout.toString() + "\n" + stderr.toString();
if (error) {
console.log(`core:archive failed, output: ${output}`);
reject(error);
return;
}
resolve(output);
});
});
// check output has no errors
expect(output).to.not.match(/ERROR|WARN/g);
});
});
|