77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
import { GraphQLError } from "graphql";
|
|
|
|
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: {
|
|
coupon: {
|
|
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: new GraphQLError('invalid_coupon')
|
|
}
|
|
});
|
|
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 ungültig.');
|
|
|
|
});
|
|
|
|
it('displays error if an error occures', () => {
|
|
cy.viewport('macbook-15');
|
|
cy.mockGraphql({
|
|
schema: schema,
|
|
operations: {
|
|
Coupon: new GraphQLError("unknown_error")
|
|
}
|
|
});
|
|
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.');
|
|
|
|
});
|
|
|
|
});
|