116 lines
2.6 KiB
JavaScript
116 lines
2.6 KiB
JavaScript
import mocks from '../../../fixtures/mocks';
|
|
import minimalModule from '../../../fixtures/module.minimal';
|
|
|
|
const module = {
|
|
...minimalModule,
|
|
chapters: [
|
|
{
|
|
contentBlocks: [
|
|
{
|
|
type: 'task',
|
|
contents: [
|
|
{
|
|
type: 'text_block',
|
|
value: {
|
|
text: 'hallo velo',
|
|
},
|
|
id: 'bla-123',
|
|
},
|
|
{
|
|
type: 'assignment',
|
|
value: {
|
|
title: 'assignment-title',
|
|
assignment: 'assignment-assignment',
|
|
id: 'some-assignment',
|
|
},
|
|
id: '123-456',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
const myText = 'submission text';
|
|
|
|
const getOperations = ({final, readOnly}) => ({
|
|
MeQuery: {
|
|
me: {
|
|
onboardingVisited: true,
|
|
readOnly
|
|
},
|
|
},
|
|
ModuleDetailsQuery: {
|
|
module,
|
|
},
|
|
AssignmentQuery: {
|
|
assignment: {
|
|
submission: {
|
|
text: myText,
|
|
final,
|
|
document: '',
|
|
submissionFeedback: null
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
describe('Assignments read-only - Student', () => {
|
|
beforeEach(() => {
|
|
cy.fakeLogin('rahel.cueni', 'test');
|
|
cy.server();
|
|
cy.task('getSchema').then(schema => {
|
|
cy.mockGraphql({
|
|
schema,
|
|
mocks
|
|
});
|
|
});
|
|
});
|
|
|
|
it('can edit and turn in', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOperations({final: false, readOnly: false})
|
|
});
|
|
cy.visit('module/module-with-assignment');
|
|
|
|
cy.get('.submission-form__textarea').as('textarea');
|
|
|
|
cy.get('@textarea').invoke('val').should('contain', myText);
|
|
cy.get('@textarea').clear().type('Hello');
|
|
cy.get('@textarea').should('not.have.attr', 'readonly');
|
|
|
|
cy.getByDataCy('submission-form-submit').should('exist');
|
|
});
|
|
|
|
it('can not edit or turn in', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOperations({final: false, readOnly: true})
|
|
});
|
|
cy.visit('module/module-with-assignment');
|
|
|
|
cy.isSubmissionReadOnly(myText);
|
|
cy.canReopen(false);
|
|
});
|
|
|
|
it('can revoke turn in', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOperations({final: true, readOnly: false})
|
|
});
|
|
|
|
cy.visit('module/module-with-assignment');
|
|
cy.getByDataCy('final-submission').should('exist');
|
|
cy.getByDataCy('final-submission-reopen').should('exist');
|
|
});
|
|
|
|
it('can not revoke turn in', () => {
|
|
cy.mockGraphqlOps({
|
|
operations: getOperations({final: true, readOnly: true})
|
|
});
|
|
|
|
cy.visit('module/module-with-assignment');
|
|
cy.getByDataCy('final-submission').should('exist');
|
|
cy.canReopen(false);
|
|
});
|
|
});
|