Skip to content

Commit 5779d8d

Browse files
committed
fix e2e
1 parent 23d8947 commit 5779d8d

File tree

2 files changed

+21
-103
lines changed

2 files changed

+21
-103
lines changed

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

Lines changed: 19 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
before: function (browser: NightwatchBrowser, done: VoidFunction) {
1414
init(browser, done, 'http://127.0.0.1:8080', false)
1515
},
16-
'confirm Matomo #group1': function (browser: NightwatchBrowser) {
16+
'accept all including Matomo anon and perf #group1': function (browser: NightwatchBrowser) {
1717
browser.perform((done) => {
1818
browser
1919
.execute(function () {
@@ -35,7 +35,7 @@ module.exports = {
3535
})
3636
.waitForElementVisible('*[data-id="matomoModalModalDialogModalBody-react"]')
3737
.pause(1000)
38-
.click('[data-id="matomoModal-modal-footer-ok-react"]') // submitted
38+
.click('[data-id="matomoModal-modal-footer-ok-react"]') // Accepted
3939
.execute(function () {
4040
return (window as any)._paq
4141
}, [], (res) => {
@@ -58,59 +58,25 @@ module.exports = {
5858
})
5959
.waitForElementNotPresent('*[data-id="matomoModalModalDialogModalBody-react"]')
6060
.clickLaunchIcon('settings')
61-
.verify.elementPresent('[id="settingsMatomoAnalytics"]:checked')
61+
.verify.elementPresent('[id="settingsMatomoPerfAnalytics"]:checked')
6262
.execute(function () {
6363
return JSON.parse(window.localStorage.getItem('config-v0.8:.remix.config'))['settings/matomo-analytics'] == true
6464
}, [], (res) => {
6565
console.log('res', res)
6666
browser.assert.ok((res as any).value, 'matomo analytics is enabled')
6767
})
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-
})
8468
.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
8670
}, [], (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')
10672
})
10773
},
108-
'blur matomo #group2': function (browser: NightwatchBrowser) {
74+
'disable matomo perf analytics on manage preferences #group2': function (browser: NightwatchBrowser) {
10975
browser.perform((done) => {
11076
browser.execute(function () {
11177
localStorage.removeItem('config-v0.8:.remix.config')
11278
localStorage.setItem('showMatomo', 'true')
113-
localStorage.removeItem('matomo-analytics-consent')
79+
localStorage.removeItem('matomo-perf-analytics-consent')
11480
}, [])
11581
.refreshPage()
11682
.perform(done())
@@ -125,17 +91,21 @@ module.exports = {
12591
abortOnFailure: true
12692
})
12793
.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
13099
.pause(2000)
131-
.waitForElementNotPresent('*[data-id="beginnerbtn"]', 10000)
100+
.waitForElementPresent('*[data-id="beginnerbtn"]', 10000)
101+
.click('[data-id="beginnerbtn"]')
132102
.clickLaunchIcon('settings')
133-
.waitForElementNotPresent('[id="settingsMatomoAnalytics"]:checked')
103+
.waitForElementNotPresent('[id="settingsMatomoPerfAnalytics"]:checked')
134104
.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
136106
}, [], (res) => {
137107
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')
139109
})
140110
},
141111
'matomo should reappear #group2': function (browser: NightwatchBrowser) {
@@ -181,66 +151,14 @@ module.exports = {
181151
.waitForElementVisible('*[id="remixTourSkipbtn"]')
182152
.click('*[id="remixTourSkipbtn"]')
183153
.clickLaunchIcon('settings')
184-
.waitForElementPresent('[id="settingsMatomoAnalytics"]:checked')
154+
.waitForElementPresent('[id="settingsMatomoPerfAnalytics"]:checked')
185155
.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
187157
}, [], (res) => {
188158
console.log('res', res)
189159
browser.assert.ok((res as any).value, 'matomo analytics is enabled')
190160
})
191161
},
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-
},
244162
'check old timestamp and reappear Matomo #group3': function (browser: NightwatchBrowser) {
245163
browser.perform((done) => {
246164
browser.execute(function () {

libs/remix-ui/settings/src/lib/remix-ui-settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
314314
</label>
315315
</div>
316316
<div className="custom-control custom-checkbox mb-1">
317-
<input onChange={onchangeMatomoAnalytics} id="settingsMatomoAnalytics" type="checkbox" className="custom-control-input" checked={isMatomoChecked} />
318-
<label data-id="label-matomo-settings" className={`form-check-label custom-control-label align-middle ${getTextClass('settings/matomo-perf-analytics')}`} htmlFor="settingsMatomoAnalytics">
317+
<input onChange={onchangeMatomoAnalytics} id="settingsMatomoPerfAnalytics" type="checkbox" className="custom-control-input" checked={isMatomoChecked} />
318+
<label data-id="label-matomo-settings" className={`form-check-label custom-control-label align-middle ${getTextClass('settings/matomo-perf-analytics')}`} htmlFor="settingsMatomoPerfAnalytics">
319319
<span>
320320
<FormattedMessage id="settings.matomoPerfAnalytics" />
321321
</span>

0 commit comments

Comments
 (0)