diff --git a/client/cypress/integration/login-page-spec.js b/client/cypress/integration/login-page-spec.js index 7435078d..71ad2001 100644 --- a/client/cypress/integration/login-page-spec.js +++ b/client/cypress/integration/login-page-spec.js @@ -43,52 +43,5 @@ describe('The Login Page', () => { cy.login(username, password); cy.get('body').contains('Berufliche Grundbildung'); }); - // it('logs in programmatically without using the UI', () => { - // cy.visit('/accounts/login/'); // have to get a csrf token by getting the base page first - // - // const username = 'test'; - // const password = 'test'; - // - // cy.getCookie('csrftoken').then(token => { - // const options = { - // url: '/accounts/login/', - // method: 'POST', - // headers: { - // 'X-CSRFToken': token.value, - // 'content-type': 'multipart/form-data' - // }, - // from: true, - // body: { - // username: username, - // password: password, - // // csrfmiddlewaretoken: token.value - // } - // }; - // - // cy.request(options); - // cy.getCookie('sessionid').should('exist'); - // cy.visit('/'); - // - // cy.get('.start-page__title').should('contain', 'skillbox') - // - // - // // cy.visit('/'); - // // cy.getCookie('csrftoken') - // // .then((csrftoken) => { - // // const response = cy.request({ - // // method: 'POST', - // // url: '/login/', - // // form: true, - // // body: { - // // identification: username, - // // password: password, - // // csrfmiddlewaretoken: csrftoken.value - // // } - // // }); - // // }); - // - // }); - - // }) }) diff --git a/client/cypress/integration/registration-page-spec.js b/client/cypress/integration/registration-page-spec.js new file mode 100644 index 00000000..fa81b961 --- /dev/null +++ b/client/cypress/integration/registration-page-spec.js @@ -0,0 +1,76 @@ +describe('The Regstration Page', () => { + it('register user', () => { + + let timestamp = Math.round((new Date()).getTime() / 1000); + + const firstname = 'pesche'; + const lastname = 'peschemann'; + const email = `skillboxtest${timestamp}@iterativ.ch`; + const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8'; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('.reset__heading').contains('Schauen Sie in Ihr Postfach'); + }); + + it('user sees error message if firstname is omitted', () => { + let timestamp = Math.round((new Date()).getTime() / 1000); + const firstname = ''; + const lastname = 'peschemann'; + const email = `skillboxtest${timestamp}@iterativ.ch`; + const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8'; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('[data-cy="firstname-local-errors"]').contains('Vorname ist ein Pflichtfeld.'); + }); + + it('user sees error message if lastname is omitted', () => { + let timestamp = Math.round((new Date()).getTime() / 1000); + const firstname = 'pesche'; + const lastname = ''; + const email = `skillboxtest${timestamp}@iterativ.ch`; + const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8'; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('[data-cy="lastname-local-errors"]').contains('Nachname ist ein Pflichtfeld.'); + }); + + it('user sees error message if email is omitted', () => { + let timestamp = Math.round((new Date()).getTime() / 1000); + const firstname = 'pesche'; + const lastname = 'peschemann'; + const email = ``; + const licenseKey = 'c1fa2e2a-2e27-480d-8469-2e88414c4ad8'; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('[data-cy="email-local-errors"]').contains('E-Mail ist ein Pflichtfeld.'); + }); + + it('user sees error message if license is omitted', () => { + let timestamp = Math.round((new Date()).getTime() / 1000); + const firstname = 'pesche'; + const lastname = 'peschemann'; + const email = `skillboxtest${timestamp}@iterativ.ch`; + const licenseKey = ''; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('[data-cy="licenseKey-local-errors"]').contains('Lizenz ist ein Pflichtfeld.'); + }); + + it('user sees error message if license key is wrong', () => { + let timestamp = Math.round((new Date()).getTime() / 1000); + const firstname = 'pesche'; + const lastname = 'peschemann'; + const email = `skillboxtest${timestamp}@iterativ.ch`; + const licenseKey = 'asdsafsadfsadfasdf'; + + cy.visit('/register'); + cy.register(firstname, lastname, email, licenseKey); + cy.get('[data-cy="licenseKey-remote-errors"]').contains('Die angegebenen Lizenz ist unglültig'); + }); + +}) diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index faaebc76..f76b462c 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -82,3 +82,23 @@ Cypress.Commands.add('changePassword', (oldPassword, newPassword) => { } cy.get('[data-cy=change-password-button]').click(); }); + +Cypress.Commands.add('register', (firstname, lastname, email, licenseKey) => { + if (firstname != '') { + cy.get('[data-cy=firstname-input]').type(firstname); + } + + if (lastname != '') { + cy.get('[data-cy=lastname-input]').type(lastname); + } + + if (email != '') { + cy.get('[data-cy=email-input]').type(email); + } + + if (licenseKey != '') { + cy.get('[data-cy=licenseKey-input]').type(licenseKey); + } + + cy.get('[data-cy=register-button]').click(); +}); diff --git a/client/src/pages/registration.vue b/client/src/pages/registration.vue index 6860a5a8..69a80778 100644 --- a/client/src/pages/registration.vue +++ b/client/src/pages/registration.vue @@ -110,7 +110,7 @@ {{registrationError}}