Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PrivacyManager_spec.js « UI « tests « PrivacyManager « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5fff7be1d2343b63ccbbdb462f15a1fcdf31ade5 (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
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
/*!
 * Piwik - free/libre analytics platform
 *
 * Screenshot integration tests.
 *
 * @link http://piwik.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();
    });

    function setAnonymizeStartEndDate(page)
    {
        // make sure tests do not fail every day
        page.evaluate(function () {
            $('input.anonymizeStartDate').val('2018-03-02').change();
            $('input.anonymizeEndDate').val('2018-03-02').change();
        });
    }
    
    function loadActionPage(page, action)
    {
        page.load(urlBase + action);

        if (action === 'privacySettings') {
            setAnonymizeStartEndDate(page);
        }
    }

    function selectModalButton(page, button)
    {
        page.click('.modal.open .modal-footer a:contains('+button+')');
    }

    function findDataSubjects(page)
    {
        page.click('.findDataSubjects .btn');
    }

    function anonymizePastData(page)
    {
        page.click('.anonymizePastData .btn');
    }

    function deleteDataSubjects(page)
    {
        page.click('.deleteDataSubjects input');
    }

    function enterSegmentMatchValue(page, value) {
        page.execCallback(function () {
            page.webpage.evaluate(function (theVal) {
                $('.metricValueBlock input').each(function (index) {
                    $(this).val(theVal).change();
                });
            }, value);
        });
    }

    function selectVisitColumn(page, title)
    {
        page.evaluate(function () {
            $('.selectedVisitColumns:last input.select-dropdown').click();
        });
        page.click('.selectedVisitColumns:last .dropdown-content li:contains(' + title + ')');
    }

    function selectActionColumn(page, title)
    {
        page.evaluate(function () {
            $('.selectedActionColumns:last input.select-dropdown').click();
        });
        page.execCallback(function () {
            page.webpage.evaluate(function (theTitle) {
                $('.selectedActionColumns:last .dropdown-content li:contains(' + theTitle + ')').click();
            }, title);
        });
    }

    function capturePage(screenshotName, test, done) {
        expect.screenshot(screenshotName).to.be.captureSelector('.pageWrap,#notificationContainer,.modal.open', test, done);
    }

    function captureAnonymizeLogData(screenshotName, test, done) {
        expect.screenshot(screenshotName).to.be.captureSelector('.logDataAnonymizer,#notificationContainer,.modal.open,.logDataAnonymizer table', test, done);
    }

    function captureModal(screenshotName, test, done) {
        expect.screenshot(screenshotName).to.be.captureSelector('.modal.open', test, done);
    }

    it('should load privacy opt out page', function (done) {
        capturePage('users_opt_out_default', function (page) {
            loadActionPage(page, 'usersOptOut');
        }, done);
    });

    it('should load privacy asking for consent page', function (done) {
        capturePage('consent_default', function (page) {
            loadActionPage(page, 'consent');
        }, done);
    });

    it('should load GDPR overview page', function (done) {
        capturePage('gdpr_overview', function (page) {
            loadActionPage(page, 'gdprOverview');
        }, done);
    });

    it('should load privacy settings page', function (done) {
        capturePage('privacy_settings_default', function (page) {
            loadActionPage(page, 'privacySettings');
        }, done);
    });

    it('should anonymize ip and visit column', function (done) {
        captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_prefilled', function (page) {
            page.click('[name=anonymizeIp] label');
            page.wait(500);
            selectVisitColumn(page, 'config_browser_name');
            selectVisitColumn(page, 'config_cookie');
        }, done);
    });

    it('should show a confirmation message before executing any anonymization', function (done) {
        captureModal('anonymizelogdata_anonymizeip_and_visit_column_confirmation_message', function (page) {
            anonymizePastData(page);
        }, done);
    });

    it('should be able to cancel anonymization of past data', function (done) {
        captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_cancelled', function (page) {
            selectModalButton(page, 'No');
        }, done);
    });

    it('should be able to confirm anonymization of past data', function (done) {
        captureAnonymizeLogData('anonymizelogdata_anonymizeip_and_visit_column_confirmed', function (page) {
            anonymizePastData(page);
            selectModalButton(page, 'Yes');
            setAnonymizeStartEndDate(page);
        }, done);
    });

    it('should prefill anonymize location and action column', function (done) {
        captureAnonymizeLogData('anonymizelogdata_anonymizelocation_anduserid_and_action_column_prefilled', function (page) {
            loadActionPage(page, 'privacySettings');
            page.click('[name=anonymizeLocation] label');
            page.click('[name=anonymizeTheUserId] label');
            page.wait(500);
            selectActionColumn(page, 'time_spent_ref_action');
            selectActionColumn(page, 'idaction_content_name');
        }, done);
    });

    it('should confirm anonymize location and action column', function (done) {
        captureAnonymizeLogData('anonymizelogdata_anonymizelocation_anduserid_and_action_column_confirmed', function (page) {
            anonymizePastData(page);
            selectModalButton(page, 'Yes');
            page.wait(1000);
            setAnonymizeStartEndDate(page);
        }, done);
    });

    it('should anonymize only one site and different date pre filled', function (done) {
        captureAnonymizeLogData('anonymizelogdata_one_site_and_custom_date_prefilled', function (page) {
            page.click('.form-group #anonymizeSite .title');
            page.wait(1000);
            page.click(".form-group #anonymizeSite [title='Site 1']");
            page.click('[name=anonymizeIp] label');
            page.evaluate(function () {
                $('input.anonymizeStartDate').val('2017-01-01').change();
                $('input.anonymizeEndDate').val('2017-02-14').change();
            });
        }, done);
    });

    it('should anonymize only one site and different date confirmed', function (done) {
        captureAnonymizeLogData('anonymizelogdata_one_site_and_custom_date_confirmed', function (page) {
            anonymizePastData(page);
            selectModalButton(page, 'Yes');
            page.wait(1000);
            setAnonymizeStartEndDate(page);
        }, done);
    });

    it('should load GDPR tools page', function (done) {
        capturePage('gdpr_tools_default', function (page) {
            loadActionPage(page, 'gdprTools');
        }, done);
    });

    it('should show no visitor found message', function (done) {
        capturePage('gdpr_tools_no_visits_found', function (page) {
            enterSegmentMatchValue(page, 'userfoobar')
            findDataSubjects(page);
        }, done);
    });

    it('should find visits', function (done) {
        capturePage('gdpr_tools_visits_found', function (page) {
            enterSegmentMatchValue(page, 'userId203');

            findDataSubjects(page);
        }, done);
    });

    it('should be able to show visitor profile', function (done) {
        capturePage('gdpr_tools_visits_showprofile', function (page) {
            page.click('.visitorLogTooltip:first');
        }, done);
    });

    it('should be able to add IP to segment search with one click', function (done) {
        capturePage('gdpr_tools_enrich_segment_by_ip', function (page) {
            page.click('#Piwik_Popover .visitor-profile-close');
            page.click('.visitorIp:first a');
        }, done);
    });

    it('should be able to uncheck a visit', function (done) {
        capturePage('gdpr_tools_uncheck_one_visit', function (page) {
            page.click('.entityTable tbody tr:nth-child(2) .checkInclude label');
        }, done);
    });

    it('should ask for confirmation before deleting any visit', function (done) {
        capturePage('gdpr_tools_delete_visit_unconfirmed', function (page) {
            deleteDataSubjects(page);
        }, done);
    });

    it('should be able to cancel deletion and not delete any data', function (done) {
        capturePage('gdpr_tools_delete_visit_cancelled', function (page) {
            selectModalButton(page, 'No');
        }, done);
    });

    it('should verify really no data deleted', function (done) {
        capturePage('gdpr_tools_delete_visit_cancelled_verified_no_data_deleted', function (page) {
            loadActionPage(page, 'gdprTools');
            page.wait(1000);
            enterSegmentMatchValue(page, 'userId203');
            findDataSubjects(page);
            page.click('.entityTable tbody tr:nth-child(2) .checkInclude label');
        }, done);
    });

    it('should be able to confirm deletion and then actually delete data', function (done) {
        capturePage('gdpr_tools_delete_visit_confirmed', function (page) {
            deleteDataSubjects(page);
            selectModalButton(page, 'Yes');
        }, done);
    });

});