98 lines
2.4 KiB
JavaScript
98 lines
2.4 KiB
JavaScript
import { getMinimalMe } from '../../../support/helpers';
|
|
|
|
// const operations = {
|
|
// MeQuery: getMinimalMe({isTeacher: false}),
|
|
// };
|
|
const MeQuery = getMinimalMe({ isTeacher: false });
|
|
|
|
describe('Assignment in Module', () => {
|
|
const slug = 'some-module';
|
|
const assignment = {
|
|
id: 'abc',
|
|
title: 'Some assignment',
|
|
assignment: 'Please write down your thoughts',
|
|
submission: null,
|
|
};
|
|
const module = {
|
|
title: 'Hello world',
|
|
slug,
|
|
solutionsEnabled: false,
|
|
chapters: [
|
|
{
|
|
contentBlocks: [
|
|
{
|
|
title: 'A content block',
|
|
contents: [
|
|
{
|
|
type: 'text_block',
|
|
value: {
|
|
text: 'Ein Text',
|
|
},
|
|
},
|
|
{
|
|
type: 'assignment',
|
|
value: assignment,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
const operations = {
|
|
ModuleDetailsQuery: {
|
|
module,
|
|
},
|
|
MeQuery,
|
|
ModuleEditModeQuery: {
|
|
module: {
|
|
slug,
|
|
},
|
|
},
|
|
UpdateLastModule: {
|
|
module,
|
|
},
|
|
AssignmentQuery: {
|
|
assignment,
|
|
},
|
|
UpdateAssignmentWithSuccess: {
|
|
updateAssignment: {
|
|
successful: true,
|
|
updatedAssignment: assignment,
|
|
},
|
|
},
|
|
UpdateAssignment({ input: { assignment: updatedAssignment } }) {
|
|
return {
|
|
updateAssignment: {
|
|
updatedAssignment: {
|
|
...assignment,
|
|
submission: {
|
|
final: updatedAssignment.final,
|
|
text: updatedAssignment.answer,
|
|
document: '',
|
|
},
|
|
},
|
|
},
|
|
};
|
|
},
|
|
};
|
|
beforeEach(() => {
|
|
cy.setup();
|
|
cy.mockGraphqlOps({ operations });
|
|
cy.visit(`module/${slug}`);
|
|
});
|
|
|
|
it('types into the assignment input', () => {
|
|
cy.getByDataCy('submission-textarea').should('exist').type('My Solution');
|
|
cy.getByDataCy('submission-form-submit').click();
|
|
cy.getByDataCy('submission-textarea').should('have.class', 'submission-form__textarea--readonly');
|
|
cy.getByDataCy('final-submission-reopen').click();
|
|
cy.getByDataCy('submission-textarea').should('not.have.class', 'submission-form__textarea--readonly');
|
|
});
|
|
|
|
it('does not see assignment input on mobile', () => {
|
|
cy.viewport('iphone-8');
|
|
cy.getByDataCy('submission-textarea').should('not.be.visible');
|
|
});
|
|
});
|