Add test for read only mode in room
This commit is contained in:
parent
9dbddac078
commit
462348dd32
|
|
@ -0,0 +1,70 @@
|
||||||
|
import mocks from '../../../fixtures/mocks';
|
||||||
|
|
||||||
|
const SELECTED_CLASS_ID = 'selectedClassId';
|
||||||
|
|
||||||
|
const getOperations = ({readOnly}) => ({
|
||||||
|
MeQuery: {
|
||||||
|
me: {
|
||||||
|
onboardingVisited: true,
|
||||||
|
readOnly,
|
||||||
|
isTeacher: true,
|
||||||
|
selectedClass: {
|
||||||
|
id: SELECTED_CLASS_ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RoomsQuery: {
|
||||||
|
rooms: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: {
|
||||||
|
id: '',
|
||||||
|
slug: '',
|
||||||
|
title: 'some room',
|
||||||
|
entryCount: 3,
|
||||||
|
appearance: 'red',
|
||||||
|
description: 'some description',
|
||||||
|
schoolClass: {
|
||||||
|
id: SELECTED_CLASS_ID,
|
||||||
|
name: 'bla',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('checkRoomReadOnly', (readOnly) => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({readOnly}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const exist = readOnly ? 'not.exist' : 'exist';
|
||||||
|
cy.visit('rooms');
|
||||||
|
cy.log('visit');
|
||||||
|
cy.get('.room-widget').should('exist');
|
||||||
|
cy.getByDataCy('add-room').should(exist);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Room Team Management - Read only', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.fakeLogin('nino.teacher', 'test');
|
||||||
|
cy.server();
|
||||||
|
cy.viewport('macbook-15');
|
||||||
|
cy.task('getSchema').then(schema => {
|
||||||
|
cy.mockGraphql({
|
||||||
|
schema,
|
||||||
|
mocks,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can edit room', () => {
|
||||||
|
cy.checkRoomReadOnly(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can not edit room', () => {
|
||||||
|
cy.checkRoomReadOnly(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -63,20 +63,9 @@ describe('School Class and Team Management - Read only', () => {
|
||||||
|
|
||||||
it('can see menu items', () => {
|
it('can see menu items', () => {
|
||||||
cy.checkSchoolClassTeamReadOnly(false);
|
cy.checkSchoolClassTeamReadOnly(false);
|
||||||
// cy.visit('me/class');
|
|
||||||
// cy.getByDataCy('group-list-name').should('exist').should('contain', selectedClassName);
|
|
||||||
// cy.getByDataCy('show-code-button').should('exist');
|
|
||||||
// cy.getByDataCy('edit-group-name-link').should('exist');
|
|
||||||
// cy.openSidebar();
|
|
||||||
// cy.getByDataCy('class-selection').click();
|
|
||||||
// cy.getByDataCy('current-class-name').should('exist');
|
|
||||||
// cy.getByDataCy('create-class-link').should('exist');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can not see menu items', () => {
|
it('can not see menu items', () => {
|
||||||
// cy.mockGraphqlOps({
|
|
||||||
// operations: getOperations({readOnly: true}),
|
|
||||||
// });
|
|
||||||
cy.checkSchoolClassTeamReadOnly(true);
|
cy.checkSchoolClassTeamReadOnly(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
return this.me.selectedClass.id;
|
return this.me.selectedClass.id;
|
||||||
},
|
},
|
||||||
canAddRoom() {
|
canAddRoom() {
|
||||||
return this.me.permissions.includes('users.can_manage_school_class_content');
|
return this.me.isTeacher && !this.me.readOnly;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue