87 lines
2.2 KiB
JavaScript
87 lines
2.2 KiB
JavaScript
import {getMinimalMe} from '../../../support/helpers';
|
|
|
|
describe('The Rooms Page', () => {
|
|
const getOperations = (isTeacher) => ({
|
|
MeQuery: getMinimalMe({isTeacher}),
|
|
RoomsQuery: {
|
|
rooms: {
|
|
edges: [
|
|
{
|
|
node: {
|
|
schoolClass: {
|
|
id: 'selectedClassId',
|
|
},
|
|
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
});
|
|
|
|
const getOnboardingOperations = (isTeacher) => {
|
|
const operations = getOperations(isTeacher);
|
|
return {
|
|
...operations,
|
|
RoomsQuery: {
|
|
rooms: {
|
|
edges: [],
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
beforeEach(() => {
|
|
cy.setup();
|
|
});
|
|
|
|
it('shows the onboarding page', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOnboardingOperations(true),
|
|
});
|
|
|
|
cy.visit('/rooms');
|
|
cy.getByDataCy('page-title').should('contain', 'Räume');
|
|
cy.getByDataCy('rooms-onboarding-text').should('contain', 'Hier können Sie Räume erstellen');
|
|
cy.getByDataCy('page-footer').should('not.exist');
|
|
cy.getByDataCy('create-room-button').should('contain', 'Raum erstellen').click();
|
|
cy.url().should('include', 'new-room');
|
|
});
|
|
|
|
it('shows the onboarding page without button for student', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOnboardingOperations(false),
|
|
});
|
|
|
|
cy.visit('/rooms');
|
|
cy.getByDataCy('page-title').should('contain', 'Räume');
|
|
cy.getByDataCy('rooms-onboarding-text').should('contain', 'Hier können Sie Räume erstellen');
|
|
cy.getByDataCy('page-footer').should('not.exist');
|
|
cy.getByDataCy('create-room-button').should('not.exist');
|
|
});
|
|
|
|
it('goes to the rooms page', () => {
|
|
const operations = getOperations(true);
|
|
cy.mockGraphqlOps({
|
|
operations,
|
|
});
|
|
|
|
cy.visit('/rooms');
|
|
|
|
cy.getByDataCy('room-widget').should('have.length', 1);
|
|
cy.get('[data-cy=add-room]').should('exist');
|
|
});
|
|
|
|
it('add room should not exist for student', () => {
|
|
const operations = getOperations(false);
|
|
cy.mockGraphqlOps({
|
|
operations,
|
|
});
|
|
|
|
cy.visit('/rooms');
|
|
|
|
cy.getByDataCy('room-widget').should('have.length', 1);
|
|
cy.get('[data-cy=add-room]').should('not.exist');
|
|
});
|
|
});
|