const schema = require('../fixtures/schema_public.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: { Registration: { registration: { message: "success", success: true } }, } }); cy.visit('/verify-email?confirmation=abcd1234&id=12'); // user should be logged in at that stage. As the cookie cannot be set at the right time // we just check if the user gets redirected to the login page as we can't log her in cy.url().should('include', 'hello?redirect=%2F'); }); it('displays error if key is incorrect', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, // endpoint: '/api/graphql' operations: { Registration: { registration: { message: "invalid_key", success: false } }, } }); cy.visit('/verify-email?confirmation=abcd1234&id=12'); cy.get('[data-cy="code-nok-msg"]').contains('Der angegebene Verifizierungscode ist ungültig oder abgelaufen.'); cy.get('[data-cy="code-ok-msg"]').should('not.exist'); }); it('displays error if an error occured', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, // endpoint: '/api/graphql' operations: { Registration: { registration: { message: "unkown_error", success: false } }, } }); cy.visit('/verify-email?confirmation=abcd1234&id=12'); cy.get('[data-cy="code-nok-msg"]').contains('Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.'); }); it('forwards to coupon page if user has no valid license', () => { cy.viewport('macbook-15'); cy.mockGraphql({ schema: schema, // endpoint: '/api/graphql' operations: { Registration: { registration: { message: "no_valid_license", success: false } }, } }); cy.visit('/verify-email?confirmation=abcd1234&id=12'); // user should be logged in at that stage. As the cookie cannot be set at the right time // we just check if the user gets redirected to the coupon page as we can't log her in cy.url().should('include', 'hello?redirect=%2Flicense-activation'); }); });