Add test for current module

This commit is contained in:
Ramon Wenger 2019-04-11 14:09:00 +02:00
parent afe29f3f0c
commit 09d20e346d
7 changed files with 30 additions and 4 deletions

View File

@ -0,0 +1,22 @@
describe('Current Module', () => {
it('is set correctly', () => {
// cy.route('POST', '/api/graphql/').as('graphQL');
cy.startGraphQLCapture();
cy.login('nico.zickgraf', 'test');
cy.visit('/module/lohn-und-budget');
cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget')
cy.visit('/');
cy.waitFor('MeQuery');
cy.get('[data-cy="current-module-link"]').click();
cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget')
cy.visit('/module/geld');
cy.get('[data-cy=module-title]').should('contain', 'Geld')
cy.get('[data-cy="home-link"]').click();
cy.get('[data-cy="current-module-link"]').click();
cy.get('[data-cy=module-title]').should('contain', 'Geld')
})
})

View File

@ -8,10 +8,8 @@ describe('Solutions', () => {
// // });
//
it('toggles the solution as teacher, then the student can display it', () => {
cy.server();
cy.exec("python ../server/manage.py hidesolutions");
// cy.login('nico.zickgraf', 'test');
// cy.visit('/module/lohn-und-budget');
cy.startGraphQLCapture();
cy.route('POST', '/api/graphql/').as('graphQL');
// does not work with cypress yet, because of the fetch api
// https://github.com/cypress-io/cypress/issues/95

View File

@ -60,6 +60,11 @@ Cypress.Commands.add('loginByCsrf', (username, password, csrftoken) => {
});
});
Cypress.Commands.add('startGraphQLCapture', () => {
cy.server();
cy.route('POST', '/api/graphql/').as('graphQL');
});
// from https://stackoverflow.com/questions/53814647/how-can-i-alias-specific-graphql-requests-in-cypress
Cypress.Commands.add('waitFor', operationName => {
cy.wait('@graphQL').then(({request}) => {

View File

@ -1,6 +1,6 @@
<template>
<div class="mobile-header">
<router-link to="/">
<router-link to="/" data-cy="home-link">
<logo></logo>
</router-link>

View File

@ -10,6 +10,7 @@
class="start-sections__section"
title="Inhalte"
subtitle="Neues Wissen erwerben"
data-cy="current-module-link"
:link-text="moduleText"
:route="moduleRoute"
>