diff --git a/routes/participants/registration.js b/routes/participants/registration.js index 9c02300b..eb919e08 100644 --- a/routes/participants/registration.js +++ b/routes/participants/registration.js @@ -28,6 +28,7 @@ router.post('/', (req, res) => { bank: config.get('contact.bank'), token: result.token, amount: new Intl.NumberFormat('de-DE', {minimumFractionDigits: '2'}).format(calculator.priceFor(newParticipant)), + free: calculator.priceFor(newParticipant) < 1, editUrl: editUrlHelper.generateUrl(result.secureid), startnr: result.startnr }), err => res.render('failure', { diff --git a/service/registration.js b/service/registration.js index 4b3e19f6..8155840d 100644 --- a/service/registration.js +++ b/service/registration.js @@ -64,6 +64,7 @@ registration.sendConfirmationMail = (participant, paymentToken) => { token: paymentToken, bank: config.get('contact.bank'), amount: calculator.priceFor(participant), + free: calculator.priceFor(participant) < 1, editUrl: editUrlHelper.generateUrl(participant.secureID), startnr: participant.start_number }, diff --git a/spec/registrationJourney.js b/spec/registrationJourney.js index 3d727d96..a26ffc68 100644 --- a/spec/registrationJourney.js +++ b/spec/registrationJourney.js @@ -6,6 +6,7 @@ const helper = require('./journeyHelper'); const config = require('config'); const registration = require('../service/registration'); +const couponcodes = require('../service/couponcodes'); describe('registration journey', () => { @@ -67,13 +68,55 @@ describe('registration journey', () => { }) .getText('span.amount') .then((amount) => { - expect(amount).toMatch(/20.00/); + expect(amount).toMatch(/20.00/); // shirt and full price }) .getText('span.startNumber') .then((number) => { expect(number).toMatch(/d*/); }) - .end(done); + .call(done); + }); + + it("doesn't display bank details and payment message when valid coupon code is used", (done) => { + couponcodes.create() + .then((code) => { + client.url(helper.paceUrl) + .click('a#registration') + .isVisible('form#registrationForm') + .setValue('input#firstname', 'Max') + .setValue('input#lastname', 'Mustermann') + .setValue('input#email', 'max@example.com') + .selectByValue('select#category', 'f') + .setValue('input#birthyear', 2000) + .setValue('input#team', 'Crazy runners') + .selectByIndex('select#visibility', 1) + .selectByIndex('select#goal', 2) + .selectByIndex('select#discount', 2) + .isVisible('input#couponcode') + .then((isVisible) => { + expect(isVisible).toBe(true); + }) + .setValue('input#couponcode', code.code) + .click('input#shirt') + .click('button#submit') + .isVisible('div.thanks') + .then((isVisible) => { + expect(isVisible).toBe(true); + }) + .isVisible('a#editurl') + .then(function (isVisible) { + expect(isVisible).toBe(true); + }) + .getText('span.amount') + .then((amount) => { + expect(amount).toMatch(/10.00/); // only tshirt price + }) + .getText('span.startNumber') + .then((number) => { + expect(number).toMatch(/d*/); + }) + .call(done); + }); }); it('allows to register without giving too much information', (done) => { diff --git a/views/registration/confirmationText.pug b/views/registration/confirmationText.pug index e6c7132f..1f66a579 100644 --- a/views/registration/confirmationText.pug +++ b/views/registration/confirmationText.pug @@ -1,6 +1,6 @@ h3 Hey #{name}! h5 Danke für deine Registrierung. - if amount > 0 + if !free | Bitte überweise den Betrag von  span.amount #{amount} | Euro auf folgendes Konto: