From 1f85defb2afcca28053b11c8660ec0c0013653b7 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 19 May 2021 12:59:14 +0200 Subject: [PATCH] Add 2 new frontend tests --- .graphqlrc | 1 + .../frontend/objectives-visibility.spec.js | 87 +++++++++++++++++++ .../integration/frontend/objectives.spec.js | 0 3 files changed, 88 insertions(+) create mode 100644 .graphqlrc create mode 100644 client/cypress/integration/frontend/objectives-visibility.spec.js create mode 100644 client/cypress/integration/frontend/objectives.spec.js diff --git a/.graphqlrc b/.graphqlrc new file mode 100644 index 00000000..b856c5cf --- /dev/null +++ b/.graphqlrc @@ -0,0 +1 @@ +schema: 'server/schema.graphql' diff --git a/client/cypress/integration/frontend/objectives-visibility.spec.js b/client/cypress/integration/frontend/objectives-visibility.spec.js new file mode 100644 index 00000000..d00fa7f4 --- /dev/null +++ b/client/cypress/integration/frontend/objectives-visibility.spec.js @@ -0,0 +1,87 @@ +import {getMe} from '../../support/helpers'; +import mocks from '../../fixtures/mocks'; + +const modules = { + 'lohn-und-budget': { + 'objectiveGroups': { + 'edges': [ + { + 'node': { + 'title': 'LANGUAGE_COMMUNICATION', + 'objectives': { + 'edges': [ + { + 'node': { + 'text': 'i-am-an-objective', + 'hiddenFor': { + 'edges': [], + }, + }, + }, + ], + }, + }, + }, + ], + }, + }, +}; + +const operations = { + MeQuery() { + return getMe({ + schoolClasses: ['FLID2018a'], + teacher: false, + }); + }, + ModulesQuery: modules, + MySchoolClassQuery: { + me: {}, + }, + UpdateLastModule: { + updateLastModule: { + success: true, + }, + }, + SyncModuleVisibility: { + syncModuleVisibility: { + success: true, + }, + }, +}; + +// const mocks = { +// UUID: () => 'Whatever', +// GenericStreamFieldType: () => [], +// ObjectiveGroup: () => ({}), +// Module: () => ({ +// title: 'title', +// slug: 'slug', +// metaTitle: 'metaTitle', +// teaser: 'teaser', +// intro: 'intro', +// assignments: {edges: []}, +// objectiveGroups: {edges: []}, +// id: 'ID', +// }), +// }; + +describe('Objective Visibility', () => { + beforeEach(() => { + cy.server(); + cy.task('getSchema').then(schema => { + cy.mockGraphql({ + schema, + // endpoint: '/api/graphql' + mocks, + operations, + }); + }); + }); + + it('should display the correct objectives', () => { + cy.fakeLogin('rahel.cueni', 'test'); + + cy.visit('/module/lohn-und-budget'); + }); +}); diff --git a/client/cypress/integration/frontend/objectives.spec.js b/client/cypress/integration/frontend/objectives.spec.js new file mode 100644 index 00000000..e69de29b