Skip to content

Commit 64c2d98

Browse files
authored
Merge pull request #144 from hemanth-hk/master
Added unit and e2e tests for HelpSection.vue component
2 parents dd374af + 62b0083 commit 64c2d98

File tree

9 files changed

+1219
-980
lines changed

9 files changed

+1219
-980
lines changed

src/components/HelpSection.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,12 @@ export default {
279279
clickHandler(modalNumber) {
280280
this.modals[modalNumber].status = true
281281
if (process.env.NODE_ENV === 'production') {
282-
this.$ga.event({
282+
const Tracked = this.$ga.event({
283283
eventCategory: 'HelpSection',
284284
eventAction: 'clicked',
285285
eventLabel: this.modals[modalNumber].title
286286
})
287+
return Tracked
287288
}
288289
}
289290
}

tests/e2e/specs/AttributionDetailsStep.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module.exports = {
22
'@tags': ['att'],
3-
'AttributionDetailsStep'(browser){
3+
'AttributionDetailsStep'(browser) {
44
const knowLicenseSelector = '.b-radio'
55
const nextButton = '.pagination-next'
66
const select = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select'
77
const selectOpt = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select > option:nth-child(4)'
88
const stepTitle = '.step-title'
99
const attributionDetailsInstructions = '.attribution-details-instructions'
10-
const workAuthorLabel ='#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(1) > label'
10+
const workAuthorLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(1) > label'
1111
const workAuthorInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(1) > div > input'
1212
const urlCreatorProfileLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(2) > label'
1313
const urlCreatorProfileInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(2) > div > input'
@@ -18,12 +18,11 @@ module.exports = {
1818
const backBtn = '.pagination-previous'
1919
const paginationFinish = '.pagination-finish'
2020

21-
2221
browser
2322
.init()
2423
.click(knowLicenseSelector)
2524
.click(nextButton)
26-
.click(select, () =>{
25+
.click(select, () => {
2726
browser.click(selectOpt)
2827
})
2928
.click(nextButton)
@@ -40,4 +39,4 @@ module.exports = {
4039
.assert.visible(backBtn, 'Back button is visible')
4140
.assert.visible(paginationFinish, 'Pagination Finish Block is visible')
4241
}
43-
}
42+
}

tests/e2e/specs/HelpSection.js

+106-47
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,141 @@
11
module.exports = {
2-
3-
'Common license pop up redirects to https://creativecommons.org/licenses/': function(browser) {
2+
'Check if the Help Section is rendered in the DOM': function(browser) {
43
browser
54
.init()
6-
.assert.elementPresent('#cc_license_btn')
7-
.click('#cc_license_btn')
8-
.assert.elementPresent('#license_link')
9-
.click('#license_link')
10-
.assert.urlEquals('https://creativecommons.org/licenses/')
5+
.assert.elementPresent('.help-section')
6+
.assert.elementPresent('.h3a')
117
},
128

13-
'How do licenses work pop up redirects to https://creativecommons.org/licenses/': function(browser) {
9+
'Check if "What Are Creative Commons Licenses?" modal is working fine': function(browser) {
1410
browser
1511
.init()
16-
.assert.elementPresent('#license_work_btn')
17-
.click('#license_work_btn')
18-
.assert.elementPresent('#license_link_2')
19-
.click('#license_link_2')
20-
.assert.urlEquals('https://creativecommons.org/licenses/')
12+
.assert.elementPresent('ul > li:nth-child(1) > a')
13+
.click('ul > li:nth-child(1) > a')
14+
.assert.elementPresent('.modal-content')
15+
.assert.elementPresent('header[class="modal-card-head"]')
16+
.assert.elementPresent('.help-text')
17+
.assert.elementPresent('footer[class="modal-card-foot"]')
18+
.assert.elementPresent('#license_link')
19+
.getAttribute('#license_link', 'href', function(result) {
20+
this.assert.equal(result.value, 'https://creativecommons.org/licenses/')
21+
})
2122
},
2223

23-
'How do licenses work pop up redirects to https://wiki.creativecommons.org/wiki/CC_REL': function(browser) {
24+
'Check if "How do the Licenses Work?" modal is working fine': function(browser) {
2425
browser
2526
.init()
26-
.assert.elementPresent('#license_work_btn')
27-
.click('#license_work_btn')
27+
.assert.elementPresent('ul > li:nth-child(2) > a')
28+
.click('ul > li:nth-child(2) > a')
29+
.assert.elementPresent('.modal-content')
30+
.assert.elementPresent('header[class="modal-card-head"]')
31+
.assert.elementPresent('.help-text')
32+
.assert.elementPresent('footer[class="modal-card-foot"]')
2833
.assert.elementPresent('#cc_rights_link')
29-
.click('#cc_rights_link')
30-
.assert.urlEquals('https://wiki.creativecommons.org/wiki/CC_REL')
34+
.getAttribute('#cc_rights_link', 'href', function(result) {
35+
this.assert.equal(result.value, 'https://wiki.creativecommons.org/Ccrel')
36+
})
37+
.assert.elementPresent('#license_link_2')
38+
.getAttribute('#license_link_2', 'href', function(result) {
39+
this.assert.equal(result.value, 'https://creativecommons.org/licenses/')
40+
})
3141
},
32-
33-
'Public domain pop up redirects to https://creativecommons.org/publicdomain/': function(browser) {
42+
'Check if "What do the Icons Mean?" modal is working fine': function(browser) {
3443
browser
3544
.init()
36-
.assert.elementPresent('#public_domain_btn')
37-
.click('#public_domain_btn')
45+
.assert.elementPresent('ul > li:nth-child(3) > a')
46+
.click('ul > li:nth-child(3) > a')
47+
.assert.elementPresent('.modal-content')
48+
.assert.elementPresent('header[class="modal-card-head"]')
49+
.assert.elementPresent('.modal-card-body')
50+
.assert.elementPresent('.edu-icons-title-section img')
51+
.assert.elementPresent('footer[class="modal-card-foot"]')
52+
.assert.elementPresent('.help a')
53+
.getAttribute('.help a', 'href', function(result) {
54+
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/NonCommercial_interpretation')
55+
})
3856
.assert.elementPresent('#domain_link')
39-
.click('#domain_link')
40-
.assert.urlEquals('https://creativecommons.org/publicdomain/')
57+
.getAttribute('#domain_link', 'href', function(result) {
58+
this.assert.equal(result.value, 'https://creativecommons.org/publicdomain/')
59+
})
4160
},
4261

43-
'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors': function(browser) {
62+
'Check if "Considerations Before Licensing" modal is working fine': function(browser) {
4463
browser
4564
.init()
46-
.assert.elementPresent('#consideration_btn')
47-
.click('#consideration_btn')
65+
.assert.elementPresent('ul > li:nth-child(4) > a')
66+
.click('ul > li:nth-child(4) > a')
67+
.assert.elementPresent('.modal-content')
68+
.assert.elementPresent('header[class="modal-card-head"]')
69+
.assert.elementPresent('footer[class="modal-card-foot"]')
4870
.assert.elementPresent('#licensors_link')
49-
.click('#licensors_link')
50-
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors')
71+
.getAttribute('#licensors_link', 'href', function(result) {
72+
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors')
73+
})
74+
.assert.elementPresent('#licensees_link')
75+
.getAttribute('#licensees_link', 'href', function(result) {
76+
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees')
77+
})
78+
.assert.elementPresent('#wiki_link')
79+
.getAttribute('#wiki_link', 'href', function(result) {
80+
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Before_Licensing')
81+
})
5182
},
5283

53-
'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees': function(browser) {
84+
'Check if "How do I Formally License my Work?" modal is working fine': function(browser) {
5485
browser
5586
.init()
56-
.assert.elementPresent('#consideration_btn')
57-
.click('#consideration_btn')
58-
.assert.elementPresent('#licensees_link')
59-
.click('#licensees_link')
60-
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees')
87+
.assert.elementPresent('ul > li:nth-child(5) > a')
88+
.click('ul > li:nth-child(5) > a')
89+
.assert.elementPresent('.modal-content')
90+
.assert.elementPresent('header[class="modal-card-head"]')
91+
.assert.elementPresent('.modal-card-body')
92+
.assert.elementPresent('article')
6193
},
6294

63-
'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees': function(browser) {
95+
'Check if "The Six Creative Commons Licenses" modal is working fine': function(browser) {
6496
browser
6597
.init()
66-
.assert.elementPresent('#consideration_btn')
67-
.click('#consideration_btn')
68-
.assert.elementPresent('#wiki_link')
69-
.click('#wiki_link')
70-
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees')
98+
.assert.elementPresent('ul > li:nth-child(6) > a')
99+
.click('ul > li:nth-child(6) > a')
100+
.assert.elementPresent('.modal-content')
101+
.assert.elementPresent('header[class="modal-card-head"]')
102+
.assert.elementPresent('.modal-card-body')
103+
.assert.elementPresent('div[class="column"] img')
104+
.assert.elementPresent('footer[class="modal-card-foot"]')
105+
.assert.elementPresent('.modal-card-foot p a')
106+
.getAttribute('.modal-card-foot p a', 'href', function(result) {
107+
this.assert.equal(result.value, 'https://creativecommons.org/share-your-work/licensing-types-examples/')
108+
})
109+
},
110+
111+
'Check if "How are Licenses Communicated?" modal is working fine': function(browser) {
112+
browser
113+
.init()
114+
.assert.elementPresent('ul > li:nth-child(7) > a')
115+
.click('ul > li:nth-child(7) > a')
116+
.assert.elementPresent('.modal-content')
117+
.assert.elementPresent('header[class="modal-card-head"]')
118+
.assert.elementPresent('.modal-card-body')
119+
.assert.elementPresent('.help-section__table')
120+
.assert.elementPresent('.photo-license-icons img')
71121
},
72122

73-
'License types pop up redirects to https://creativecommons.org/share-your-work/licensing-types-examples/': function(browser) {
123+
'Check if "What is a Free Culture License?" modal is working fine': function(browser) {
74124
browser
75125
.init()
76-
.assert.elementPresent('#license_description_btn')
77-
.click('#license_description_btn')
78-
.assert.elementPresent('#licensing_examples_link')
79-
.click('#licensing_examples_link')
80-
.assert.urlEquals('https://creativecommons.org/share-your-work/licensing-examples/')
126+
.assert.elementPresent('ul > li:nth-child(8) > a')
127+
.click('ul > li:nth-child(8) > a')
128+
.assert.elementPresent('.modal-content')
129+
.assert.elementPresent('header[class="modal-card-head"]')
130+
.assert.elementPresent('.modal-card-body')
131+
.assert.elementPresent('footer[class="modal-card-foot"]')
132+
.assert.elementPresent('p[class="help-text"] a')
133+
.getAttribute('p[class="help-text"] a', 'href', function(result) {
134+
this.assert.equal(result.value, 'https://freedomdefined.org/Definition')
135+
})
136+
.assert.elementPresent('footer[class="modal-card-foot"] p a')
137+
.getAttribute('footer[class="modal-card-foot"] p a', 'href', function(result) {
138+
this.assert.equal(result.value, 'https://creativecommons.org/share-your-work/public-domain/freeworks')
139+
})
81140
}
82141
}

tests/unit/FirstStep.spec.js

-79
This file was deleted.

0 commit comments

Comments
 (0)