Skip to content

Commit

Permalink
Merge pull request #144 from hemanth-hk/master
Browse files Browse the repository at this point in the history
Added unit and e2e tests for HelpSection.vue component
  • Loading branch information
obulat authored Apr 3, 2020
2 parents dd374af + 62b0083 commit 64c2d98
Show file tree
Hide file tree
Showing 9 changed files with 1,219 additions and 980 deletions.
3 changes: 2 additions & 1 deletion src/components/HelpSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,12 @@ export default {
clickHandler(modalNumber) {
this.modals[modalNumber].status = true
if (process.env.NODE_ENV === 'production') {
this.$ga.event({
const Tracked = this.$ga.event({
eventCategory: 'HelpSection',
eventAction: 'clicked',
eventLabel: this.modals[modalNumber].title
})
return Tracked
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/specs/AttributionDetailsStep.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = {
'@tags': ['att'],
'AttributionDetailsStep'(browser){
'AttributionDetailsStep'(browser) {
const knowLicenseSelector = '.b-radio'
const nextButton = '.pagination-next'
const select = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select'
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)'
const stepTitle = '.step-title'
const attributionDetailsInstructions = '.attribution-details-instructions'
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'
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'
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'
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'
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'
Expand All @@ -18,12 +18,11 @@ module.exports = {
const backBtn = '.pagination-previous'
const paginationFinish = '.pagination-finish'


browser
.init()
.click(knowLicenseSelector)
.click(nextButton)
.click(select, () =>{
.click(select, () => {
browser.click(selectOpt)
})
.click(nextButton)
Expand All @@ -40,4 +39,4 @@ module.exports = {
.assert.visible(backBtn, 'Back button is visible')
.assert.visible(paginationFinish, 'Pagination Finish Block is visible')
}
}
}
153 changes: 106 additions & 47 deletions tests/e2e/specs/HelpSection.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,141 @@
module.exports = {

'Common license pop up redirects to https://creativecommons.org/licenses/': function(browser) {
'Check if the Help Section is rendered in the DOM': function(browser) {
browser
.init()
.assert.elementPresent('#cc_license_btn')
.click('#cc_license_btn')
.assert.elementPresent('#license_link')
.click('#license_link')
.assert.urlEquals('https://creativecommons.org/licenses/')
.assert.elementPresent('.help-section')
.assert.elementPresent('.h3a')
},

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

'How do licenses work pop up redirects to https://wiki.creativecommons.org/wiki/CC_REL': function(browser) {
'Check if "How do the Licenses Work?" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#license_work_btn')
.click('#license_work_btn')
.assert.elementPresent('ul > li:nth-child(2) > a')
.click('ul > li:nth-child(2) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.help-text')
.assert.elementPresent('footer[class="modal-card-foot"]')
.assert.elementPresent('#cc_rights_link')
.click('#cc_rights_link')
.assert.urlEquals('https://wiki.creativecommons.org/wiki/CC_REL')
.getAttribute('#cc_rights_link', 'href', function(result) {
this.assert.equal(result.value, 'https://wiki.creativecommons.org/Ccrel')
})
.assert.elementPresent('#license_link_2')
.getAttribute('#license_link_2', 'href', function(result) {
this.assert.equal(result.value, 'https://creativecommons.org/licenses/')
})
},

'Public domain pop up redirects to https://creativecommons.org/publicdomain/': function(browser) {
'Check if "What do the Icons Mean?" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#public_domain_btn')
.click('#public_domain_btn')
.assert.elementPresent('ul > li:nth-child(3) > a')
.click('ul > li:nth-child(3) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.modal-card-body')
.assert.elementPresent('.edu-icons-title-section img')
.assert.elementPresent('footer[class="modal-card-foot"]')
.assert.elementPresent('.help a')
.getAttribute('.help a', 'href', function(result) {
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/NonCommercial_interpretation')
})
.assert.elementPresent('#domain_link')
.click('#domain_link')
.assert.urlEquals('https://creativecommons.org/publicdomain/')
.getAttribute('#domain_link', 'href', function(result) {
this.assert.equal(result.value, 'https://creativecommons.org/publicdomain/')
})
},

'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors': function(browser) {
'Check if "Considerations Before Licensing" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#consideration_btn')
.click('#consideration_btn')
.assert.elementPresent('ul > li:nth-child(4) > a')
.click('ul > li:nth-child(4) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('footer[class="modal-card-foot"]')
.assert.elementPresent('#licensors_link')
.click('#licensors_link')
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors')
.getAttribute('#licensors_link', 'href', function(result) {
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensors')
})
.assert.elementPresent('#licensees_link')
.getAttribute('#licensees_link', 'href', function(result) {
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees')
})
.assert.elementPresent('#wiki_link')
.getAttribute('#wiki_link', 'href', function(result) {
this.assert.equal(result.value, 'https://wiki.creativecommons.org/wiki/Before_Licensing')
})
},

'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees': function(browser) {
'Check if "How do I Formally License my Work?" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#consideration_btn')
.click('#consideration_btn')
.assert.elementPresent('#licensees_link')
.click('#licensees_link')
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees#Considerations_for_licensees')
.assert.elementPresent('ul > li:nth-child(5) > a')
.click('ul > li:nth-child(5) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.modal-card-body')
.assert.elementPresent('article')
},

'License consideration pop up redirects to https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees': function(browser) {
'Check if "The Six Creative Commons Licenses" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#consideration_btn')
.click('#consideration_btn')
.assert.elementPresent('#wiki_link')
.click('#wiki_link')
.assert.urlEquals('https://wiki.creativecommons.org/wiki/Considerations_for_licensors_and_licensees')
.assert.elementPresent('ul > li:nth-child(6) > a')
.click('ul > li:nth-child(6) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.modal-card-body')
.assert.elementPresent('div[class="column"] img')
.assert.elementPresent('footer[class="modal-card-foot"]')
.assert.elementPresent('.modal-card-foot p a')
.getAttribute('.modal-card-foot p a', 'href', function(result) {
this.assert.equal(result.value, 'https://creativecommons.org/share-your-work/licensing-types-examples/')
})
},

'Check if "How are Licenses Communicated?" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('ul > li:nth-child(7) > a')
.click('ul > li:nth-child(7) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.modal-card-body')
.assert.elementPresent('.help-section__table')
.assert.elementPresent('.photo-license-icons img')
},

'License types pop up redirects to https://creativecommons.org/share-your-work/licensing-types-examples/': function(browser) {
'Check if "What is a Free Culture License?" modal is working fine': function(browser) {
browser
.init()
.assert.elementPresent('#license_description_btn')
.click('#license_description_btn')
.assert.elementPresent('#licensing_examples_link')
.click('#licensing_examples_link')
.assert.urlEquals('https://creativecommons.org/share-your-work/licensing-examples/')
.assert.elementPresent('ul > li:nth-child(8) > a')
.click('ul > li:nth-child(8) > a')
.assert.elementPresent('.modal-content')
.assert.elementPresent('header[class="modal-card-head"]')
.assert.elementPresent('.modal-card-body')
.assert.elementPresent('footer[class="modal-card-foot"]')
.assert.elementPresent('p[class="help-text"] a')
.getAttribute('p[class="help-text"] a', 'href', function(result) {
this.assert.equal(result.value, 'https://freedomdefined.org/Definition')
})
.assert.elementPresent('footer[class="modal-card-foot"] p a')
.getAttribute('footer[class="modal-card-foot"] p a', 'href', function(result) {
this.assert.equal(result.value, 'https://creativecommons.org/share-your-work/public-domain/freeworks')
})
}
}
79 changes: 0 additions & 79 deletions tests/unit/FirstStep.spec.js

This file was deleted.

Loading

0 comments on commit 64c2d98

Please sign in to comment.