const schema = require('../fixtures/schema.json'); describe('Email Verifcation', () => { beforeEach(() => { cy.server(); }); it('forwards to homepage if confirmation key is correct', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, operations: { Coupon: variables => { return { coupon: { errors: [], success: true } } }, } }); cy.login('rahel.cueni', 'test', true) cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen'); cy.visit('/license-activation'); cy.redeemCoupon('12345asfd'); cy.get('body').contains('Neues Wissen erwerben'); }); it('displays error if input is missing', () => { cy.viewport('macbook-15'); cy.login('rahel.cueni', 'test', true) cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen'); cy.visit('/license-activation'); cy.redeemCoupon(''); cy.get('[data-cy="coupon-local-errors"]').contains('Coupon ist ein Pflichtfeld.'); }); it('displays error if coupon input is wrong', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, operations: { Coupon: variables => { return { coupon: { errors: [{ field: 'invalid_coupon' }], success: false } } }, } }); cy.login('rahel.cueni', 'test', true) cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen'); cy.visit('/license-activation'); cy.redeemCoupon('12345asfd'); cy.get('[data-cy="coupon-remote-errors"]').contains('Der angegebene Coupon-Code ist falsch.'); }); it('displays error if an error occures', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, operations: { Coupon: variables => { return { coupon: { errors: [{ field: 'unknown_error' }], success: false } } }, } }); cy.login('rahel.cueni', 'test', true) cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen'); cy.visit('/license-activation'); cy.redeemCoupon('12345asfd'); cy.get('[data-cy="coupon-remote-errors"]').contains('Es ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmals oder kontaktieren Sie den Administrator.'); }); });