From 5ae7dcbf21f0b9afedb299b2fd0ea8194ef6d8b2 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Fri, 15 Jul 2022 13:21:29 +0200 Subject: [PATCH] Update module test, add new test with experimental code --- .../modules/content-blocks-mobile.spec.js | 54 +++++++++++++++++++ .../modules/custom-content-block.spec.js | 16 +++++- 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js diff --git a/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js b/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js new file mode 100644 index 00000000..b045fd5c --- /dev/null +++ b/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js @@ -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'); + }); +}); diff --git a/client/cypress/integration/frontend/modules/custom-content-block.spec.js b/client/cypress/integration/frontend/modules/custom-content-block.spec.js index 0b415197..ad77fa22 100644 --- a/client/cypress/integration/frontend/modules/custom-content-block.spec.js +++ b/client/cypress/integration/frontend/modules/custom-content-block.spec.js @@ -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, });