diff --git a/client/cypress/fixtures/mocks.js b/client/cypress/fixtures/mocks.js index 272bee86..66338361 100644 --- a/client/cypress/fixtures/mocks.js +++ b/client/cypress/fixtures/mocks.js @@ -66,8 +66,8 @@ export default { ], }, recentModules: { - edges: [] - } + edges: [], + }, }), SchoolClassNode: () => ({ readOnly: false, @@ -93,7 +93,20 @@ export default { }), TopicNode: () => ({ modules: { - edges: [] - } - }) + edges: [], + }, + }), + RoomNode: () => ({ + title: 'A Room', + entryCount: 3, + appearance: 'blue', + description: 'A Room description', + schoolClass: { + id: 'selectedClassId', + }, + }), + RoomEntryNode: () => ({ + title: 'A Room Entry', + contents: [], + }), }; diff --git a/client/cypress/integration/frontend/onboarding.spec.js b/client/cypress/integration/frontend/onboarding.spec.js index 1ce78979..d21419c4 100644 --- a/client/cypress/integration/frontend/onboarding.spec.js +++ b/client/cypress/integration/frontend/onboarding.spec.js @@ -4,18 +4,10 @@ const me = require('../../fixtures/me.join-class.json'); describe('Onboarding', () => { beforeEach(() => { - cy.server(); - - cy.task('getSchema').then(schema => { - cy.mockGraphql({ - schema, - }); - }); + cy.setup(); }); it('shows the onboarding steps and finishes them', () => { - cy.fakeLogin('hansli', 'test'); - cy.mockGraphqlOps({ operations: { MeQuery: { diff --git a/client/cypress/integration/frontend/rooms/room-page.spec.js b/client/cypress/integration/frontend/rooms/room-page.spec.js index af05d961..35920468 100644 --- a/client/cypress/integration/frontend/rooms/room-page.spec.js +++ b/client/cypress/integration/frontend/rooms/room-page.spec.js @@ -1,20 +1,61 @@ -describe('The Room Page', () => { - it('displays new room entry with author name', () => { - // todo: mock all the graphql queries and mutations +import {getMinimalMe} from '../../../support/helpers'; - cy.viewport('macbook-15'); - cy.apolloLogin('rachel.green', 'test'); - cy.visit('/room/ein-historisches-festival'); +describe('The Room Page', () => { + const entryText = 'something should be here'; + const entryTitle = 'some title'; + const slug = 'ein-historisches-festival'; + + const operations = { + MeQuery: getMinimalMe({}), + RoomEntriesQuery: { + room: { + slug, + roomEntries: { + edges: [], + }, + }, + }, + AddRoomEntry: { + addRoomEntry: { + roomEntry: { + title: entryTitle, + contents: [ + { + type: 'text_block', + value: { + text: entryText + } + } + ], + author: { + firstName: 'Rachel', + lastName: 'Green', + id: 'rachels-id', + }, + }, + errors: [], + }, + }, + }; + + beforeEach(() => { + cy.setup(); + }); + + it('displays new room entry with author name', () => { + cy.mockGraphqlOps({ + operations, + }); + cy.visit(`/room/${slug}`); cy.get('[data-cy=add-room-entry-button]').click(); cy.get('.add-content-element:first-of-type').click(); cy.get('[data-cy=choose-text-widget]').click(); - cy.get('[data-cy=modal-title-input] > .modal-input__inputfield').type('some title'); + cy.get('[data-cy=modal-title-input] > .modal-input__inputfield').type(entryTitle); - let text = 'something should be here'; - cy.get('[data-cy=text-form-input]').type(text); + cy.get('[data-cy=text-form-input]').type(entryText); cy.get('[data-cy=modal-save-button]').click(); - cy.get('.room-entry__content:first').should('contain', text).should('contain', 'Rachel Green'); + cy.get('.room-entry__content:first').should('contain', entryText).should('contain', 'Rachel Green'); }); });