Make new tests pass

This commit is contained in:
Ramon Wenger 2022-05-24 17:20:23 +02:00
parent ddf5360c51
commit 7d9da414d8
3 changed files with 70 additions and 5 deletions

View File

@ -1,10 +1,70 @@
import {getMinimalMe} from '../../../support/helpers';
import minimalModule from '../../../fixtures/module.minimal';
const {me: minimalMe} = getMinimalMe({});
describe('Instruments on Module page', () => { 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': '<p>Ein Interview dient dazu, durch Befragung Informationen zu ermitteln. Bei journalistischen Interviews werden oft Expertinnen und Experten befragt, aber auch Personen.</p>',
},
},
],
},
{
'type': 'normal',
'title': 'Normaler Block',
'contents': [
{
type: 'text_block',
value: {
text: 'Some text, not an instrument'
}
}
]
}
],
},
],
},
},
},
});
});
it('shows the correct instrument label', () => { it('shows the correct instrument label', () => {
cy.visit('modules/module-with-instrument'); cy.visit('module/module-with-instrument');
cy.getByDataCy('instrument').first().within(() => { cy.getByDataCy('content-block').first().within(() => {
cy.getByDataCy('instrument-subheader').should('contain', 'Instrumente - Sprache & Kommunikation'); 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 // also check that other content blocks don't have the label
}); });
}); });

View File

@ -6,6 +6,7 @@
<div <div
:class="specialClass" :class="specialClass"
class="content-block" class="content-block"
data-cy="content-block"
> >
<div <div
class="block-actions" class="block-actions"
@ -41,6 +42,7 @@
<h3 <h3
class="content-block__instrument-label" class="content-block__instrument-label"
data-cy="instrument-label"
v-if="instrumentLabel !== ''" v-if="instrumentLabel !== ''"
> >
{{ instrumentLabel }} {{ instrumentLabel }}

View File

@ -3,7 +3,10 @@
:class="typeClass" :class="typeClass"
class="instrument-entry" class="instrument-entry"
> >
<h4 class="instrument-entry__category"> <h4
class="instrument-entry__category"
data-cy="instrument-subheader"
>
{{ categoryName }} {{ categoryName }}
</h4> </h4>
<h3 class="instrument-entry__title"> <h3 class="instrument-entry__title">