From 193614872d2f6fca639f71e288d20fecc610536f Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Fri, 15 Jul 2022 16:34:18 +0200 Subject: [PATCH] Update and rename test, hide assignment input on mobile Relates to MS-534 --- .../modules/assignment-in-module.spec.js | 113 ++++++++++++++++++ .../modules/content-blocks-mobile.spec.js | 54 --------- .../assignment/SubmissionForm.vue | 5 + 3 files changed, 118 insertions(+), 54 deletions(-) create mode 100644 client/cypress/integration/frontend/modules/assignment-in-module.spec.js delete mode 100644 client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js diff --git a/client/cypress/integration/frontend/modules/assignment-in-module.spec.js b/client/cypress/integration/frontend/modules/assignment-in-module.spec.js new file mode 100644 index 00000000..3af02805 --- /dev/null +++ b/client/cypress/integration/frontend/modules/assignment-in-module.spec.js @@ -0,0 +1,113 @@ +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); + }); + + // } + }); + }); + */ diff --git a/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js b/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js deleted file mode 100644 index b045fd5c..00000000 --- a/client/cypress/integration/frontend/modules/content-blocks-mobile.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -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/src/components/content-blocks/assignment/SubmissionForm.vue b/client/src/components/content-blocks/assignment/SubmissionForm.vue index adf6ffae..8dd364f3 100644 --- a/client/src/components/content-blocks/assignment/SubmissionForm.vue +++ b/client/src/components/content-blocks/assignment/SubmissionForm.vue @@ -127,6 +127,11 @@ margin-bottom: $medium-spacing; + display: none; + @include desktop { + display: block; + } + &__inputs { margin-bottom: 12px; }