Skip to content

Commit a1875b4

Browse files
authored
Merge pull request #152 from JackieBinya/ft-copyright-unit
Adds unit and e2e tests for CopyrightWaiverStep Component
2 parents 36a86dd + c384f38 commit a1875b4

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
'@tags': ['cws'],
3+
'Check if CopyrightWaiver is rendered correctly'(browser) {
4+
browser
5+
.init()
6+
.assert.elementPresent('.control-label > span')
7+
.click('.control-label > span')
8+
.assert.not.cssClassPresent('.pagination-next', 'disabled')
9+
.click('.pagination-next')
10+
.assert.elementPresent('.select > select')
11+
.click('.select > select')
12+
.click('option[value="CC0 1.0"]')
13+
.assert.not.cssClassPresent('.pagination-next', 'disabled')
14+
.click('.pagination-next')
15+
.assert.elementPresent('.control-label')
16+
.assert.elementPresent('.waiver-textarea')
17+
.assert.elementPresent('label:nth-child(1)')
18+
.assert.elementPresent('label:nth-child(3)')
19+
},
20+
21+
'Check if user can check and uncheck checkboxes'(browser) {
22+
browser
23+
.click('label:nth-child(1)>span.control-label')
24+
.click('label:nth-child(3)>span.control-label')
25+
.assert.not.cssClassPresent('.pagination-next', 'disabled', 'Next Button visible when user checks agreed and confirmed')
26+
.click('label:nth-child(1)>span.control-label')
27+
.assert.cssClassPresent('.pagination-next', 'disabled', 'Next button disabled when user unchecks agreed')
28+
.click('label:nth-child(1)>span.control-label')
29+
.assert.not.cssClassPresent('.pagination-next', 'disabled', 'Next Button visible when user re-checks agreed')
30+
.click('label:nth-child(3)>span.control-label')
31+
.assert.cssClassPresent('.pagination-next', 'disabled', 'Next button disabled when user unchecks confirmed')
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { createLocalVue, mount } from '@vue/test-utils'
2+
import Buefy from 'buefy'
3+
import Vuex from 'vuex'
4+
import CopyrightWaiverStep from '@/components/CopyrightWaiverStep'
5+
6+
const localVue = createLocalVue()
7+
8+
localVue.use(Vuex)
9+
localVue.use(Buefy)
10+
11+
describe('CopyrightWaiver Step: Check conditional rendering of markup', () => {
12+
let wrapper
13+
14+
beforeEach(() => {
15+
wrapper = mount(CopyrightWaiverStep, {
16+
localVue,
17+
data() {
18+
return {
19+
agreed: false,
20+
confirmed: false
21+
}
22+
},
23+
mocks: {
24+
$t: key => key
25+
}
26+
})
27+
})
28+
29+
afterEach(() => {
30+
wrapper.destroy()
31+
})
32+
33+
it('Component not mounted if status is inactive', () => {
34+
wrapper.setProps({
35+
selected: undefined,
36+
status: 'inactive',
37+
stepId: 6,
38+
stepName: 'CW'
39+
})
40+
41+
expect(wrapper.find('.step-description').exists()).toBeFalsy()
42+
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
43+
})
44+
45+
it('Step Description block mounted if status is previous', () => {
46+
wrapper.setProps({ status: 'previous' })
47+
48+
expect(wrapper.find('.step-description').exists()).toBeTruthy()
49+
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
50+
})
51+
52+
it('Step Actions block mounted if status is current', () => {
53+
wrapper.setProps({ status: 'current' })
54+
55+
expect(wrapper.find('.step-description').exists()).toBeFalsy()
56+
expect(wrapper.find('.step-actions').exists()).toBeTruthy()
57+
expect(wrapper.vm.copyrightWaiverAgreed).toBe(false)
58+
})
59+
})
60+
61+
describe('Test the functionality of Computed properties', () => {
62+
let wrapper
63+
64+
beforeEach(() => {
65+
wrapper = mount(CopyrightWaiverStep, {
66+
localVue,
67+
data() {
68+
return {
69+
agreed: false,
70+
confirmed: false
71+
}
72+
},
73+
propsData: {
74+
selected: true,
75+
status: 'current',
76+
stepId: 6,
77+
stepName: 'CW'
78+
},
79+
mocks: {
80+
$t: key => key
81+
}
82+
})
83+
})
84+
85+
afterEach(() => {
86+
wrapper.destroy()
87+
})
88+
89+
it('User checks confirmed then checks agreed', () => {
90+
const checkbox1 = wrapper.findAll('input[type="checkbox"]').at(1)
91+
checkbox1.setChecked()
92+
93+
const checkbox = wrapper.findAll('input[type="checkbox"]').at(0)
94+
checkbox.setChecked()
95+
96+
expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, true])
97+
expect(wrapper.vm.copyrightWaiverAgreed).toBe(true)
98+
})
99+
100+
it('User checks agreed and then checks confirmed', () => {
101+
const checkbox = wrapper.findAll('input[type="checkbox"]').at(0)
102+
checkbox.setChecked()
103+
104+
const checkbox1 = wrapper.findAll('input[type="checkbox"]').at(1)
105+
checkbox1.setChecked()
106+
107+
expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, true])
108+
expect(wrapper.vm.copyrightWaiverConfirmed).toBe(true)
109+
})
110+
111+
it('User unchecks agreed', () => {
112+
const checkbox = wrapper.findAll('input[type="checkbox"]').at(0)
113+
checkbox.setChecked()
114+
checkbox.setChecked(false)
115+
116+
expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, undefined])
117+
expect(wrapper.vm.copyrightWaiverAgreed).toBe(false)
118+
})
119+
120+
it('User unchecks confirmed', () => {
121+
const checkbox = wrapper.findAll('input[type="checkbox"]').at(1)
122+
123+
checkbox.setChecked()
124+
checkbox.setChecked(false)
125+
126+
expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, undefined])
127+
expect(wrapper.vm.copyrightWaiverConfirmed).toBe(false)
128+
})
129+
})

0 commit comments

Comments
 (0)