const schema = require('../fixtures/schema.json'); const assignments = require('../fixtures/assignments.json'); const lohnModule = require('../fixtures/module.json'); const geldModule = require('../fixtures/module-geld.json'); describe('Current Module', () => { before(() => { cy.server(); cy.mockGraphql({ schema: schema, // endpoint: '/api/graphql' operations: { MeQuery: variables => { return { me: { 'lastModule': { // 'id': 'TW9kdWxlTm9kZToxNw==', 'slug': 'lohn-und-budget', '__typename': 'ModuleNode' }, '__typename': 'UserNode', 'permissions': [] } } }, AssignmentsQuery: { assignments }, ModulesQuery: variables => { let module; if (variables.slug === 'lohn-und-budget') { module = lohnModule; } else { module = geldModule } return { module } }, UpdateLastModule: variables => { let module; if (variables.input.id === 'TW9kdWxlTm9kZToxNw==') { module = lohnModule } else { module = geldModule } return { updateLastModule: { module, errors: null, __typename: 'UpdateLastModulePayload' } } } } }); }); it('is set correctly', () => { cy.viewport('macbook-15'); cy.apolloLogin('nico.zickgraf', 'test'); cy.visit('/book/topic/geld-und-kauf'); cy.contains('Modul 1').click(); cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget'); cy.get('[data-cy="home-link"]').click(); cy.get('[data-cy="current-module-link"]').click(); cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget'); cy.visit('/book/topic/geld-und-kauf'); cy.contains('Modul 2').click(); 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') }) });