Skip to content

Commit 0d9685e

Browse files
committed
Merge branch 'master' into modals
# Conflicts: # package.json
2 parents 341c5da + e5656e5 commit 0d9685e

30 files changed

+741
-225
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
dist/
55
coverage/
66
node_modules/
7+
yarn.lock

cypress.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
{}
1+
{
2+
"project": "creativecommons-chooser",
3+
"baseUrl": "http://localhost:8080/"
4+
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/* This Source Code Form is subject to the terms of the Creative Commons
2+
* License Chooser
3+
*/
4+
5+
describe('Stepper.vue', () => {
6+
describe('User can select licenses using the dropdown', () => {
7+
it('Selecting CC0', () => {
8+
cy.visit('/')
9+
cy.makeAChoice('.FS', 'yes')
10+
cy.clickNext()
11+
cy.get('select').select('CC0 1.0')
12+
cy.hasRecommendedLicense('CC0 1.0 Universal')
13+
cy.hasStepsCount(4)
14+
cy.clickNext()
15+
cy.waiveCopyright()
16+
cy.clickNext()
17+
cy.hasLicenseInAttributionCode(' CC0 1.0 ')
18+
})
19+
20+
it('Selecting CC BY-NC-ND', () => {
21+
cy.visit('/')
22+
cy.makeAChoice('.FS', 'yes')
23+
cy.clickNext()
24+
cy.get('select').select('CC BY-NC-ND 4.0')
25+
cy.hasRecommendedLicense('CC BY-NC-ND 4.0')
26+
cy.hasStepsCount(3)
27+
cy.clickNext()
28+
cy.hasLicenseInAttributionCode('CC BY-NC-ND 4.0')
29+
})
30+
})
31+
32+
describe('User can select a license using the steps', () => {
33+
it('Selecting CC0', () => {
34+
cy.visit('/')
35+
cy.makeAChoice('.FS', 'no')
36+
cy.clickNext()
37+
cy.makeAChoice('.BY', 'no')
38+
cy.hasRecommendedLicense('CC0 1.0 Universal')
39+
cy.hasStepsCount(7)
40+
cy.clickNext()
41+
cy.get('.NC').should('have.class', 'disabled')
42+
cy.get('.ND').should('have.class', 'disabled')
43+
cy.get('.SA').should('have.class', 'disabled')
44+
cy.waiveCopyright()
45+
cy.clickNext()
46+
cy.hasLicenseInAttributionCode(' CC0 1.0 ')
47+
})
48+
49+
it('Selecting CC BY', () => {
50+
cy.visit('/')
51+
cy.makeAChoice('.FS', 'no')
52+
cy.clickNext()
53+
cy.makeAChoice('.BY', 'yes')
54+
cy.hasRecommendedLicense('CC BY 4.0')
55+
cy.hasStepsCount(6)
56+
cy.clickNext()
57+
cy.makeAChoice('.NC', 'yes')
58+
cy.clickNext()
59+
cy.makeAChoice('.ND', 'yes')
60+
cy.clickNext()
61+
cy.makeAChoice('.SA', 'yes')
62+
cy.get('.AD').should('be.visible')
63+
cy.clickNext()
64+
cy.hasLicenseInAttributionCode('CC BY 4.0')
65+
})
66+
67+
it('Selecting CC BY-NC-ND', () => {
68+
cy.visit('/')
69+
cy.makeAChoice('.FS', 'no')
70+
cy.clickNext()
71+
cy.makeAChoice('.BY', 'yes')
72+
cy.hasRecommendedLicense('CC BY 4.0')
73+
cy.clickNext()
74+
cy.makeAChoice('.NC', 'no')
75+
cy.hasRecommendedLicense('CC BY-NC 4.0')
76+
cy.clickNext()
77+
cy.makeAChoice('.ND', 'no')
78+
cy.hasRecommendedLicense('CC BY-NC-ND 4.0')
79+
cy.clickNext()
80+
cy.get('.SA').should('have.class', 'disabled')
81+
cy.hasLicenseInAttributionCode('CC BY-NC-ND 4.0')
82+
})
83+
84+
it('Can select CC BY-ND', () => {
85+
cy.visit('/')
86+
cy.makeAChoice('.FS', 'no')
87+
cy.clickNext()
88+
cy.makeAChoice('.BY', 'yes')
89+
cy.hasRecommendedLicense('CC BY 4.0')
90+
cy.clickNext()
91+
cy.makeAChoice('.NC', 'yes')
92+
cy.clickNext()
93+
cy.makeAChoice('.ND', 'no')
94+
cy.hasRecommendedLicense('CC BY-ND 4.0')
95+
cy.clickNext()
96+
cy.get('.SA').should('have.class', 'disabled')
97+
cy.hasLicenseInAttributionCode('CC BY-ND 4.0')
98+
})
99+
})
100+
101+
describe('"Back", "Done" and "Start again" buttons work correctly', () => {
102+
it('User can select CC BY-ND, go back and change selection to CC BY-SA', () => {
103+
cy.clickBack()
104+
cy.makeAChoice('.ND', 'yes')
105+
cy.clickNext()
106+
cy.makeAChoice('.SA', 'no')
107+
cy.clickNext()
108+
cy.hasRecommendedLicense('CC BY-SA 4.0')
109+
cy.get('.AD').should('be.visible')
110+
cy.hasLicenseInAttributionCode('CC BY-SA 4.0')
111+
})
112+
113+
it('User can select CCO using the License Dropdown, go back and select CC BY-NC-SA using steps', () => {
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.clickNext()
120+
cy.waiveCopyright()
121+
cy.clickNext()
122+
cy.hasLicenseInAttributionCode(' CC0 1.0 ')
123+
cy.clickBack()
124+
cy.clickBack()
125+
cy.clickBack()
126+
cy.makeAChoice('.FS', 'no')
127+
cy.clickNext()
128+
cy.makeAChoice('.BY', 'yes')
129+
cy.hasRecommendedLicense('CC BY 4.0')
130+
cy.clickNext()
131+
cy.makeAChoice('.NC', 'yes')
132+
cy.clickNext()
133+
cy.makeAChoice('.ND', 'yes')
134+
cy.clickNext()
135+
cy.makeAChoice('.SA', 'no')
136+
cy.hasRecommendedLicense('CC BY-SA 4.0')
137+
cy.clickNext()
138+
cy.hasLicenseInAttributionCode('CC BY-SA 4.0')
139+
})
140+
141+
it('User can start the selection process over by clicking "Start again" Button', () => {
142+
cy.get('button').contains('Start again').click()
143+
cy.get('.right-column').find('.recommended-card').should('not.exist')
144+
cy.get('.right-column').find('.license-use-card').should('not.exist')
145+
cy.get('.BY').should('have.class', 'inactive')
146+
cy.get('.NC').should('have.class', 'inactive')
147+
cy.get('.ND').should('have.class', 'inactive')
148+
cy.get('.SA').should('have.class', 'inactive')
149+
})
150+
151+
it('Chooser auto-scrolls to "Mark Your Work" section when "Done" is clicked', () => {
152+
cy.visit('/')
153+
cy.viewport('iphone-x')
154+
cy.makeAChoice('.FS', 'no')
155+
cy.clickNext()
156+
cy.makeAChoice('.BY', 'yes')
157+
cy.clickNext()
158+
cy.makeAChoice('.NC', 'yes')
159+
cy.clickNext()
160+
cy.makeAChoice('.ND', 'no')
161+
cy.clickNext()
162+
cy.get('.SA').should('have.class', 'disabled')
163+
cy.hasRecommendedLicense('CC BY-ND 4.0')
164+
cy.window().then(($window) => {
165+
expect($window.scrollY).to.be.closeTo(800, 300)
166+
})
167+
cy.get('button').contains('DONE').click()
168+
cy.hasLicenseInAttributionCode('CC BY-ND 4.0')
169+
cy.window().then(($window) => {
170+
expect($window.scrollY).to.be.closeTo(1400, 300)
171+
})
172+
})
173+
})
174+
})

cypress/support/commands.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,30 @@
2323
//
2424
// -- This will overwrite an existing command --
2525
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26+
27+
Cypress.Commands.add("clickNext", () => {
28+
cy.get('button').contains('NEXT').click()
29+
})
30+
Cypress.Commands.add("clickBack", () => {
31+
cy.get('button').contains('BACK').click()
32+
})
33+
34+
Cypress.Commands.add("makeAChoice", (stepId, choice) => {
35+
cy.get(stepId).find(`[value="${choice}"]`).check()
36+
})
37+
38+
Cypress.Commands.add('waiveCopyright', () => {
39+
cy.get('.v-checkbox:nth-child(1) > input').check()
40+
cy.get('.v-checkbox:nth-child(2) > input').check()
41+
})
42+
43+
Cypress.Commands.add('hasRecommendedLicense', (license) => {
44+
cy.get('.recommended-card').should('be.visible').contains(license)
45+
})
46+
47+
Cypress.Commands.add('hasLicenseInAttributionCode', (license) => {
48+
cy.get('.license-use-card').should('be.visible').contains(license)
49+
})
50+
Cypress.Commands.add('hasStepsCount', (stepsCount) => {
51+
cy.get('.stepper__container').find('.step-container').should('have.lengthOf', stepsCount)
52+
})

docs/CNAME

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chooser-beta.creativecommons.org
1+
chooser-beta.creativecommons.org

0 commit comments

Comments
 (0)