Update module test, add new test with experimental code
This commit is contained in:
parent
ec3811b5a2
commit
5ae7dcbf21
|
|
@ -0,0 +1,54 @@
|
|||
import {graphql} from 'graphql';
|
||||
import {makeExecutableSchema} from '@graphql-tools/schema';
|
||||
import {addMocksToSchema} from '@graphql-tools/mock';
|
||||
import {addResolversToSchema} from '@graphql-tools/schema';
|
||||
import defaultMocks from '../../../fixtures/mocks';
|
||||
|
||||
// const operations = {
|
||||
// MeQuery: getMinimalMe({isTeacher: false}),
|
||||
// };
|
||||
|
||||
describe('Content Blocks', () => {
|
||||
beforeEach(() => {
|
||||
cy.fakeLogin('nino.teacher', 'test');
|
||||
cy.viewport('macbook-15');
|
||||
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);
|
||||
});
|
||||
|
||||
// }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('opens the module', () => {
|
||||
cy.visit('module/some-module');
|
||||
});
|
||||
});
|
||||
|
|
@ -9,7 +9,14 @@ const chapters = [{
|
|||
title: 'A ContentBlock',
|
||||
userCreated: true,
|
||||
mine: true,
|
||||
contents: [],
|
||||
contents: [
|
||||
{
|
||||
type: 'text_block',
|
||||
value: {
|
||||
text: 'Hello World'
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
}];
|
||||
|
|
@ -21,6 +28,11 @@ const operations = {
|
|||
chapters,
|
||||
},
|
||||
},
|
||||
ModuleEditModeQuery: {
|
||||
module: {
|
||||
slug: 'some-module',
|
||||
}
|
||||
},
|
||||
DeleteContentBlock: {
|
||||
success: true,
|
||||
},
|
||||
|
|
@ -32,7 +44,7 @@ describe('Custom Content Block', () => {
|
|||
cy.setup();
|
||||
});
|
||||
|
||||
it.skip('Deletes the custom content block and removes it from the view', () => {
|
||||
it('Deletes the custom content block and removes it from the view', () => {
|
||||
cy.mockGraphqlOps({
|
||||
operations,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue