Fix broken cypress tests
This commit is contained in:
parent
841b75e0db
commit
ae3f990898
|
|
@ -4,7 +4,7 @@ describe('The Login Page', () => {
|
|||
const password = 'test';
|
||||
cy.visit('/beta-login');
|
||||
cy.login(username, password, true);
|
||||
cy.get('body').contains('Neues Wissen erwerben');
|
||||
cy.assertStartPage();
|
||||
});
|
||||
|
||||
it('user sees error message if username is omitted', () => {
|
||||
|
|
@ -35,7 +35,6 @@ describe('The Login Page', () => {
|
|||
});
|
||||
|
||||
it('logs out then logs in again', () => {
|
||||
|
||||
const user = 'rahel.cueni';
|
||||
const pw = 'test'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
describe('Bookmarks', () => {
|
||||
beforeEach(() => {
|
||||
// todo: mock all the graphql queries and mutations
|
||||
cy.exec("python ../server/manage.py prepare_bookmarks_for_cypress");
|
||||
cy.exec('python ../server/manage.py prepare_bookmarks_for_cypress');
|
||||
|
||||
cy.viewport('macbook-15');
|
||||
cy.startGraphQLCapture();
|
||||
cy.login('rahel.cueni', 'test', true);
|
||||
cy.get('body').contains('Neues Wissen erwerben');
|
||||
cy.assertStartPage();
|
||||
});
|
||||
|
||||
it('should bookmark content block', () => {
|
||||
|
|
@ -35,5 +35,4 @@ describe('Bookmarks', () => {
|
|||
|
||||
cy.get('[data-cy=modal-save-button]').click();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { GraphQLError } from "graphql";
|
||||
import { GraphQLError } from 'graphql';
|
||||
|
||||
const schema = require('../fixtures/schema.json');
|
||||
|
||||
|
|
@ -20,23 +20,21 @@ describe('Email Verifcation', () => {
|
|||
}
|
||||
});
|
||||
cy.login('rahel.cueni', 'test', true)
|
||||
cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen');
|
||||
cy.assertStartPage();
|
||||
|
||||
cy.visit('/license-activation');
|
||||
cy.redeemCoupon('12345asfd');
|
||||
cy.get('body').contains('Neues Wissen erwerben');
|
||||
|
||||
cy.assertStartPage();
|
||||
});
|
||||
|
||||
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.assertStartPage();
|
||||
|
||||
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', () => {
|
||||
|
|
@ -48,12 +46,11 @@ describe('Email Verifcation', () => {
|
|||
}
|
||||
});
|
||||
cy.login('rahel.cueni', 'test', true)
|
||||
cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen');
|
||||
cy.assertStartPage();
|
||||
|
||||
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', () => {
|
||||
|
|
@ -61,16 +58,14 @@ describe('Email Verifcation', () => {
|
|||
cy.mockGraphql({
|
||||
schema: schema,
|
||||
operations: {
|
||||
Coupon: new GraphQLError("unknown_error")
|
||||
Coupon: new GraphQLError('unknown_error')
|
||||
}
|
||||
});
|
||||
cy.login('rahel.cueni', 'test', true)
|
||||
cy.get('[data-cy="rooms-link"]').contains('Alle Räume anzeigen');
|
||||
cy.assertStartPage();
|
||||
|
||||
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.');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
// import 'cypress-graphql-mock';
|
||||
import '@iam4x/cypress-graphql-mock';
|
||||
|
||||
|
||||
Cypress.Commands.add('apolloLogin', (username, password) => {
|
||||
const payload = {
|
||||
'operationName': 'BetaLogin',
|
||||
|
|
@ -47,12 +46,10 @@ Cypress.Commands.add('apolloLogin', (username, password) => {
|
|||
url: '/api/graphql-public/',
|
||||
body: payload
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
// todo: replace with apollo call
|
||||
Cypress.Commands.add("login", (username, password, visitLogin = false) => {
|
||||
Cypress.Commands.add('login', (username, password, visitLogin = false) => {
|
||||
if (visitLogin) {
|
||||
cy.visit('/beta-login');
|
||||
}
|
||||
|
|
@ -67,7 +64,7 @@ Cypress.Commands.add("login", (username, password, visitLogin = false) => {
|
|||
cy.get('[data-cy=login-button]').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("logout", () => {
|
||||
Cypress.Commands.add('logout', () => {
|
||||
cy.get('[data-cy=user-icon]').click();
|
||||
cy.get('[data-cy=logout]').click();
|
||||
});
|
||||
|
|
@ -122,7 +119,6 @@ Cypress.Commands.add('enterPassword', (password) => {
|
|||
});
|
||||
|
||||
Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, postcode, password, passwordConfirmation, acceptTerms) => {
|
||||
|
||||
let selection = prefix === 1 ? 'Herr' : 'Frau';
|
||||
|
||||
cy.get('[data-cy="prefix-selection"]').select(selection);
|
||||
|
|
@ -153,7 +149,7 @@ Cypress.Commands.add('register', (prefix, firstname, lastname, street, city, pos
|
|||
if (acceptTerms) {
|
||||
cy.get('[data-cy="acceptedTerms-input"] > input').first().check({force: true}).then(() => {
|
||||
cy.get('[data-cy="acceptedTerms-input"] > input:checkbox').should('be.checked');
|
||||
});;
|
||||
}); ;
|
||||
}
|
||||
|
||||
cy.get('[data-cy="passwordConfirmation-input"]').type(passwordConfirmation);
|
||||
|
|
@ -167,3 +163,6 @@ Cypress.Commands.add('redeemCoupon', coupon => {
|
|||
cy.get('[data-cy="coupon-button"]').click();
|
||||
})
|
||||
|
||||
Cypress.Commands.add('assertStartPage', () => {
|
||||
cy.get('[data-cy=start-modules-list]').should('exist');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue