Skip to content

Commit 5de6086

Browse files
committed
fix e2e for perf-analytics
1 parent 5779d8d commit 5de6086

File tree

2 files changed

+27
-60
lines changed

2 files changed

+27
-60
lines changed

apps/remix-ide-e2e/src/tests/matomo.test.ts

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ module.exports = {
9090
selector: '*[data-id="matomoModalModalDialogModalBody-react"]',
9191
abortOnFailure: true
9292
})
93-
.waitForElementVisible('*[data-id="matomoModal-modal-close"]')
94-
.click('[data-id="matomoModal-modal-close"]') // click on Manage Preferences
95-
.waitForElementNotVisible('*[data-id="managePreferencesModalModalDialogModalBody-react"]')
96-
.waitForElementNotVisible('*[data-id="matomoPerfAnalyticsToggleSwitch"]')
93+
.waitForElementVisible('*[data-id="matomoModal-modal-footer-cancel-react"]')
94+
.click('[data-id="matomoModal-modal-footer-cancel-react"]') // click on Manage Preferences
95+
.waitForElementVisible('*[data-id="managePreferencesModalModalDialogModalBody-react"]')
96+
.waitForElementVisible('*[data-id="matomoPerfAnalyticsToggleSwitch"]')
9797
.click('*[data-id="matomoPerfAnalyticsToggleSwitch"]') // disable matomo perf analytics3
98-
.click('[managePreferencesModal-modal-footer-ok-react"]') // click on Save Preferences
98+
.click('[data-id="managePreferencesModal-modal-footer-ok-react"]') // click on Save Preferences
9999
.pause(2000)
100100
.waitForElementPresent('*[data-id="beginnerbtn"]', 10000)
101101
.click('[data-id="beginnerbtn"]')
@@ -108,25 +108,8 @@ module.exports = {
108108
browser.assert.ok((res as any).value, 'matomo perf analytics is disabled')
109109
})
110110
},
111-
'matomo should reappear #group2': function (browser: NightwatchBrowser) {
112-
browser
113-
.refreshPage()
114-
.waitForElementPresent({
115-
selector: `//*[@data-id='compilerloaded']`,
116-
locateStrategy: 'xpath',
117-
timeout: 120000
118-
})
119-
.waitForElementVisible({
120-
selector: '*[data-id="matomoModalModalDialogModalBody-react"]',
121-
abortOnFailure: true
122-
})
123-
.waitForElementVisible('*[data-id="matomoModal-modal-close"]')
124-
.click('[data-id="matomoModal-modal-close"]')
125-
.waitForElementNotVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
126-
},
127111
'change settings #group2': function (browser: NightwatchBrowser) {
128112
browser
129-
.clickLaunchIcon('settings')
130113
.waitForElementVisible('*[data-id="label-matomo-settings"]')
131114
.pause(1000)
132115
.click('*[data-id="label-matomo-settings"]')
@@ -137,34 +120,18 @@ module.exports = {
137120
timeout: 120000
138121
})
139122
.waitForElementNotPresent('*[data-id="matomoModalModalDialogModalBody-react"]')
140-
},
141-
'should get enter dialog again #group2': function (browser: NightwatchBrowser) {
142-
browser
143-
.waitForElementVisible('*[data-id="beginnerbtn"]', 10000)
144-
.pause(1000)
145-
.click('[data-id="beginnerbtn"]')
146-
.waitForElementNotPresent('*[data-id="beginnerbtn"]')
147-
.waitForElementVisible({
148-
selector: `//*[contains(text(), 'Welcome to Remix IDE')]`,
149-
locateStrategy: 'xpath'
150-
})
151-
.waitForElementVisible('*[id="remixTourSkipbtn"]')
152-
.click('*[id="remixTourSkipbtn"]')
153123
.clickLaunchIcon('settings')
154-
.waitForElementPresent('[id="settingsMatomoPerfAnalytics"]:checked')
155-
.execute(function () {
156-
return JSON.parse(window.localStorage.getItem('config-v0.8:.remix.config'))['settings/matomo-perf-analytics'] == true
157-
}, [], (res) => {
158-
console.log('res', res)
159-
browser.assert.ok((res as any).value, 'matomo analytics is enabled')
160-
})
124+
.pause(1000)
125+
.click('*[data-id="label-matomo-settings"]') // disable again
126+
.pause(1000)
127+
.refreshPage()
161128
},
162-
'check old timestamp and reappear Matomo #group3': function (browser: NightwatchBrowser) {
129+
'check old timestamp and reappear Matomo #group2': function (browser: NightwatchBrowser) {
163130
browser.perform((done) => {
164131
browser.execute(function () {
165132
const oldTimestamp = new Date()
166133
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
167-
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
134+
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
168135
}, [])
169136
.refreshPage()
170137
.perform(done())
@@ -176,7 +143,7 @@ module.exports = {
176143
})
177144
.execute(function () {
178145

179-
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
146+
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
180147
if (timestamp) {
181148

182149
const consentDate = new Date(Number(timestamp));
@@ -195,26 +162,26 @@ module.exports = {
195162

196163
}, [], (res) => {
197164
console.log('res', res)
198-
browser.assert.ok((res as any).value, 'matomo analytics consent timestamp is set')
165+
browser.assert.ok((res as any).value, 'matomo performance analytics consent timestamp is set')
199166
})
200167
.waitForElementVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
201-
.click('[data-id="matomoModal-modal-footer-cancel-react"]') // cancel
168+
.click('[data-id="matomoModal-modal-footer-ok-react"]') // accept
202169
.waitForElementNotVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
203170
},
204171
'check recent timestamp and do not reappear Matomo #group3': function (browser: NightwatchBrowser) {
205172
browser.perform((done) => {
206173
browser.execute(function () {
207174
const recentTimestamp = new Date()
208175
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
209-
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
176+
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
210177
}, [])
211178
.refreshPage()
212179
.perform(done())
213180
})
214181
// check if timestamp is younger than 6 months
215182
.execute(function () {
216183

217-
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
184+
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
218185
if (timestamp) {
219186

220187
const consentDate = new Date(Number(timestamp));
@@ -248,7 +215,7 @@ module.exports = {
248215
browser.execute(function () {
249216
localStorage.removeItem('config-v0.8:.remix.config')
250217
localStorage.setItem('showMatomo', 'true')
251-
localStorage.removeItem('matomo-analytics-consent')
218+
localStorage.removeItem('matomo-perf-analytics-consent')
252219
}, [])
253220
.refreshPage()
254221
.perform(done())
@@ -264,7 +231,7 @@ module.exports = {
264231
.pause(2000)
265232
.execute(function () {
266233

267-
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
234+
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
268235
if (timestamp) {
269236

270237
const consentDate = new Date(Number(timestamp));
@@ -290,7 +257,7 @@ module.exports = {
290257
browser.execute(function () {
291258
const oldTimestamp = new Date()
292259
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
293-
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
260+
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
294261
}, [])
295262
.refreshPage()
296263
.perform(done())
@@ -308,7 +275,7 @@ module.exports = {
308275
browser.execute(function () {
309276
const recentTimestamp = new Date()
310277
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
311-
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
278+
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
312279
}, [])
313280
.refreshPage()
314281
.perform(done())
@@ -327,13 +294,13 @@ module.exports = {
327294
localStorage.removeItem('config-v0.8:.remix.config')
328295
const recentTimestamp = new Date()
329296
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
330-
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
297+
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
331298
}, [])
332299
.refreshPage()
333300
.perform(done())
334301
})
335302
.waitForElementVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
336-
.click('[data-id="matomoModal-modal-footer-cancel-react"]') // cancel
303+
.click('[data-id="matomoModal-modal-footer-ok-react"]') // accept
337304
.waitForElementNotVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
338305
},
339306
'when there is a old timestamp but no config the dialog should reappear #group3': function (browser: NightwatchBrowser) {
@@ -342,13 +309,13 @@ module.exports = {
342309
localStorage.removeItem('config-v0.8:.remix.config')
343310
const oldTimestamp = new Date()
344311
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
345-
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
312+
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
346313
}, [])
347314
.refreshPage()
348315
.perform(done())
349316
})
350317
.waitForElementVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
351-
.click('[data-id="matomoModal-modal-footer-cancel-react"]') // cancel
318+
.click('[data-id="matomoModal-modal-footer-ok-react"]') // accept
352319
.waitForElementNotVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
353320
},
354321
'verify Matomo events are tracked on app start #group4': function (browser: NightwatchBrowser) {

apps/remix-ide/src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ class AppComponent {
221221
}
222222

223223
_paq.push(['trackEvent', 'App', 'load']);
224-
this.matomoConfAlreadySet = Registry.getInstance().get('config').api.exists('settings/matomo-analytics')
225-
this.matomoCurrentSetting = Registry.getInstance().get('config').api.get('settings/matomo-analytics')
224+
this.matomoConfAlreadySet = Registry.getInstance().get('config').api.exists('settings/matomo-perf-analytics')
225+
this.matomoCurrentSetting = Registry.getInstance().get('config').api.get('settings/matomo-perf-analytics')
226226

227227
const electronTracking = (window as any).electronAPI ? await (window as any).electronAPI.canTrackMatomo() : false
228228

229-
const lastMatomoCheck = window.localStorage.getItem('matomo-analytics-consent')
229+
const lastMatomoCheck = window.localStorage.getItem('matomo-perf-analytics-consent')
230230
const sixMonthsAgo = new Date();
231231
sixMonthsAgo.setMonth(sixMonthsAgo.getMonth() - 6);
232232

0 commit comments

Comments
 (0)