Skip to content

Commit 788764b

Browse files
committed
Merge branch 'master' into stepper-test
2 parents 444905f + a1875b4 commit 788764b

19 files changed

+2016
-17
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/LicenseCode.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
<span v-if="!workTitle">{{ $t('license-use.richtext.workTitle') }}</span>
1818
<span
1919
v-else
20-
rel="dc:title"
20+
rel="dct:title"
2121
>
2222
{{ workTitle }}
2323
</span>
2424
</a>
2525
<span
2626
v-else-if="workTitle"
27-
rel="dc:title"
27+
rel="dct:title"
2828
>
2929
{{ workTitle }}
3030
</span>

src/components/LocaleChooser.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export default {
6161
width: 100%;
6262
}
6363
.locale-chooser-field .control .select select {
64-
padding-left:2.5em;
64+
padding-left: 2.5em;
65+
z-index: -1;
6566
}
6667
.locale-chooser-field .control .select::before {
6768
content: url("../assets/language.png");
6869
position: absolute;
69-
z-index: 1;
7070
left:10px;
7171
top:8px;
7272
}

src/utils/license-utilities.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function attrToShort(attr) {
2828
}
2929

3030
function attrToFull(attr) {
31+
if (attr.BY === undefined) { return undefined }
3132
if (!attr.BY) { return 'CC0 1.0 Universal' }
3233
let base = 'Attribution'
3334
if (attr.NC) { base += '-NonCommercial' }
@@ -143,7 +144,7 @@ function generateHTML(attributionDetails, shortLicenseName) {
143144
}
144145
}
145146
if (attributionDetails.workTitle) {
146-
const workTitleSpan = `<span rel="dc:title">${attributionDetails.workTitle}</span>`
147+
const workTitleSpan = `<span rel="dct:title">${attributionDetails.workTitle}</span>`
147148
if (attributionDetails.workUrl) {
148149
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" href="${attributionDetails.workUrl}">${workTitleSpan}</a>`
149150
} else {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
'@tags': ['att'],
3+
'AttributionDetailsStep'(browser) {
4+
const knowLicenseSelector = '.b-radio'
5+
const nextButton = '.pagination-next'
6+
const select = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select'
7+
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)'
8+
const stepTitle = '.step-title'
9+
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'
11+
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'
12+
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'
13+
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'
14+
const workUrlLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > label'
15+
const workUrlInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(4) > div > input'
16+
const workTitleLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > label'
17+
const workTitleInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > div > input'
18+
const backBtn = '.pagination-previous'
19+
const paginationFinish = '.pagination-finish'
20+
21+
browser
22+
.init()
23+
.click(knowLicenseSelector)
24+
.click(nextButton)
25+
.click(select, () => {
26+
browser.click(selectOpt)
27+
})
28+
.click(nextButton)
29+
.assert.visible(stepTitle, 'Title is visible')
30+
.assert.visible(attributionDetailsInstructions, 'Atrribution Details Instructions block is visible')
31+
.assert.visible(workAuthorLabel, 'Work Author Label is visible')
32+
.assert.visible(workAuthorInput, 'Work Author Input is visible')
33+
.assert.visible(urlCreatorProfileLabel, 'URL of Creator Profile Label is visible')
34+
.assert.visible(urlCreatorProfileInput, 'URL of Creator Profile Input is visible')
35+
.assert.visible(workUrlLabel, 'Work URL Label is visible')
36+
.assert.visible(workUrlInput, 'Work URL Input is visible')
37+
.assert.visible(workTitleLabel, 'Work Title Label is visible')
38+
.assert.visible(workTitleInput, 'Work Title Input is visible')
39+
.assert.visible(backBtn, 'Back button is visible')
40+
.assert.visible(paginationFinish, 'Pagination Finish Block is visible')
41+
}
42+
}
Lines changed: 33 additions & 0 deletions
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+
}

tests/e2e/specs/LicenseCode.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module.exports = {
2+
3+
'Check if the p-tag with the class license-text is present': function(browser) {
4+
browser
5+
.init()
6+
.assert.elementPresent('.control-label > span')
7+
.click('.control-label > span')
8+
.assert.elementPresent('.pagination-next')
9+
.click('.pagination-next')
10+
.assert.elementPresent('.select > select')
11+
.click('.select')
12+
.click('option[value="CC BY-SA 4.0"]')
13+
.assert.elementPresent('.pagination-next')
14+
.click('.pagination-next')
15+
.assert.elementPresent('p[class="license-text"]')
16+
},
17+
'Check if the links in the license code redirects properly': function(browser) {
18+
browser
19+
.setValue('input[placeholder="Jane Doe"]', 'Jane Doe')
20+
.setValue('input[placeholder="www.author.com"]', 'www.author.com')
21+
.setValue('input[placeholder="This work"]', 'This work')
22+
.setValue('input[placeholder="www.author.com/work.jpg"]', 'www.author.com/work.jpg')
23+
.assert.elementPresent('p[class="license-text"] a')
24+
.getAttribute('p > span > a:nth-child(1)', 'href', function(result) {
25+
this.assert.equal(result.value, 'http://localhost:8080/www.author.com/work.jpg')
26+
})
27+
.getAttribute('p > span > a:nth-child(2)', 'href', function(result) {
28+
this.assert.equal(result.value, 'http://localhost:8080/www.author.com')
29+
})
30+
.getAttribute('p > span > a:nth-child(4)', 'href', function(result) {
31+
this.assert.equal(result.value, 'https://creativecommons.org/licenses/by-sa/4.0/?ref=ccchooser')
32+
})
33+
},
34+
'Check if the text is displayed under the print attribution': function(browser) {
35+
browser
36+
.click('nav > ul > li:nth-child(2) > a')
37+
.assert.elementPresent('p[class="license-text"]')
38+
.assert.elementPresent('#attribution-text > p > span:nth-child(1)')
39+
.assert.elementPresent('#attribution-text > p > span:nth-child(2)')
40+
},
41+
42+
// Tests for the text under the "Plain Text"
43+
44+
'Check if the work in plain text is displayed': function(browser) {
45+
browser
46+
.click('nav > ul > li:nth-child(2) > a')
47+
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(1)').text.to.equal('This work')
48+
},
49+
'Check if the license in plain text is displayed': function(browser) {
50+
browser
51+
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(4)').text.to.equal('CC BY-SA 4.0')
52+
},
53+
'Check if the author-name in plain text is displayed': function(browser) {
54+
browser
55+
.expect.element('#attribution-text > p > span:nth-child(1) > span:nth-child(2) > span').text.to.equal('Jane Doe')
56+
},
57+
'Check if the license-details in plain text are displayed': function(browser) {
58+
browser
59+
.click('nav > ul > li:nth-child(2) > a')
60+
.assert.elementPresent('#attribution-text > p > span:nth-child(2)')
61+
.expect.element('#attribution-text > p > span:nth-child(2)').text.to.equal('. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0')
62+
}
63+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
3+
'Check if the main div tag with the class selected-license-card is present': function(browser) {
4+
browser
5+
.init()
6+
.assert.elementPresent('.control-label > span')
7+
.click('.control-label > span')
8+
.assert.elementPresent('.pagination-next')
9+
.click('.pagination-next')
10+
.assert.elementPresent('.select')
11+
.click('.select')
12+
.click('option[value="CC BY-SA 4.0"]')
13+
.assert.elementPresent('.selected-license-card')
14+
},
15+
'Check if the a tag with class license-name redirects correctly': function(browser) {
16+
browser
17+
.assert.elementPresent('a[class="license-name"]')
18+
.getAttribute('a[class="license-name"]', 'href', function(result) {
19+
this.assert.equal(result.value, 'https://creativecommons.org/licenses/by-sa/4.0/?ref=ccchooser')
20+
})
21+
}
22+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { createLocalVue, mount } from '@vue/test-utils'
2+
import Buefy from 'buefy'
3+
import Vuex from 'vuex'
4+
import AttributionDetailsStep from '@/components/AttributionDetailsStep'
5+
6+
const localVue = createLocalVue()
7+
8+
localVue.use(Vuex)
9+
localVue.use(Buefy)
10+
11+
describe('AttributionDetailsStep Component Rendering', () => {
12+
let wrapper
13+
14+
beforeEach(() => {
15+
wrapper = mount(AttributionDetailsStep, {
16+
localVue,
17+
mocks: {
18+
$t: key => key,
19+
$store: {
20+
state: {
21+
attributionDetails: {
22+
creatorName: '',
23+
creatorProfileUrl: '',
24+
workTitle: '',
25+
workUrl: ''
26+
}
27+
}
28+
}
29+
}
30+
31+
})
32+
})
33+
34+
afterEach(() => {
35+
wrapper.destroy()
36+
})
37+
38+
it('Component not mounted if status is previous', () => {
39+
wrapper.setProps({ status: 'previous' })
40+
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
41+
})
42+
43+
it('Component not mounted if status is inactive', () => {
44+
wrapper.setProps({ status: 'inactive' })
45+
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
46+
})
47+
48+
it('Component mounted if status is current', () => {
49+
wrapper.setProps({ status: 'current' })
50+
expect(wrapper.element).toMatchSnapshot()
51+
})
52+
})
53+
54+
describe('Store is updated when a user provides input', () => {
55+
let mutations, state, wrapper, store
56+
57+
beforeEach(() => {
58+
mutations = {
59+
setCreatorName: jest.fn(),
60+
setCreatorProfileUrl: jest.fn(),
61+
setWorkTitle: jest.fn(),
62+
setWorkUrl: jest.fn()
63+
}
64+
65+
state = {
66+
attributionDetails: {
67+
creatorName: '',
68+
creatorProfileUrl: '',
69+
workTitle: '',
70+
workUrl: ''
71+
}
72+
}
73+
74+
store = new Vuex.Store({
75+
state,
76+
mutations
77+
})
78+
79+
wrapper = mount(AttributionDetailsStep, {
80+
propsData: {
81+
status: 'current'
82+
},
83+
mocks: {
84+
$t: key => key
85+
},
86+
store,
87+
localVue
88+
})
89+
})
90+
91+
afterEach(() => {
92+
wrapper.destroy()
93+
})
94+
95+
it('Creator Name is updated', async() => {
96+
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-name.placeholder"]')
97+
await input.setValue('Jane Bar')
98+
expect(mutations.setCreatorName).toHaveBeenCalled()
99+
})
100+
101+
// CreatorProfile URL
102+
it('Profile Url is updated', async() => {
103+
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-profile.placeholder"]')
104+
await input.setValue('jane@bar.com')
105+
expect(mutations.setCreatorProfileUrl).toHaveBeenCalled()
106+
})
107+
108+
// Work URL
109+
it('Work Url is updated', async() => {
110+
const input = wrapper.find('input[placeholder="stepper.AD.form.work-url.placeholder"]')
111+
await input.setValue('jane@bar.com/kitty.jpeg')
112+
expect(mutations.setWorkUrl).toHaveBeenCalled()
113+
})
114+
115+
// Work Title
116+
it('Work Title is updated', async() => {
117+
const input = wrapper.find('input[placeholder="stepper.AD.form.work-title.placeholder"]')
118+
await input.setValue('illustrator')
119+
expect(mutations.setWorkTitle).toHaveBeenCalled()
120+
})
121+
})

0 commit comments

Comments
 (0)