@@ -13,7 +13,7 @@ module.exports = {
13
13
before : function ( browser : NightwatchBrowser , done : VoidFunction ) {
14
14
init ( browser , done , 'http://127.0.0.1:8080' , false )
15
15
} ,
16
- 'confirm Matomo #group1' : function ( browser : NightwatchBrowser ) {
16
+ 'accept all including Matomo anon and perf #group1' : function ( browser : NightwatchBrowser ) {
17
17
browser . perform ( ( done ) => {
18
18
browser
19
19
. execute ( function ( ) {
@@ -35,7 +35,7 @@ module.exports = {
35
35
} )
36
36
. waitForElementVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
37
37
. pause ( 1000 )
38
- . click ( '[data-id="matomoModal-modal-footer-ok-react"]' ) // submitted
38
+ . click ( '[data-id="matomoModal-modal-footer-ok-react"]' ) // Accepted
39
39
. execute ( function ( ) {
40
40
return ( window as any ) . _paq
41
41
} , [ ] , ( res ) => {
@@ -58,59 +58,25 @@ module.exports = {
58
58
} )
59
59
. waitForElementNotPresent ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
60
60
. clickLaunchIcon ( 'settings' )
61
- . verify . elementPresent ( '[id="settingsMatomoAnalytics "]:checked' )
61
+ . verify . elementPresent ( '[id="settingsMatomoPerfAnalytics "]:checked' )
62
62
. execute ( function ( ) {
63
63
return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-analytics' ] == true
64
64
} , [ ] , ( res ) => {
65
65
console . log ( 'res' , res )
66
66
browser . assert . ok ( ( res as any ) . value , 'matomo analytics is enabled' )
67
67
} )
68
- } ,
69
- 'decline Matomo #group1' : function ( browser : NightwatchBrowser ) {
70
- browser . perform ( ( done ) => {
71
- browser . execute ( function ( ) {
72
- localStorage . removeItem ( 'config-v0.8:.remix.config' )
73
- localStorage . setItem ( 'showMatomo' , 'true' )
74
- localStorage . removeItem ( 'matomo-analytics-consent' )
75
- } , [ ] )
76
- . refreshPage ( )
77
- . perform ( done ( ) )
78
- } )
79
- . waitForElementPresent ( {
80
- selector : `//*[@data-id='compilerloaded']` ,
81
- locateStrategy : 'xpath' ,
82
- timeout : 120000
83
- } )
84
68
. execute ( function ( ) {
85
- return ( window as any ) . _paq
69
+ return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-perf-analytics' ] == true
86
70
} , [ ] , ( res ) => {
87
- console . log ( '_paq' , res )
88
- } )
89
- . waitForElementVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
90
- . click ( '[data-id="matomoModal-modal-footer-cancel-react"]' ) // cancel
91
- . execute ( function ( ) {
92
- return ( window as any ) . _paq
93
- } , [ ] , ( res ) => {
94
- console . log ( '_paq' , res )
95
- } )
96
- . waitForElementNotVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
97
- . pause ( 2000 )
98
- . waitForElementNotPresent ( '*[data-id="beginnerbtn"]' , 10000 )
99
- . clickLaunchIcon ( 'settings' )
100
- . waitForElementNotPresent ( '[id="settingsMatomoAnalytics"]:checked' )
101
- . execute ( function ( ) {
102
- return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-analytics' ] == false
103
- } , [ ] , ( res ) => {
104
- console . log ( 'res' , res )
105
- browser . assert . ok ( ( res as any ) . value , 'matomo analytics is disabled' )
71
+ browser . assert . ok ( ( res as any ) . value , 'matomo perf analytics is enabled' )
106
72
} )
107
73
} ,
108
- 'blur matomo #group2' : function ( browser : NightwatchBrowser ) {
74
+ 'disable matomo perf analytics on manage preferences #group2' : function ( browser : NightwatchBrowser ) {
109
75
browser . perform ( ( done ) => {
110
76
browser . execute ( function ( ) {
111
77
localStorage . removeItem ( 'config-v0.8:.remix.config' )
112
78
localStorage . setItem ( 'showMatomo' , 'true' )
113
- localStorage . removeItem ( 'matomo-analytics-consent' )
79
+ localStorage . removeItem ( 'matomo-perf- analytics-consent' )
114
80
} , [ ] )
115
81
. refreshPage ( )
116
82
. perform ( done ( ) )
@@ -125,17 +91,21 @@ module.exports = {
125
91
abortOnFailure : true
126
92
} )
127
93
. waitForElementVisible ( '*[data-id="matomoModal-modal-close"]' )
128
- . click ( '[data-id="matomoModal-modal-close"]' )
129
- . waitForElementNotVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
94
+ . click ( '[data-id="matomoModal-modal-close"]' ) // click on Manage Preferences
95
+ . waitForElementNotVisible ( '*[data-id="managePreferencesModalModalDialogModalBody-react"]' )
96
+ . waitForElementNotVisible ( '*[data-id="matomoPerfAnalyticsToggleSwitch"]' )
97
+ . click ( '*[data-id="matomoPerfAnalyticsToggleSwitch"]' ) // disable matomo perf analytics3
98
+ . click ( '[managePreferencesModal-modal-footer-ok-react"]' ) // click on Save Preferences
130
99
. pause ( 2000 )
131
- . waitForElementNotPresent ( '*[data-id="beginnerbtn"]' , 10000 )
100
+ . waitForElementPresent ( '*[data-id="beginnerbtn"]' , 10000 )
101
+ . click ( '[data-id="beginnerbtn"]' )
132
102
. clickLaunchIcon ( 'settings' )
133
- . waitForElementNotPresent ( '[id="settingsMatomoAnalytics "]:checked' )
103
+ . waitForElementNotPresent ( '[id="settingsMatomoPerfAnalytics "]:checked' )
134
104
. execute ( function ( ) {
135
- return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-analytics' ] == undefined
105
+ return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-perf- analytics' ] == false
136
106
} , [ ] , ( res ) => {
137
107
console . log ( 'res' , res )
138
- browser . assert . ok ( ( res as any ) . value , 'matomo analytics is undefined ' )
108
+ browser . assert . ok ( ( res as any ) . value , 'matomo perf analytics is disabled ' )
139
109
} )
140
110
} ,
141
111
'matomo should reappear #group2' : function ( browser : NightwatchBrowser ) {
@@ -181,66 +151,14 @@ module.exports = {
181
151
. waitForElementVisible ( '*[id="remixTourSkipbtn"]' )
182
152
. click ( '*[id="remixTourSkipbtn"]' )
183
153
. clickLaunchIcon ( 'settings' )
184
- . waitForElementPresent ( '[id="settingsMatomoAnalytics "]:checked' )
154
+ . waitForElementPresent ( '[id="settingsMatomoPerfAnalytics "]:checked' )
185
155
. execute ( function ( ) {
186
- return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-analytics' ] == true
156
+ return JSON . parse ( window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ) [ 'settings/matomo-perf- analytics' ] == true
187
157
} , [ ] , ( res ) => {
188
158
console . log ( 'res' , res )
189
159
browser . assert . ok ( ( res as any ) . value , 'matomo analytics is enabled' )
190
160
} )
191
161
} ,
192
- 'decline Matomo and check timestamp #group3' : function ( browser : NightwatchBrowser ) {
193
- browser . perform ( ( done ) => {
194
- browser . execute ( function ( ) {
195
- localStorage . removeItem ( 'config-v0.8:.remix.config' )
196
- localStorage . setItem ( 'showMatomo' , 'true' )
197
- localStorage . removeItem ( 'matomo-analytics-consent' )
198
- } , [ ] )
199
- . refreshPage ( )
200
- . perform ( done ( ) )
201
- } )
202
- . waitForElementPresent ( {
203
- selector : `//*[@data-id='compilerloaded']` ,
204
- locateStrategy : 'xpath' ,
205
- timeout : 120000
206
- } )
207
- // output the contents of the storage
208
- . execute ( function ( ) {
209
- return {
210
- consent : window . localStorage . getItem ( 'matomo-analytics-consent' ) ,
211
- config : window . localStorage . getItem ( 'config-v0.8:.remix.config' ) ,
212
- showMatomo : window . localStorage . getItem ( 'showMatomo' )
213
- }
214
- } , [ ] , ( res ) => {
215
- console . log ( 'res' , res )
216
- } )
217
- . waitForElementVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
218
- . click ( '[data-id="matomoModal-modal-footer-cancel-react"]' ) // cancel
219
- . waitForElementNotVisible ( '*[data-id="matomoModalModalDialogModalBody-react"]' )
220
- . pause ( 2000 )
221
- . execute ( function ( ) {
222
-
223
- const timestamp = window . localStorage . getItem ( 'matomo-analytics-consent' ) ;
224
- if ( timestamp ) {
225
-
226
- const consentDate = new Date ( Number ( timestamp ) ) ;
227
- // validate it is actually a date
228
- if ( isNaN ( consentDate . getTime ( ) ) ) {
229
- return false ;
230
- }
231
- const now = new Date ( ) ;
232
- console . log ( 'timestamp' , timestamp , consentDate , now . getTime ( ) )
233
- const diffInMinutes = ( now . getTime ( ) - consentDate . getTime ( ) ) / ( 1000 * 60 ) ;
234
- console . log ( 'diffInMinutes' , diffInMinutes )
235
- return diffInMinutes < 2 ;
236
- }
237
- return false ;
238
-
239
- } , [ ] , ( res ) => {
240
- console . log ( 'res' , res )
241
- browser . assert . ok ( ( res as any ) . value , 'matomo analytics consent timestamp is set' )
242
- } )
243
- } ,
244
162
'check old timestamp and reappear Matomo #group3' : function ( browser : NightwatchBrowser ) {
245
163
browser . perform ( ( done ) => {
246
164
browser . execute ( function ( ) {
0 commit comments