|
| 1 | +describe('I can create a new project as a new user', () => { |
| 2 | + const projectInfo = { |
| 3 | + name: 'Test Project', |
| 4 | + location: '123 Test Street', |
| 5 | + postcode: 42424, |
| 6 | + insee: 42123, |
| 7 | + commune: 'commune de test', |
| 8 | + description: 'This is a test project description', |
| 9 | + email: `${Date.now()}@example.com`, |
| 10 | + fixedEmail: 'test2@example.com', |
| 11 | + }; |
| 12 | + |
| 13 | + const signupInfo = { |
| 14 | + first_name: 'Test', |
| 15 | + last_name: 'User', |
| 16 | + organization: 'Test Organization', |
| 17 | + organization_position: 'Test Position', |
| 18 | + phone_no: '0102030405', |
| 19 | + password1: 'Testpassword123', |
| 20 | + password2: 'Testpassword123', |
| 21 | + }; |
| 22 | + |
| 23 | + const alreadyExistingUserInfo = { |
| 24 | + email: projectInfo.email, |
| 25 | + password: 'Testpassword123', |
| 26 | + }; |
| 27 | + |
| 28 | + it('goes through the complete onboarding process', () => { |
| 29 | + // Visit home page and click on need help button |
| 30 | + cy.visit('/'); |
| 31 | + cy.get('[data-test-id="button-need-help"]') |
| 32 | + .contains('Solliciter') |
| 33 | + .click({ force: true }); |
| 34 | + |
| 35 | + // Land on onboarding/project page |
| 36 | + cy.url().should('include', '/onboarding/project'); |
| 37 | + |
| 38 | + // Fill project form |
| 39 | + cy.get('#id_name') |
| 40 | + .should('not.have.class', 'fr-input--error') |
| 41 | + .type(projectInfo.name, { delay: 0 }) |
| 42 | + .should('have.value', projectInfo.name) |
| 43 | + .should('have.class', 'fr-input--valid'); |
| 44 | + |
| 45 | + cy.get('#id_location') |
| 46 | + .should('not.have.class', 'fr-input--error') |
| 47 | + .type(projectInfo.location, { delay: 0 }) |
| 48 | + .should('have.value', projectInfo.location) |
| 49 | + .should('have.class', 'fr-input--valid'); |
| 50 | + |
| 51 | + cy.get('[data-test-id="input-postcode"]') |
| 52 | + .type(projectInfo.postcode, { delay: 0 }) |
| 53 | + .should('have.value', projectInfo.postcode) |
| 54 | + .parent() |
| 55 | + .should('have.class', 'fr-input-group--valid'); |
| 56 | + |
| 57 | + cy.get('[data-test-id="select-city"]') |
| 58 | + .should('not.have.class', 'fr-select-group--error') |
| 59 | + .focus(); |
| 60 | + |
| 61 | + cy.get('[data-test-id="select-city"]') |
| 62 | + .should('contain.text', projectInfo.commune) |
| 63 | + .should('have.value', projectInfo.insee) |
| 64 | + .parent() |
| 65 | + .should('have.class', 'fr-select-group--valid'); |
| 66 | + |
| 67 | + cy.get('#id_description') |
| 68 | + .should('not.have.class', 'fr-input--error') |
| 69 | + .type(projectInfo.description, { delay: 0 }) |
| 70 | + .should('have.value', projectInfo.description) |
| 71 | + .should('have.class', 'fr-input--valid'); |
| 72 | + |
| 73 | + cy.get('#id_email') |
| 74 | + .should('not.have.class', 'fr-input--error') |
| 75 | + .type(projectInfo.email, { delay: 0 }) |
| 76 | + .should('have.value', projectInfo.email) |
| 77 | + .should('have.class', 'fr-input--valid'); |
| 78 | + |
| 79 | + // Handle captcha |
| 80 | + cy.document().then((doc) => { |
| 81 | + const iframe = doc.getElementById('id_captcha').querySelector('iframe'); |
| 82 | + const innerDoc = iframe.contentDocument || iframe.contentWindow.document; |
| 83 | + innerDoc.querySelector('.recaptcha-checkbox').click(); |
| 84 | + cy.wait(400); |
| 85 | + }); |
| 86 | + |
| 87 | + // Submit project form |
| 88 | + cy.get('button[type="submit"]').click(); |
| 89 | + |
| 90 | + // Land on onboarding/signup page |
| 91 | + cy.url().should('include', '/onboarding/signup'); |
| 92 | + |
| 93 | + // Fill signup form |
| 94 | + cy.get('[name=first_name]') |
| 95 | + .type(signupInfo.first_name, { delay: 0 }) |
| 96 | + .should('have.value', signupInfo.first_name); |
| 97 | + |
| 98 | + cy.get('[name=last_name]') |
| 99 | + .type(signupInfo.last_name, { delay: 0 }) |
| 100 | + .should('have.value', signupInfo.last_name); |
| 101 | + |
| 102 | + cy.get('[name=org_name]') |
| 103 | + .type(signupInfo.organization, { delay: 0 }) |
| 104 | + .should('have.value', signupInfo.organization); |
| 105 | + |
| 106 | + cy.get('[name=role]') |
| 107 | + .type(signupInfo.organization_position, { delay: 0 }) |
| 108 | + .should('have.value', signupInfo.organization_position); |
| 109 | + |
| 110 | + cy.get('[name=phone]') |
| 111 | + .type(signupInfo.phone_no, { delay: 0 }) |
| 112 | + .should('have.value', signupInfo.phone_no); |
| 113 | + |
| 114 | + cy.get('[name=password]') |
| 115 | + .type(signupInfo.password1, { delay: 0 }) |
| 116 | + .should('have.value', signupInfo.password1); |
| 117 | + |
| 118 | + // Submit signup form |
| 119 | + cy.get('[type=submit]').click(); |
| 120 | + |
| 121 | + // Land on onboarding/summary page |
| 122 | + cy.url().should('include', '/onboarding/summary'); |
| 123 | + }); |
| 124 | + |
| 125 | + it('goes through the onboarding process but stop at signup page', () => { |
| 126 | + // Visit home page and click on need help button |
| 127 | + cy.visit('/'); |
| 128 | + cy.get('[data-test-id="button-need-help"]') |
| 129 | + .contains('Solliciter') |
| 130 | + .click({ force: true }); |
| 131 | + |
| 132 | + // Land on onboarding/project page |
| 133 | + cy.url().should('include', '/onboarding/project'); |
| 134 | + |
| 135 | + // Fill project form |
| 136 | + cy.get('#id_name') |
| 137 | + .should('not.have.class', 'fr-input--error') |
| 138 | + .type(projectInfo.name, { delay: 0 }) |
| 139 | + .should('have.value', projectInfo.name) |
| 140 | + .should('have.class', 'fr-input--valid'); |
| 141 | + |
| 142 | + cy.get('#id_location') |
| 143 | + .should('not.have.class', 'fr-input--error') |
| 144 | + .type(projectInfo.location, { delay: 0 }) |
| 145 | + .should('have.value', projectInfo.location) |
| 146 | + .should('have.class', 'fr-input--valid'); |
| 147 | + |
| 148 | + cy.get('[data-test-id="input-postcode"]') |
| 149 | + .type(projectInfo.postcode, { delay: 0 }) |
| 150 | + .should('have.value', projectInfo.postcode) |
| 151 | + .parent() |
| 152 | + .should('have.class', 'fr-input-group--valid'); |
| 153 | + |
| 154 | + cy.get('[data-test-id="select-city"]') |
| 155 | + .should('not.have.class', 'fr-select-group--error') |
| 156 | + .focus(); |
| 157 | + |
| 158 | + cy.get('[data-test-id="select-city"]') |
| 159 | + .should('contain.text', projectInfo.commune) |
| 160 | + .should('have.value', projectInfo.insee) |
| 161 | + .parent() |
| 162 | + .should('have.class', 'fr-select-group--valid'); |
| 163 | + |
| 164 | + cy.get('#id_description') |
| 165 | + .should('not.have.class', 'fr-input--error') |
| 166 | + .type(projectInfo.description, { delay: 0 }) |
| 167 | + .should('have.value', projectInfo.description) |
| 168 | + .should('have.class', 'fr-input--valid'); |
| 169 | + |
| 170 | + cy.get('#id_email') |
| 171 | + .should('not.have.class', 'fr-input--error') |
| 172 | + .type(projectInfo.fixedEmail, { delay: 0 }) |
| 173 | + .should('have.value', projectInfo.fixedEmail) |
| 174 | + .should('have.class', 'fr-input--valid'); |
| 175 | + |
| 176 | + // Handle captcha |
| 177 | + cy.document().then((doc) => { |
| 178 | + const iframe = doc.getElementById('id_captcha').querySelector('iframe'); |
| 179 | + const innerDoc = iframe.contentDocument || iframe.contentWindow.document; |
| 180 | + innerDoc.querySelector('.recaptcha-checkbox').click(); |
| 181 | + cy.wait(400); |
| 182 | + }); |
| 183 | + |
| 184 | + // Submit project form |
| 185 | + cy.get('button[type="submit"]').click(); |
| 186 | + |
| 187 | + // Land on onboarding/signup page |
| 188 | + cy.url().should('include', '/onboarding/signup'); |
| 189 | + |
| 190 | + // Restart at project page |
| 191 | + cy.visit('/onboarding/project'); |
| 192 | + |
| 193 | + cy.get('[data-cy="found-email-onboarding"]').should( |
| 194 | + 'contain.text', |
| 195 | + projectInfo.fixedEmail |
| 196 | + ); |
| 197 | + |
| 198 | + cy.get('[data-cy="continue-onboarding"]').click(); |
| 199 | + |
| 200 | + // Fill signup form |
| 201 | + cy.get('[name=first_name]') |
| 202 | + .type(signupInfo.first_name, { delay: 0 }) |
| 203 | + .should('have.value', signupInfo.first_name); |
| 204 | + |
| 205 | + cy.get('[name=last_name]') |
| 206 | + .type(signupInfo.last_name, { delay: 0 }) |
| 207 | + .should('have.value', signupInfo.last_name); |
| 208 | + |
| 209 | + cy.get('[name=org_name]') |
| 210 | + .type(signupInfo.organization, { delay: 0 }) |
| 211 | + .should('have.value', signupInfo.organization); |
| 212 | + |
| 213 | + cy.get('[name=role]') |
| 214 | + .type(signupInfo.organization_position, { delay: 0 }) |
| 215 | + .should('have.value', signupInfo.organization_position); |
| 216 | + |
| 217 | + cy.get('[name=phone]') |
| 218 | + .type(signupInfo.phone_no, { delay: 0 }) |
| 219 | + .should('have.value', signupInfo.phone_no); |
| 220 | + |
| 221 | + cy.get('[name=password]') |
| 222 | + .type(signupInfo.password1, { delay: 0 }) |
| 223 | + .should('have.value', signupInfo.password1); |
| 224 | + |
| 225 | + // Submit signup form |
| 226 | + cy.get('[type=submit]').click(); |
| 227 | + |
| 228 | + // Land on onboarding/summary page |
| 229 | + cy.url().should('include', '/onboarding/summary'); |
| 230 | + }); |
| 231 | + |
| 232 | + it('goes through the complete onboarding process with already existing user', () => { |
| 233 | + // Visit home page and click on need help button |
| 234 | + cy.visit('/'); |
| 235 | + cy.get('[data-test-id="button-need-help"]') |
| 236 | + .contains('Solliciter') |
| 237 | + .click({ force: true }); |
| 238 | + |
| 239 | + // Land on onboarding/project page |
| 240 | + cy.url().should('include', '/onboarding/project'); |
| 241 | + |
| 242 | + // Fill project form |
| 243 | + cy.get('#id_name') |
| 244 | + .should('not.have.class', 'fr-input--error') |
| 245 | + .type(projectInfo.name, { delay: 0 }) |
| 246 | + .should('have.value', projectInfo.name) |
| 247 | + .should('have.class', 'fr-input--valid'); |
| 248 | + |
| 249 | + cy.get('#id_location') |
| 250 | + .should('not.have.class', 'fr-input--error') |
| 251 | + .type(projectInfo.location, { delay: 0 }) |
| 252 | + .should('have.value', projectInfo.location) |
| 253 | + .should('have.class', 'fr-input--valid'); |
| 254 | + |
| 255 | + cy.get('[data-test-id="input-postcode"]') |
| 256 | + .type(projectInfo.postcode, { delay: 0 }) |
| 257 | + .should('have.value', projectInfo.postcode) |
| 258 | + .parent() |
| 259 | + .should('have.class', 'fr-input-group--valid'); |
| 260 | + |
| 261 | + cy.get('[data-test-id="select-city"]') |
| 262 | + .should('not.have.class', 'fr-select-group--error') |
| 263 | + .focus(); |
| 264 | + |
| 265 | + cy.get('[data-test-id="select-city"]') |
| 266 | + .should('contain.text', projectInfo.commune) |
| 267 | + .should('have.value', projectInfo.insee) |
| 268 | + .parent() |
| 269 | + .should('have.class', 'fr-select-group--valid'); |
| 270 | + |
| 271 | + cy.get('#id_description') |
| 272 | + .should('not.have.class', 'fr-input--error') |
| 273 | + .type(projectInfo.description, { delay: 0 }) |
| 274 | + .should('have.value', projectInfo.description) |
| 275 | + .should('have.class', 'fr-input--valid'); |
| 276 | + |
| 277 | + cy.get('#id_email') |
| 278 | + .should('not.have.class', 'fr-input--error') |
| 279 | + .type(projectInfo.email, { delay: 0 }) |
| 280 | + .should('have.value', projectInfo.email) |
| 281 | + .should('have.class', 'fr-input--valid'); |
| 282 | + |
| 283 | + // Handle captcha |
| 284 | + cy.document().then((doc) => { |
| 285 | + const iframe = doc.getElementById('id_captcha').querySelector('iframe'); |
| 286 | + const innerDoc = iframe.contentDocument || iframe.contentWindow.document; |
| 287 | + innerDoc.querySelector('.recaptcha-checkbox').click(); |
| 288 | + cy.wait(400); |
| 289 | + }); |
| 290 | + |
| 291 | + // Submit project form |
| 292 | + cy.get('button[type="submit"]').click(); |
| 293 | + |
| 294 | + // Land on onboarding/signup page |
| 295 | + cy.url().should('include', '/onboarding/signin'); |
| 296 | + |
| 297 | + // Fill signup form |
| 298 | + cy.get('[name=login]').should('have.value', alreadyExistingUserInfo.email); |
| 299 | + |
| 300 | + cy.get('[name=password]') |
| 301 | + .type(alreadyExistingUserInfo.password, { delay: 0 }) |
| 302 | + .should('have.value', alreadyExistingUserInfo.password); |
| 303 | + |
| 304 | + // Submit signup form |
| 305 | + cy.get('[type=submit]').click(); |
| 306 | + |
| 307 | + // Land on onboarding/summary page |
| 308 | + cy.url().should('include', '/onboarding/summary'); |
| 309 | + }); |
| 310 | +}); |
0 commit comments