import minimalMe from '../../fixtures/me.minimal'; import module from '../../fixtures/module.minimal'; import mocks from '../../fixtures/mocks'; const me = isTeacher => ({ ...minimalMe, isTeacher, }); const operations = isTeacher => ({ operations: { MeQuery: { me: me(isTeacher), }, ModuleDetailsQuery: { module, }, CreateSnapshot: { createSnapshot: { snapshot: { id: '', title: '', created: '', creator: '', }, success: true, }, }, ModuleSnapshotsQuery: { module: { ...module, snapshots: [ { id: 'snapshot-id', title: 'title', created: '2020-01-01', mine: true, shared: false, creator: 'me', }, ], }, }, }, }); describe('Snapshot', () => { beforeEach(() => { cy.server(); cy.task('getSchema').then(schema => { cy.mockGraphql({ schema, mocks, }); }); cy.viewport('macbook-15'); }); it('Menu is visible for teacher', () => { cy.fakeLogin('nico.zickgraf', 'test'); cy.mockGraphqlOps(operations(true)); cy.visit('module/miteinander-reden/'); cy.getByDataCy('snapshot-menu').should('be.visible'); }); it('Menu is not visible for student', () => { cy.fakeLogin('rahel.cueni', 'test'); cy.mockGraphqlOps(operations(false)); cy.visit('module/miteinander-reden/'); cy.getByDataCy('module-title').should('be.visible'); cy.getByDataCy('snapshot-menu').should('not.exist'); }); it.only('Creates Snapshot', () => { cy.fakeLogin('nico.zickgraf', 'test'); cy.mockGraphqlOps(operations(true)); cy.visit('module/miteinander-reden/'); cy.getByDataCy('module-snapshots-button').click(); cy.getByDataCy('create-snapshot-button').click(); cy.getByDataCy('show-all-snapshots-button').click(); cy.getByDataCy('snapshot-list').should('exist').within(() => { cy.get('.snapshots__snapshot').should('have.length', 1); }); }); it('Applies Snapshot', () => { cy.fakeLogin('nico.zickgraf', 'test'); cy.mockGraphqlOps(operations(true)); cy.visit('module/miteinander-reden/snapshots'); cy.get('Not Implemented'); }); });