skillbox/client/cypress/integration/frontend/rooms/room-page.spec.js

100 lines
2.4 KiB
JavaScript

import {getMinimalMe} from '../../../support/helpers';
describe('The Room Page', () => {
const entryText = 'something should be here';
const entryTitle = 'some title';
const slug = 'ein-historisches-festival';
const id = btoa('RoomNode:1');
const room = {
id,
slug,
restricted: false,
roomEntries: {
edges: [],
},
};
const RoomEntriesQuery = {
room
};
const operations = {
MeQuery: getMinimalMe({}),
RoomEntriesQuery,
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(entryTitle);
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', entryText).should('contain', 'Rachel Green');
});
it.only('changes visibility of a room', () => {
const MeQuery = getMinimalMe({
isTeacher: true
});
const operations = {
MeQuery,
RoomEntriesQuery,
UpdateRoomVisibility: {
updateRoomVisibility: {
success: true,
room: {
...room,
restricted: true
}
}
}
};
cy.mockGraphqlOps({
operations,
});
cy.visit(`/room/${slug}`);
cy.getByDataCy('room-visibility-status').should('contain', 'alle Lernenden');
cy.getByDataCy('toggle-room-actions-menu').click();
cy.getByDataCy('change-visibility').click();
cy.getByDataCy('modal-title').should('contain', 'Sichtbarkeit anpassen');
cy.getByDataCy('select-option').eq(1).click();
cy.getByDataCy('modal-save-button').click();
cy.getByDataCy('room-visibility-status').should('contain', 'eigenen Beiträge');
});
});