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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*!
* Matomo - free/libre analytics platform
*
* Screenshot integration tests.
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
describe("PrivacyManager", function () {
this.timeout(0);
this.fixture = "Piwik\\Plugins\\PrivacyManager\\tests\\Fixtures\\MultipleSitesMultipleVisitsFixture";
var generalParams = 'idSite=1&period=day&date=2017-01-02',
urlBase = '?module=PrivacyManager&' + generalParams + '&action=';
before(function () {
testEnvironment.pluginsToLoad = ['PrivacyManager'];
testEnvironment.save();
});
async function setAnonymizeStartEndDate()
{
// make sure tests do not fail every day
await page.waitForSelector('input.anonymizeStartDate');
await page.evaluate(function () {
$('input.anonymizeStartDate').val('2018-03-02').change();
$('input.anonymizeEndDate').val('2018-03-02').change();
});
}
async function loadActionPage(action)
{
await page.goto(urlBase + action);
await page.waitForNetworkIdle();
if (action === 'privacySettings') {
await setAnonymizeStartEndDate();
}
}
async function selectModalButton(button)
{
var elem = await page.jQuery('.modal.open .modal-footer a:contains('+button+')');
await elem.click();
await page.waitForTimeout(500);
await page.waitForNetworkIdle();
}
async function findDataSubjects()
{
await page.click('.findDataSubjects .btn');
await page.waitForNetworkIdle();
await page.waitForTimeout(250);
}
async function anonymizePastData()
{
await page.click('.anonymizePastData .btn');
await page.waitForTimeout(1000); // wait for animation
}
async function deleteDataSubjects()
{
await page.evaluate(() => $('.deleteDataSubjects input').click());
await page.waitForTimeout(500); // wait for animation
}
async function enterSegmentMatchValue(value) {
await page.evaluate(theVal => {
$('.metricValueBlock input').each(function (index) {
$(this).val(theVal).change();
});
}, value);
await page.waitForTimeout(100);
}
async function selectVisitColumn(title)
{
await page.evaluate(function () {
$('.selectedVisitColumns:last input.select-dropdown').click();
});
var selector = '.selectedVisitColumns:last .dropdown-content li:contains(' + title + ')';
await page.waitForFunction('$("'+selector+'").length > 0');
var elem = await page.jQuery(selector);
await elem.click();
await page.waitForTimeout(100);
}
async function selectActionColumn(title)
{
await page.evaluate(function () {
$('.selectedActionColumns:last input.select-dropdown').click();
});
await page.waitForTimeout(100);
await page.evaluate(theTitle => {
$('.selectedActionColumns:last .dropdown-content li:contains(' + theTitle + ')').click();
}, title);
await page.waitForTimeout(100);
}
async function capturePage(screenshotName) {
await page.waitForNetworkIdle();
expect(await page.screenshotSelector('.pageWrap,#notificationContainer,.modal.open')).to.matchImage(screenshotName);
}
async function captureAnonymizeLogData(screenshotName) {
await page.waitForNetworkIdle();
expect(await page.screenshotSelector('.logDataAnonymizer,#notificationContainer,.modal.open,.logDataAnonymizer table')).to.matchImage(screenshotName);
}
async function captureModal(screenshotName) {
await page.waitForNetworkIdle();
const modal = await page.$('.modal.open');
expect(await modal.screenshot()).to.matchImage(screenshotName);
}
it('should load privacy opt out page', async function() {
await loadActionPage('usersOptOut');
await capturePage('users_opt_out_default');
});
it('should load privacy asking for consent page', async function() {
await loadActionPage('consent');
await capturePage('consent_default');
});
it('should load GDPR overview page', async function() {
testEnvironment.overrideConfig('Deletelogs', 'delete_logs_enable', '1');
testEnvironment.overrideConfig('Deletelogs', 'delete_logs_older_than', '95');
testEnvironment.overrideConfig('Deletereports', 'delete_reports_enable', '1');
testEnvironment.overrideConfig('Deletereports', 'delete_reports_older_than', '131');
testEnvironment.save();
await loadActionPage('gdprOverview');
await capturePage('gdpr_overview');
});
it('should load GDPR overview page', async function() {
testEnvironment.overrideConfig('Deletelogs', 'delete_logs_enable', '0');
testEnvironment.overrideConfig('Deletereports', 'delete_reports_enable', '0');
testEnvironment.save();
await loadActionPage('gdprOverview');
await capturePage('gdpr_overview_no_retention');
});
it('should load privacy settings page', async function() {
await loadActionPage('privacySettings');
await page.waitForNetworkIdle();
await capturePage('privacy_settings_default');
});
it('should anonymize ip and visit column', async function() {
await page.waitForSelector('[name="anonymizeIp"] label');
await page.click('[name="anonymizeIp"] label');
await selectVisitColumn('config_browser_name');
await selectVisitColumn('config_cookie');
await captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_prefilled');
});
it('should show a confirmation message before executing any anonymization', async function() {
await anonymizePastData();
await captureModal('anonymizelogdata_anonymizeip_and_visit_column_confirmation_message');
});
it('should be able to cancel anonymization of past data', async function() {
await selectModalButton('No');
await captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_cancelled');
});
it('should be able to confirm anonymization of past data', async function() {
await anonymizePastData();
await selectModalButton('Yes');
await setAnonymizeStartEndDate();
await captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_confirmed');
});
it('should prefill anonymize location and action column', async function() {
await loadActionPage('privacySettings');
await page.click('[name="anonymizeLocation"] label');
await page.click('[name="anonymizeTheUserId"] label');
await page.waitForTimeout(500);
await selectActionColumn('time_spent_ref_action');
await selectActionColumn('idaction_content_name');
await captureAnonymizeLogData('anonymizelogdata_anonymizelocation_anduserid_and_action_column_prefilled');
});
it('should confirm anonymize location and action column', async function() {
await anonymizePastData();
await selectModalButton('Yes');
await page.waitForTimeout(1000);
await setAnonymizeStartEndDate();
await captureAnonymizeLogData('anonymizelogdata_anonymizelocation_anduserid_and_action_column_confirmed');
});
it('should anonymize only one site and different date pre filled', async function() {
await page.click('.form-group #anonymizeSite .title');
await page.waitForTimeout(1000);
await page.click(".form-group #anonymizeSite [title='Site 1']");
await page.click('[name="anonymizeIp"] label');
await page.evaluate(function () {
$('input.anonymizeStartDate').val('2017-01-01').change();
$('input.anonymizeEndDate').val('2017-02-14').change();
});
await page.waitForTimeout(100);
await captureAnonymizeLogData('anonymizelogdata_one_site_and_custom_date_prefilled');
});
it('should anonymize only one site and different date confirmed', async function() {
await anonymizePastData();
await selectModalButton('Yes');
await page.waitForTimeout(1000);
await setAnonymizeStartEndDate();
await captureAnonymizeLogData('anonymizelogdata_one_site_and_custom_date_confirmed');
});
it('should load GDPR tools page', async function() {
await loadActionPage('gdprTools');
await capturePage('gdpr_tools_default');
});
it('should show no visitor found message', async function() {
await enterSegmentMatchValue('userfoobar');
await findDataSubjects();
await page.waitForSelector('.manageGdpr tr');
await page.mouse.move(-10, -10);
await capturePage('gdpr_tools_no_visits_found');
});
it('should find visits', async function() {
await enterSegmentMatchValue('userId203');
await findDataSubjects();
await capturePage('gdpr_tools_visits_found');
});
it('should be able to show visitor profile', async function() {
var elem = await page.jQuery('.visitorLogTooltip:first');
await elem.click();
await page.waitForNetworkIdle();
expect(await page.screenshotSelector('.ui-dialog')).to.matchImage('gdpr_tools_visits_showprofile');
});
it('should be able to add IP to segment search with one click', async function() {
await page.click('#Piwik_Popover .visitor-profile-close');
var elem = await page.jQuery('.visitorIp:first a');
await elem.click();
await page.waitForNetworkIdle();
await capturePage('gdpr_tools_enrich_segment_by_ip');
});
it('should be able to uncheck a visit', async function() {
await page.click('.entityTable tbody tr:nth-child(2) .checkInclude label');
await page.mouse.move(-10, -10);
await capturePage('gdpr_tools_uncheck_one_visit');
});
it('should ask for confirmation before deleting any visit', async function() {
await deleteDataSubjects();
const modal = await page.waitForSelector('.modal.open', { visible: true });
expect(await modal.screenshot()).to.matchImage('gdpr_tools_delete_visit_unconfirmed');
});
it('should be able to cancel deletion and not delete any data', async function() {
await selectModalButton('No');
await page.waitForTimeout(500);
await capturePage('gdpr_tools_delete_visit_cancelled');
});
it('should verify really no data deleted', async function() {
await loadActionPage('gdprTools');
await page.waitForTimeout(1000);
await enterSegmentMatchValue('userId203');
await findDataSubjects();
await page.click('.entityTable tbody tr:nth-child(2) .checkInclude label');
await capturePage('gdpr_tools_delete_visit_cancelled_verified_no_data_deleted');
});
it('should be able to confirm deletion and then actually delete data', async function() {
await deleteDataSubjects();
await selectModalButton('Yes');
await capturePage('gdpr_tools_delete_visit_confirmed');
});
});
|