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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
/*!
* Piwik - free/libre analytics platform
*
* Bar graph screenshot tests.
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("Comparison", function () {
const generalParams = 'idSite=1&period=range&date=2012-01-12,2012-01-17',
urlBase = 'module=CoreHome&action=index&' + generalParams,
dashboardUrl = "?" + urlBase + "#?" + generalParams + "&category=Dashboard_Dashboard&subcategory=5",
tokenAuth = "9ad1de7f8b329ab919d854c556f860c1", // md5('superUserLogin' . md5('superUserPass'))
comparePeriod = "&compareDates[]=2012-01-01,2012-01-31&comparePeriods[]=range",
compareSegment = "&compareSegments[]=continentCode%3D%3Deur",
compareParams = comparePeriod + compareSegment,
barGraphUrl = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getKeywords&viewDataTable=graphVerticalBar&isFooterExpandedInDashboard=1&"
+ "token_auth=" + tokenAuth + compareParams,
pieGraphUrl = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getKeywords&viewDataTable=graphPie&isFooterExpandedInDashboard=1&"
+ "token_auth=" + tokenAuth + compareParams,
goalsTableUrl = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getKeywords&viewDataTable=tableGoals&filter_limit=5&isFooterExpandedInDashboard=1" + compareParams,
htmlTableUrl = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getSearchEngines&viewDataTable=table&filter_limit=5&isFooterExpandedInDashboard=1" + compareParams,
htmlTableUrlNoPeriods = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getSearchEngines&viewDataTable=table&filter_limit=5&isFooterExpandedInDashboard=1" + compareSegment,
htmlTableUrlNoSegments = "?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&idSite=1&period=year&date=2012-08-09&"
+ "actionToWidgetize=getSearchEngines&viewDataTable=table&filter_limit=5&isFooterExpandedInDashboard=1" + comparePeriod,
visitOverviewWidget = "?module=Widgetize&action=iframe&containerId=VisitOverviewWithGraph&disableLink=0&widget=1&" +
"moduleToWidgetize=CoreHome&actionToWidgetize=renderWidgetContainer&disableLink=1&widget=1&" + generalParams + "&" +
compareParams
;
it('should compare periods correctly when comparing the last period', async () => {
await page.goto(dashboardUrl);
await page.waitForNetworkIdle();
await page.click('#periodString');
await page.waitFor('label[for=comparePeriodTo]');
await page.click('label[for=comparePeriodTo]');
await page.click('#calendarApply');
await page.waitForNetworkIdle();
await page.waitFor('.widget');
await page.waitForNetworkIdle();
await page.waitFor('.piwik-graph');
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('dashboard_last_period');
});
it('should add a segment comparison when the compare icon in the segment list is clicked', async () => {
await page.click('.segmentationContainer');
await (await page.jQuery('li[data-idsegment=2] .compareSegment', { waitFor: true })).click();
await page.waitForNetworkIdle();
await page.waitFor('.widget');
await page.waitForNetworkIdle();
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('dashboard_last_period_and_segment');
});
it('should not show comparisons for pages that do not support it', async () => {
await (await page.jQuery('li.menuTab:contains(Behaviour)')).click();
await page.waitFor(100);
await (await page.jQuery('a.item:contains(Transitions)')).click();
await page.waitForNetworkIdle();
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('transitions');
});
it('should show extra serieses when comparing in evolution graphs and sparklines', async () => {
await (await page.jQuery('li.menuTab:contains(Visitors)')).click();
await page.waitFor(100);
await (await page.jQuery('li.menuTab:contains(Visitors) a.item:contains(Overview)')).click();
await page.waitForNetworkIdle();
await page.waitFor('.piwik-graph');
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('visitors_overview');
});
it('should change the evolution series when the sparkline is clicked', async () => {
await (await page.jQuery('.sparkline:contains(pageviews):eq(0)')).click();
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('visitors_overview_switched');
});
it('should show the tooltip correctly in an evolution graph', async () => {
await page.hover('.piwik-graph');
await page.waitFor(250);
const element = await page.$('.ui-tooltip');
expect(await element.screenshot()).to.matchImage('visitors_overview_tooltip');
});
it('should remove segment comparison when the x button is clicked', async () => {
await page.click('.card.comparison .remove-button');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('visitors_overview_segment_removed');
});
it('should remove period comparison if period is selected w/o compare set', async () => {
await page.click('#periodString .periodSelector');
await page.waitFor('label[for=comparePeriodTo]', { visible: true });
await page.click('label[for=comparePeriodTo]');
await page.click('#calendarApply');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const pageWrap = await page.$('.pageWrap');
expect(await pageWrap.screenshot()).to.matchImage('visitors_overview_no_compare');
});
it('should show the bar graph correctly when comparing segments and period', async () => {
await page.goto(barGraphUrl);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('bar_graph');
});
it('should show the pie graph correctly when comparing segments and period', async () => {
await page.goto(pieGraphUrl);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('pie_graph');
});
it('should show the normal html table correctly when comparing segments and periods', async () => {
await page.goto(htmlTableUrl);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('normal_table');
});
it('should show the correct percentages and tooltip during comparison', async () => {
const element = await page.jQuery('span.ratio:visible:eq(1)');
await element.hover();
const tooltip = await page.waitFor('.ui-tooltip', { visible: true });
expect(await tooltip.screenshot()).to.matchImage('totals_tooltip');
});
it('should show the normal html table correctly when comparing segments but not periods', async () => {
await page.goto(htmlTableUrlNoPeriods);
await page.mouse.move(-10, -10); // mae sure no row is highlighted
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('normal_table_no_periods');
});
it('should show the normal html table correctly when comparing periods but not segments', async () => {
await page.goto(htmlTableUrlNoSegments);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('normal_table_no_segments');
});
it('should expand subtables correctly when comparing', async () => {
(await page.$$('tr.subDataTable'))[0].click();
await page.waitForNetworkIdle();
await page.waitFor(function () {
return $('.cellSubDataTable > .dataTable').length === 1;
});
await page.mouse.move(-10, -10); // mae sure no row is highlighted
expect(await page.screenshot({ fullPage: true })).to.matchImage('subtables_loaded');
});
it('should advance to the next page when paginating the subtable', async () => {
await page.click('.cellSubDataTable .dataTableNext');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10); // mae sure no row is highlighted
expect(await page.screenshot({ fullPage: true })).to.matchImage('subtables_paginate');
});
it('should show the row evolution popup for the compared row/segment/period when clicked', async () => {
const row = await page.jQuery('tbody tr.comparisonRow:visible:eq(1)');
await row.hover();
const icon = await page.jQuery('tbody tr.comparisonRow:visible:eq(1) a.actionRowEvolution');
await icon.click();
await page.waitForSelector('.ui-dialog');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const dialog = await page.$('.ui-dialog');
expect(await dialog.screenshot()).to.matchImage('row_evolution');
});
it('should show the multirow evolution popup for another comparison series', async () => {
await page.click('.rowevolution-startmulti');
await page.waitFor(250);
const row = await page.jQuery('tbody tr.comparisonRow:visible:eq(0)');
await row.hover();
const icon = await page.jQuery('tbody tr.comparisonRow:visible:eq(0) a.actionRowEvolution');
await icon.click();
await page.waitForSelector('.ui-dialog');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const dialog = await page.$('.ui-dialog');
expect(await dialog.screenshot()).to.matchImage('multi_row_evolution');
});
it('should show the segmented visitor log popup for the compared row/segment/period when clicked', async () => {
await page.click('.ui-dialog-titlebar-close');
const row = await page.jQuery('tbody tr.comparisonRow:eq(1)');
await row.hover();
const icon = await page.jQuery('tbody tr.comparisonRow:eq(1) a.actionSegmentVisitorLog');
await icon.click();
await page.waitForSelector('.ui-dialog');
await page.waitForNetworkIdle();
await page.mouse.move(-10, -10);
const dialog = await page.$('.ui-dialog');
expect(await dialog.screenshot()).to.matchImage('segmented_visitorlog');
});
it('should show the goals table correctly when comparing segments and period', async () => {
await page.goto(goalsTableUrl);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('goals_table');
});
it('should load a widgetized sparklines visualization correctly', async () => {
await page.goto(visitOverviewWidget);
await page.waitForNetworkIdle();
expect(await page.screenshot({ fullPage: true })).to.matchImage('visits_overview_widget');
});
});
|