Skip to content

Commit 34dadda

Browse files
committed
added new cypress steps for info button and year of creation
1 parent 40a206b commit 34dadda

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

tests/cypress/integration/AttributionDetails._spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,31 @@ describe('Attribution Details Step.vue', () => {
109109
})
110110
})
111111

112+
describe('Year Of Creation Input field available or not', () => {
113+
it('not visible if the license is not CC-BY type', () => {
114+
cy.visit('/')
115+
cy.makeAChoice('.FS', 'yes')
116+
cy.clickNext()
117+
cy.get('select').select('CC0 1.0')
118+
cy.hasRecommendedLicense('CC0 1.0 Universal')
119+
cy.hasStepsCount(4)
120+
cy.clickNext()
121+
cy.waiveCopyright()
122+
cy.clickNext()
123+
cy.missingInputField(5)
124+
})
125+
it('visible if the license is of type CC-BY', () => {
126+
cy.visit('/')
127+
cy.makeAChoice('.FS', 'yes')
128+
cy.clickNext()
129+
cy.get('select').select('CC BY 4.0')
130+
cy.hasRecommendedLicense('Attribution 4.0 International')
131+
cy.hasStepsCount(3)
132+
cy.clickNext()
133+
cy.visibleInputField(5)
134+
})
135+
})
136+
112137
describe('Attribution details are updated correctly', () => {
113138
it('When the user adds information in the attribution details, the license code is updated accordingly', () => {
114139
cy.visit('/')
@@ -127,5 +152,15 @@ describe('Attribution Details Step.vue', () => {
127152
cy.valueOfInputField(1, '[property="dct:title"]')
128153
cy.valueOfInputField(2, '[property="cc:attributionName"]')
129154
})
155+
it('When the user adds information in the attribution details, the year of Creation field is updated accordingly', () => {
156+
cy.clickBack()
157+
cy.clickBack()
158+
cy.get('select').select('CC BY 4.0')
159+
cy.hasRecommendedLicense('Attribution 4.0 International')
160+
cy.hasStepsCount(3)
161+
cy.clickNext()
162+
cy.selectInputField(5, '2021')
163+
cy.valueOfInputField(5, '.license-text > :nth-child(2)')
164+
})
130165
})
131166
})

tests/cypress/integration/Stepper._spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,21 @@ describe('Stepper.vue', () => {
205205
})
206206
})
207207
})
208+
it('Clicking the info button', () => {
209+
cy.visit('/')
210+
cy.makeAChoice('.FS', 'yes')
211+
cy.clickNext()
212+
cy.get('select').select('CC0 1.0')
213+
cy.hasRecommendedLicense('CC0 1.0 Universal')
214+
cy.hasStepsCount(4)
215+
cy.clickNext()
216+
cy.waiveCopyright()
217+
cy.clickNext()
218+
cy.hasLicenseInAttributionCode(' CC0 1.0 ')
219+
cy.missingModal()
220+
cy.clickInfo()
221+
cy.openModal()
222+
cy.clickClose()
223+
cy.missingModal()
224+
})
208225
})

tests/cypress/support/commands.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Cypress.Commands.add("clickBack", () => {
3131
cy.get('button').contains('BACK').click()
3232
})
3333

34+
Cypress.Commands.add('clickInfo', () => {
35+
cy.get('.info').click()
36+
})
37+
3438
Cypress.Commands.add("makeAChoice", (stepId, choice) => {
3539
cy.get(stepId).find(`[value="${choice}"]`).check()
3640
})
@@ -47,33 +51,62 @@ Cypress.Commands.add('hasRecommendedLicense', (license) => {
4751
Cypress.Commands.add('hasLicenseInAttributionCode', (license) => {
4852
cy.get('.license-use-card').should('be.visible').contains(license)
4953
})
54+
5055
Cypress.Commands.add('hasStepsCount', (stepsCount) => {
5156
cy.get('.stepper__container').find('.step-container').should('have.lengthOf', stepsCount)
5257
})
58+
5359
Cypress.Commands.add('missingLicenseInAttributionCode', () => {
5460
cy.get('.license-use-card').should('not.exist')
5561
})
62+
5663
Cypress.Commands.add('headerTitle', (license) => {
5764
cy.get('.license-short-name > .b-header').contains(license)
5865
})
66+
5967
Cypress.Commands.add('readableStringTitle', (license) => {
6068
cy.get('b').contains(license)
6169
})
70+
6271
Cypress.Commands.add('licenseText', (license) => {
6372
cy.get('.license-text > a').contains(license)
6473
})
74+
6575
Cypress.Commands.add('copyButton', (text) => {
6676
cy.get('.donate').contains(text).click()
6777
})
78+
79+
Cypress.Commands.add('missingInputField', (id) => {
80+
cy.get(`:nth-child(${id}) > label.is-normal > .control-inner > .input`).should('not.exist')
81+
})
82+
83+
Cypress.Commands.add('visibleInputField', (id) => {
84+
cy.get(`:nth-child(${id}) > label.is-normal > .control-inner > .input`).should('exist')
85+
})
86+
6887
Cypress.Commands.add('selectInputField', (id, text) => {
6988
cy.get(`:nth-child(${id}) > label.is-normal > .control-inner > .input`).type(text)
7089
})
90+
7191
Cypress.Commands.add('valueOfInputField', (id, attr) => {
7292
cy.get(`:nth-child(${id}) > label.is-normal > .control-inner > .input`).invoke('val')
7393
.then((text) => {
7494
cy.get(`${attr}`).contains(text)
7595
})
7696
})
97+
7798
Cypress.Commands.add('toggleButton', () => {
7899
cy.get('#copy-type').click()
79100
})
101+
102+
Cypress.Commands.add('openModal', () => {
103+
cy.get('.modal').should('exist')
104+
})
105+
106+
Cypress.Commands.add('missingModal', () => {
107+
cy.get('.modal').should('not.exist')
108+
})
109+
110+
Cypress.Commands.add('clickClose', () => {
111+
cy.get('.close-button').click()
112+
})

0 commit comments

Comments
 (0)