diff --git a/client/cypress/integration/e2e/new-student.spec.js b/client/cypress/integration/e2e/new-student.spec.js deleted file mode 100644 index 7d51c27b..00000000 --- a/client/cypress/integration/e2e/new-student.spec.js +++ /dev/null @@ -1,57 +0,0 @@ -import {mockUpdateOnboardingProgress} from '../../support/helpers'; - -const me = require('../../fixtures/me.new-student.json'); - -describe('New student', () => { - before(() => { - cy.server(); - cy.task('getSchema').then(schema => { - cy.mockGraphql({ - schema, - }); - }); - }); - - // todo: unskip me - it('shows "Enter Code" page and adds the user to a class', () => { - cy.apolloLogin('hansli', 'test'); - - const name = 'KF1A'; - const id = 'U2Nob29sQ2xhc3NOb2RlOjI='; - - cy.mockGraphqlOps({ - operations: { - MeQuery: me, - JoinClass: { - joinClass: { - success: true, - schoolClass: { - id, - name, - }, - }, - }, - MySchoolClassQuery: { - me: { - ...me.me, - selectedClass: { - name, - id, - members: [], - }, - }, - }, - ...mockUpdateOnboardingProgress(), - }, - }); - - cy.visit('/'); - cy.get('[data-cy=join-form-title]').should('contain', 'Einer Klasse beitreten'); - cy.get('[data-cy=join-code-input]').type('XXXX'); - cy.get('[data-cy=join-form-confirm]').click(); - cy.getByDataCy('onboarding-skip-link').click(); - cy.get('[data-cy=user-widget-avatar]').click(); - cy.get('[data-cy=class-list-link]').click(); - cy.get('[data-cy=group-list-title]').should('contain', 'Klassenliste'); - }); -}); diff --git a/client/cypress/integration/frontend/new-student.spec.js b/client/cypress/integration/frontend/new-student.spec.js new file mode 100644 index 00000000..517cec6c --- /dev/null +++ b/client/cypress/integration/frontend/new-student.spec.js @@ -0,0 +1,82 @@ +import {getMinimalMe} from '../../support/helpers'; + +// const me = require('../../fixtures/me.new-student.json'); + +describe('New student', () => { + before(() => { + cy.setup(); + }); + + // todo: unskip me + it.skip('shows "Enter Code" page and adds the user to a class', () => { + const {me} = getMinimalMe({isTeacher: false}); + + let onboardingVisited = false; + let selectedClass; + let schoolClasses = []; + + const name = 'KF1A'; + const id = 'selectedClassId'; + + console.log('me', me); + + const getSelectedClass = () => { + return selectedClass; + }; + + const getMe = () => { + return { + ...me, + onboardingVisited, + schoolClasses: {edges: schoolClasses}, + selectedClass: getSelectedClass(), + }; + }; + + console.log('getMe()', getMe()); + + cy.mockGraphqlOps({ + operations: { + MeQuery() { + return { + me: getMe(), + }; + }, + JoinClass() { + console.log('joining class'); + selectedClass = { + id, + name, + }; + schoolClasses.push(selectedClass); + return { + joinClass: { + success: true, + schoolClass: selectedClass, + }, + }; + }, + MySchoolClassQuery: { + me: getMe(), + }, + UpdateOnboardingProgress: () => { + onboardingVisited = true; + return { + updateOnboardingProgress: { + success: true, + }, + }; + }, + }, + }); + + cy.visit('/'); + cy.get('[data-cy=join-form-title]').should('contain', 'Einer Klasse beitreten'); + cy.get('[data-cy=join-form-input]').type('XXXX'); + cy.get('[data-cy=join-form-confirm]').click(); + cy.getByDataCy('onboarding-skip-link').click(); + cy.get('[data-cy=user-widget-avatar]').click(); + cy.get('[data-cy=class-list-link]').click(); + cy.get('[data-cy=group-list-title]').should('contain', 'Klassenliste'); + }); +});