skillbox/client/cypress/integration/frontend/instruments/instruments-page.spec.js

96 lines
2.5 KiB
JavaScript

describe('Instruments Page', () => {
beforeEach(() => {
cy.setup();
const analyse = {
name: 'Analyse',
category: 'LANGUAGE_COMMUNICATION',
type: 'analyse',
};
const argumentation = {
name: 'Argumentation',
category: 'LANGUAGE_COMMUNICATION',
type: 'argumentation',
};
const ethik = {
name: 'Ethik',
category: 'SOCIETY',
type: 'ethik',
};
cy.mockGraphqlOps({
operations: {
MeQuery: {},
InstrumentsQuery: {
instruments: [
{
type: analyse,
title: 'Instrument: Analyse',
slug: 'analyse',
},
{
type: argumentation,
title: 'Instrument: Argumentation',
slug: 'argumentation',
},
{
type: ethik,
title: 'Instrument: Ethik',
slug: 'ethik',
}
],
},
InstrumentTypesQuery: {
instrumentTypes: [
analyse,
argumentation,
{
name: 'Beschreibung',
category: 'LANGUAGE_COMMUNICATION',
type: 'beschreibung',
},
ethik,
{
name: 'Identität und Sozialisation',
category: 'SOCIETY',
type: 'identitt-und-sozialisation',
},
],
},
},
});
});
it('opens the instruments page', () => {
cy.visit('instruments/');
cy.getByDataCy('instrument').should('have.length', 3);
cy.getByDataCy('filter-language-communication').click();
cy.getByDataCy('instrument').should('have.length', 2);
cy.getByDataCy('filter-society').click();
cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-interdisciplinary').click();
cy.getByDataCy('instrument').should('have.length', 0);
cy.getByDataCy('filter-analyse').click();
cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-ethik').click();
cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-all-instruments').click();
cy.getByDataCy('instrument').should('have.length', 3);
});
it('shows the correct instrument label', () => {
cy.visit('instruments/');
cy.getByDataCy('instrument').first().within(() => {
cy.getByDataCy('instrument-subheader').should('contain', 'Instrumente - Sprache & Kommunikation');
});
});
});