Fix room test

This commit is contained in:
Ramon Wenger 2021-08-18 22:11:32 +02:00
parent 5785077edd
commit 33b476fcb0
3 changed files with 70 additions and 24 deletions

View File

@ -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: [],
}),
};

View File

@ -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: {

View File

@ -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');
});
});