From 7d9da414d8b4da7b43faeb3186c7610aa1b508c0 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 24 May 2022 17:20:23 +0200 Subject: [PATCH] Make new tests pass --- .../frontend/instruments/module-page.spec.js | 68 +++++++++++++++++-- client/src/components/ContentBlock.vue | 2 + .../instruments/InstrumentEntry.vue | 5 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/client/cypress/integration/frontend/instruments/module-page.spec.js b/client/cypress/integration/frontend/instruments/module-page.spec.js index fc6ba35c..a2594cfc 100644 --- a/client/cypress/integration/frontend/instruments/module-page.spec.js +++ b/client/cypress/integration/frontend/instruments/module-page.spec.js @@ -1,10 +1,70 @@ +import {getMinimalMe} from '../../../support/helpers'; +import minimalModule from '../../../fixtures/module.minimal'; + +const {me: minimalMe} = getMinimalMe({}); + describe('Instruments on Module page', () => { + beforeEach(() => { + console.log('setting up'); + cy.setup(); + cy.mockGraphqlOps({ + operations: { + UpdateLastModule: { + updateLastModule: { + success: true, + }, + }, + MeQuery: { + me: minimalMe, + }, + ModuleDetailsQuery: { + module: { + ...minimalModule, + slug: 'module-with-instrument', + chapters: [ + { + title: 'Some Chapter', + contentBlocks: [ + { + 'type': 'base_communication', + 'title': 'Das Interview', + 'contents': [ + { + 'type': 'basic_knowledge', + 'value': { + 'description': '

Ein Interview dient dazu, durch Befragung Informationen zu ermitteln. Bei journalistischen Interviews werden oft Expertinnen und Experten befragt, aber auch Personen.

', + }, + }, + ], + }, + { + 'type': 'normal', + 'title': 'Normaler Block', + 'contents': [ + { + type: 'text_block', + value: { + text: 'Some text, not an instrument' + } + } + ] + } + ], + }, + ], + }, + }, + }, + }); + }); it('shows the correct instrument label', () => { - cy.visit('modules/module-with-instrument'); - cy.getByDataCy('instrument').first().within(() => { - cy.getByDataCy('instrument-subheader').should('contain', 'Instrumente - Sprache & Kommunikation'); + cy.visit('module/module-with-instrument'); + cy.getByDataCy('content-block').first().within(() => { + cy.getByDataCy('instrument-label').should('contain', 'Instrumente - Sprache & Kommunikation'); + }); + cy.getByDataCy('content-block').eq(1).within(() => { + cy.getByDataCy('instrument-label').should('not.exist'); }); // also check that other content blocks don't have the label }); - }); diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue index d56a10c8..4443ac7e 100644 --- a/client/src/components/ContentBlock.vue +++ b/client/src/components/ContentBlock.vue @@ -6,6 +6,7 @@
{{ instrumentLabel }} diff --git a/client/src/components/instruments/InstrumentEntry.vue b/client/src/components/instruments/InstrumentEntry.vue index f93bad69..64ee5320 100644 --- a/client/src/components/instruments/InstrumentEntry.vue +++ b/client/src/components/instruments/InstrumentEntry.vue @@ -3,7 +3,10 @@ :class="typeClass" class="instrument-entry" > -