Fix cypress test

This commit is contained in:
Ramon Wenger 2022-09-14 11:53:16 +02:00
parent 8d40c558f0
commit bd2acdc7c6
2 changed files with 60 additions and 27 deletions

View File

@ -1,34 +1,50 @@
const LANGUAGE_COMMUNICATION = 'LANGUAGE_COMMUNICATION';
const LANGUAGE_COMMUNICATION_VALUE = 'Sprache & Kommunikation';
const SOCIETY = 'SOCIETY';
const SOCIETY_VALUE = 'Gesellschaft';
const INTERDISCIPLINARY = 'INTERDISCIPLINARY';
const INTERDISCIPLINARY_VALUE = 'Überfachliche Instrumente';
describe('Instruments Page', () => { describe('Instruments Page', () => {
beforeEach(() => { beforeEach(() => {
cy.setup(); cy.setup();
const languageCategory = { const languageCategory = {
name: 'Sprache & Kommunikation', name: LANGUAGE_COMMUNICATION_VALUE,
id: 'LANGUAGE_COMMUNICATION', id: LANGUAGE_COMMUNICATION,
foreground: '#000000', foreground: '#000000',
background: '#00ffff' background: '#00ffff',
}; };
const societyCategory = { const societyCategory = {
name: 'Gesellschaft', name: SOCIETY_VALUE,
id: 'SOCIETY', id: SOCIETY,
foreground: '#ffffff', foreground: '#ffffff',
background: '#000fff' background: '#000fff',
}; };
const ANALYSE = 'analyse';
const ARGUMENTATION = 'argumentation';
const ETHIK = 'ethik';
const analyse = { const analyse = {
name: 'Analyse', name: 'Analyse',
category: languageCategory, category: languageCategory,
type: 'analyse', type: ANALYSE,
id: ANALYSE
}; };
const argumentation = { const argumentation = {
name: 'Argumentation', name: 'Argumentation',
category: languageCategory, category: languageCategory,
type: 'argumentation', type: ARGUMENTATION,
id: ARGUMENTATION
}; };
const ethik = { const ethik = {
name: 'Ethik', name: 'Ethik',
category: societyCategory, category: societyCategory,
type: 'ethik', type: ETHIK,
id: ETHIK
}; };
cy.mockGraphqlOps({ cy.mockGraphqlOps({
@ -50,23 +66,40 @@ describe('Instruments Page', () => {
type: ethik, type: ethik,
title: 'Instrument: Ethik', title: 'Instrument: Ethik',
slug: 'ethik', slug: 'ethik',
} },
], ],
}, },
InstrumentTypesQuery: { InstrumentCategoriesQuery: {
instrumentTypes: [ instrumentCategories: [
analyse,
argumentation,
{ {
name: 'Beschreibung', name: 'Sprache & Kommunikation',
category: languageCategory, id: LANGUAGE_COMMUNICATION,
type: 'beschreibung', types: [
analyse,
argumentation,
{
name: 'Beschreibung',
category: languageCategory,
type: 'beschreibung',
},
],
}, },
ethik,
{ {
name: 'Identität und Sozialisation', name: SOCIETY_VALUE,
category: societyCategory, id: SOCIETY,
type: 'identitt-und-sozialisation', types: [
ethik,
{
name: 'Identität und Sozialisation',
category: societyCategory,
type: 'identitt-und-sozialisation',
},
],
},
{
name: INTERDISCIPLINARY_VALUE,
id: INTERDISCIPLINARY,
types: [],
}, },
], ],
}, },
@ -79,19 +112,19 @@ describe('Instruments Page', () => {
cy.getByDataCy('instrument').should('have.length', 3); cy.getByDataCy('instrument').should('have.length', 3);
cy.getByDataCy('filter-language-communication').click(); cy.contains(LANGUAGE_COMMUNICATION_VALUE).click();
cy.getByDataCy('instrument').should('have.length', 2); cy.getByDataCy('instrument').should('have.length', 2);
cy.getByDataCy('filter-society').click(); cy.contains(SOCIETY_VALUE).click();
cy.getByDataCy('instrument').should('have.length', 1); cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-interdisciplinary').click(); cy.contains(INTERDISCIPLINARY_VALUE).click();
cy.getByDataCy('instrument').should('have.length', 0); cy.getByDataCy('instrument').should('have.length', 0);
cy.getByDataCy('filter-analyse').click(); cy.contains('Analyse').click();
cy.getByDataCy('instrument').should('have.length', 1); cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-ethik').click(); cy.contains('Ethik').click();
cy.getByDataCy('instrument').should('have.length', 1); cy.getByDataCy('instrument').should('have.length', 1);
cy.getByDataCy('filter-all-instruments').click(); cy.getByDataCy('filter-all-instruments').click();

View File

@ -1,4 +1,4 @@
query InstrumentTypesQuery { query InstrumentCategoriesQuery {
instrumentCategories { instrumentCategories {
name name
id id