const assignments = require('../../fixtures/assignments.json'); const mePayload = require('../../fixtures/me.join-class.json'); const topics = require('../../fixtures/topics.json'); const baseTopic = require('../../fixtures/geld-und-kauf.json'); const moduleTeasers = require('../../fixtures/module-teasers.json'); const fullModules = require('../../fixtures/full-modules.json'); const topic = { topic: { ...baseTopic.topic, modules: { '__typename': 'ModuleNodeConnection', edges: [ ...Object.values(moduleTeasers).map(module => { return { node: module, __typename: 'ModuleNodeEdge', }; }), ], }, }, }; const me = { ...mePayload.me, lastModule: { // 'id': 'TW9kdWxlTm9kZToxNw==', 'slug': 'lohn-und-budget', '__typename': 'ModuleNode', }, lastTopic: { 'id': 'VG9waWNOb2RlOjU=', 'slug': 'geld-und-kauf', '__typename': 'TopicNode', }, recentModules: { 'edges': [], '__typename': 'ModuleNodeConnection', }, }; const operations = { MeQuery: variables => { return { me: { ...me, '__typename': 'UserNode', 'permissions': [], }, }; }, AssignmentsQuery: { assignments, }, ModulesQuery: variables => { return { module: fullModules[variables.slug], }; }, TopicsQuery: topics, Topic: topic, UpdateLastTopic: { 'updateLastTopic': { 'topic': topic.topic, '__typename': 'UpdateLastTopicPayload', }, }, UpdateLastModule: variables => { return { updateLastModule: { lastModule: moduleTeasers[variables.input.id], __typename: 'UpdateLastModulePayload', }, }; }, }; Cypress.Commands.add('checkHome', (n, skipHome) => { if (!skipHome) { cy.get('[data-cy="home-link"]').click(); } cy.get('[data-cy=start-modules-list]').should('exist'); cy.get('[data-cy=start-module-teaser]').should('have.length', n); }); Cypress.Commands.add('goToModule', (topicTitle, moduleMetaTitle) => { cy.get('[data-cy=open-sidebar-link]').click(); cy.contains(topicTitle).click(); cy.get('[data-cy=topic-title]').should('exist').should('contain', topicTitle); cy.contains(moduleMetaTitle).click(); }); describe('Current Module', () => { before(() => { cy.server(); cy.task('getSchema').then(schema => { cy.mockGraphql({ schema, // endpoint: '/api/graphql' // mocks, operations, }); }); // cy.mockGraphql({ // schema: schema, // // endpoint: '/api/graphql' // operations, // }); }); // it('is set correctly', () => { // cy.viewport('macbook-15'); // // cy.fakeLogin('ross.geller', 'test'); // // cy.apolloLogin('ross.geller', 'test'); // cy.visit('/'); // // // module list exists, but does not have anything in it // cy.checkHome(0, true); // cy.get('[data-cy=no-modules-yet]').should('exist').should('contain', 'Sie haben sich noch kein Modul angeschaut. Legen Sie jetzt los!'); // // cy.goToModule('Geld und Kauf', 'Modul 2'); // cy.get('[data-cy=module-title]').should('contain', 'Geld'); // cy.checkHome(1); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld'); // // cy.goToModule('Geld und Kauf', 'Modul 1'); // cy.get('[data-cy=module-title]').should('contain', 'Lohn und Budget'); // cy.checkHome(2); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lohn und Budget'); // cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld'); // // cy.goToModule('Geld und Kauf', 'Modul 4'); // cy.get('[data-cy=module-title]').should('contain', 'Lerntipps'); // cy.checkHome(3); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lerntipps'); // cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Lohn und Budget'); // cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Geld'); // // // module list is full, should switch only the order around // cy.goToModule('Geld und Kauf', 'Modul 2'); // cy.get('[data-cy=module-title]').should('contain', 'Geld'); // cy.checkHome(3); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Geld'); // cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Lerntipps'); // cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lohn und Budget'); // // cy.goToModule('Geld und Kauf', 'Modul 5'); // cy.get('[data-cy=module-title]').should('contain', 'Random'); // cy.checkHome(3); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Random'); // cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Geld'); // cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Lerntipps'); // // cy.get('[data-cy=start-module-teaser]').last().click(); // cy.get('[data-cy=module-title]').should('contain', 'Lerntipps'); // cy.checkHome(3); // cy.get('[data-cy=start-module-teaser]').first().should('contain', 'Lerntipps'); // cy.get('[data-cy=start-module-teaser]').eq(1).should('contain', 'Random'); // cy.get('[data-cy=start-module-teaser]').eq(2).should('contain', 'Geld'); // }); });