blob: 7d03a1eb40cd5d47c7f93a3b36e24fa14cd5ffde (
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
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
|
/*!
* Matomo - free/libre analytics platform
*
* Export link screenshot tests.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("ReportExporting", function () {
var baseUrl = "?module=Widgetize&action=iframe&idSite=1&period=year&date=2012-08-09&isFooterExpandedInDashboard=1",
referrersGetWebsitesUrl = baseUrl + "&moduleToWidgetize=Referrers&actionToWidgetize=getWebsites&filter_limit=5",
visitsSummaryGetUrl = baseUrl + "&moduleToWidgetize=VisitsSummary&actionToWidgetize=get&forceView=1&viewDataTable=graphEvolution";
function normalReportTest(format) {
it("should export a normal report correctly when the " + format + " export is chosen", async function () {
if (await page.url() !== referrersGetWebsitesUrl) {
await page.goto(referrersGetWebsitesUrl);
await page.click('.activateExportSelection');
}
await page.waitForSelector('[name="format"] input[value="'+format+'"]');
await page.click('[name="format"] input[value="' + format + '"]');
await page.click('[name="filter_limit_all"] input[value="no"]');
await page.evaluate(function () {
$('[name=filter_limit] input').val(100).trigger('change');
});
var url = await page.evaluate(function () {
return $('#reportExport a.btn').attr('href');
});
var pageContents = await page.downloadUrl(url);
expect.file('Referrers.getWebsites_exported.' + format.toLowerCase() + '.txt').to.equal(pageContents);
});
}
function evolutionReportTest(format) {
it("should export an evolution graph report correctly when the " + format + " export is chosen", async function () {
if (await page.url() !== visitsSummaryGetUrl) {
await page.goto(visitsSummaryGetUrl);
await page.click('.activateExportSelection');
}
await page.waitForSelector('[name="format"] input[value="'+format+'"]');
await page.click('[name="format"] input[value="'+format+'"]');
await page.click('[name="filter_limit_all"] input[value="no"]');
await page.evaluate(function(){
$('[name=filter_limit] input').val(100).trigger('change');
});
var url = await page.evaluate(function() {
return $('#reportExport a.btn').attr('href');
});
var pageContents = await page.downloadUrl(url);
expect.file('VisitsSummary.get_exported.' + format.toLowerCase() + '.txt').to.equal(pageContents);
});
}
function rowEvolutionReportTest(format) {
it("should export an row evolution graph report correctly when the " + format + " export link is clicked", async function () {
if (!page.url() || page.url().indexOf('popover') === -1) {
await page.goto(referrersGetWebsitesUrl);
const row = await page.waitForSelector('tbody tr:first-child');
await row.hover();
const icon = await page.waitForSelector('tbody tr:first-child a.actionRowEvolution');
await icon.click();
await page.waitForSelector('.ui-dialog');
await page.waitForNetworkIdle();
await page.click('.ui-dialog .activateExportSelection');
}
await page.waitForSelector('[name="format"] input[value="'+format+'"]');
await page.click('[name="format"] input[value="'+format+'"]');
await page.click('[name="filter_limit_all"] input[value="no"]');
await page.evaluate(function(){
$('[name=filter_limit] input').val(100).trigger('change');
});
var url = await page.evaluate(function() {
return $('#reportExport a.btn').attr('href');
});
var pageContents = await page.downloadUrl(url);
expect.file('RowEvolution_exported.' + format.toLowerCase() + '.txt').to.equal(pageContents);
});
}
var formats = ['CSV', 'TSV', 'XML', 'JSON'];
formats.forEach(normalReportTest);
formats.forEach(evolutionReportTest);
formats.forEach(rowEvolutionReportTest);
});
|