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
|
/*!
* Matomo - free/libre analytics platform
*
* Screenshot integration tests for MultiSites.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("MultiSitesTest", function () {
this.timeout(0);
var generalParams = 'idSite=1&period=year&date=2012-08-09';
var rangeParams = 'idSite=1&period=range&date=2012-08-05,2012-08-15';
var selector = '#multisites,.expandDataTableFooterDrawer';
var createdSiteIds = [];
before(async function() {
var response = await testEnvironment.callApi("SitesManager.addSite", {
siteName: '%3CMy%20website%22%27%3E%3B%2C%3F with a very very very very long stupid name',
urls: 'http%3A%2F%2Fpiwik.org%2F'
});
createdSiteIds.push(response.value);
for (var i = 0; i < 50; i++) {
var response = await testEnvironment.callApi("SitesManager.addSite", {
siteName: 'dynamically created page ' + i,
urls: 'http%3A%2F%2Fpiwik.org%2F' + i
});
createdSiteIds.push(response.value);
}
});
after(async function() {
const promises = createdSiteIds.map(async function(createdSiteId) {
return testEnvironment.callApi("SitesManager.deleteSite", {idSite: createdSiteId});
});
await Promise.all(promises);
});
it('should load the all websites dashboard correctly', async function() {
await page.goto("?" + generalParams + "&module=MultiSites&action=index");
await page.waitFor(500);
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage('all_websites');
});
it('should load next page correctly', async function() {
await page.click('.paging .next');
await page.mouse.move(-10, -10);
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage('all_websites_page_1');
});
it('should search correctly', async function() {
await page.type('.site_search input', 'Site');
await page.evaluate(function() {
$('.site_search .search_ico').click();
});
await page.mouse.move(-10, -10);
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage('all_websites_search');
});
it('should toggle sort order when click on current metric', async function() {
await page.click('#visits .heading');
await page.mouse.move(-10, -10);
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage('all_websites_changed_sort_order');
});
it('should load the all websites dashboard correctly when period is range', async function () {
await page.goto("?" + rangeParams + "&module=MultiSites&action=index");
await page.waitForNetworkIdle();
expect(await page.screenshotSelector(selector)).to.matchImage('all_websites_range');
});
});
|