71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
import mocks from '../../../fixtures/mocks';
|
|
|
|
const selectedClassName = 'My Class';
|
|
|
|
const getOperations = ({readOnly}) => ({
|
|
MeQuery: {
|
|
me: {
|
|
readOnly,
|
|
isTeacher: true,
|
|
},
|
|
},
|
|
MySchoolClassQuery: {
|
|
me: {
|
|
readOnly,
|
|
isTeacher: true,
|
|
selectedClass: {
|
|
name: selectedClassName,
|
|
code: 'XXXX',
|
|
members: [
|
|
{
|
|
id: 'id',
|
|
firstName: 'Me',
|
|
lastName: 'Myson',
|
|
isTeacher: true,
|
|
active: true,
|
|
isMe: true,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const checkSchoolClassTeamReadOnly = (readOnly) => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOperations({readOnly}),
|
|
});
|
|
|
|
const exist = readOnly ? 'not.exist' : 'exist';
|
|
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);
|
|
cy.getByDataCy('my-team-link').should(exist);
|
|
};
|
|
|
|
describe('School Class and Team Management - Read only', () => {
|
|
beforeEach(() => {
|
|
cy.fakeLogin('rachel.green', 'test');
|
|
cy.server();
|
|
cy.task('getSchema').then(schema => {
|
|
cy.mockGraphql({
|
|
schema,
|
|
mocks,
|
|
});
|
|
});
|
|
});
|
|
|
|
it('can see menu items', () => {
|
|
checkSchoolClassTeamReadOnly(false);
|
|
});
|
|
|
|
it('can not see menu items', () => {
|
|
checkSchoolClassTeamReadOnly(true);
|
|
});
|
|
});
|