skillbox/client/cypress/integration/frontend/modules/assignment-in-module.spec.js

114 lines
2.4 KiB
JavaScript

import {getMinimalMe} from '../../../support/helpers';
// const operations = {
// MeQuery: getMinimalMe({isTeacher: false}),
// };
const MeQuery = getMinimalMe();
describe('Content Blocks', () => {
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
},
},
};
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');
});
it('does not see assignment input on mobile', () => {
cy.viewport('iphone-8');
cy.getByDataCy('submission-textarea').should('not.be.visible');
});
});
/*
cy.task('getSchema').then(schemaString => {
cy.intercept('POST', '/api/graphql', (req) => {
// if (hasOperationName('MeQuery')) {
// graphql()
const schema = makeExecutableSchema({
typeDefs: schemaString,
});
const preserveResolvers = true;
const mocks = {
...defaultMocks,
module: {
title: 'I am a custom Title!'
}
};
const schemaWithMocks = addMocksToSchema({
schema,
preserveResolvers,
mocks,
});
const {query} = req.body;
console.log(req.body);
graphql({
schema: schemaWithMocks,
source: query,
}).then(result => {
console.log(result);
req.reply(result);
});
// }
});
});
*/