diff --git a/client/cypress/integration/current-module.spec.js b/client/cypress/integration/current-module.spec.js new file mode 100644 index 00000000..75592e8a --- /dev/null +++ b/client/cypress/integration/current-module.spec.js @@ -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') + }) +}) diff --git a/client/cypress/integration/home-page-logged-in-spec.js b/client/cypress/integration/home-page-logged-in.spec.js similarity index 100% rename from client/cypress/integration/home-page-logged-in-spec.js rename to client/cypress/integration/home-page-logged-in.spec.js diff --git a/client/cypress/integration/home-page-spec.js b/client/cypress/integration/home-page.spec.js similarity index 100% rename from client/cypress/integration/home-page-spec.js rename to client/cypress/integration/home-page.spec.js diff --git a/client/cypress/integration/solutions.spec.js b/client/cypress/integration/solutions.spec.js index 05a71600..8d5e475b 100644 --- a/client/cypress/integration/solutions.spec.js +++ b/client/cypress/integration/solutions.spec.js @@ -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 diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index 66477c4a..ebc97c6b 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -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}) => { diff --git a/client/src/components/MobileHeader.vue b/client/src/components/MobileHeader.vue index d30a2b0a..c4834894 100644 --- a/client/src/components/MobileHeader.vue +++ b/client/src/components/MobileHeader.vue @@ -1,6 +1,6 @@