Update module test, add new test with experimental code

This commit is contained in:
Ramon Wenger 2022-07-15 13:21:29 +02:00
parent ec3811b5a2
commit 5ae7dcbf21
2 changed files with 68 additions and 2 deletions

View File

@ -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');
});
});

View File

@ -9,7 +9,14 @@ const chapters = [{
title: 'A ContentBlock', title: 'A ContentBlock',
userCreated: true, userCreated: true,
mine: true, mine: true,
contents: [], contents: [
{
type: 'text_block',
value: {
text: 'Hello World'
}
}
],
}, },
], ],
}]; }];
@ -21,6 +28,11 @@ const operations = {
chapters, chapters,
}, },
}, },
ModuleEditModeQuery: {
module: {
slug: 'some-module',
}
},
DeleteContentBlock: { DeleteContentBlock: {
success: true, success: true,
}, },
@ -32,7 +44,7 @@ describe('Custom Content Block', () => {
cy.setup(); 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({ cy.mockGraphqlOps({
operations, operations,
}); });