From 6b8b520bc58c5ce760e01f3e06d37394947cd28d Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Thu, 16 Jan 2020 16:07:00 +0100 Subject: [PATCH] Add test to check solution display in surveys --- client/cypress/integration/solutions.spec.js | 12 ++++++++++++ .../commands/prepare_surveys_for_cypress.py | 15 ++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/client/cypress/integration/solutions.spec.js b/client/cypress/integration/solutions.spec.js index 30242b92..2d3b48ba 100644 --- a/client/cypress/integration/solutions.spec.js +++ b/client/cypress/integration/solutions.spec.js @@ -27,6 +27,13 @@ describe('Solutions', () => { cy.get('[data-cy=toggle-enable-solutions]') .should('not.exist'); cy.get('[data-cy=solution]').should('not.exist'); + + cy.visit('/survey/U3VydmV5Tm9kZTox'); + + cy.get('.survey__page').should('exist'); + cy.get('[data-cy=solution]').should('not.exist'); + cy.get('.close-button').click(); + cy.logout(); cy.visit('/module/lohn-und-budget'); @@ -54,6 +61,11 @@ describe('Solutions', () => { .should('contain', 'ausblenden'); }); + cy.visit('/survey/U3VydmV5Tm9kZTox'); + + cy.get('.survey__page').should('exist'); + cy.get('[data-cy=solution]').should('exist'); + }); }); diff --git a/server/core/management/commands/prepare_surveys_for_cypress.py b/server/core/management/commands/prepare_surveys_for_cypress.py index a3cd8c3b..e7fb39e4 100644 --- a/server/core/management/commands/prepare_surveys_for_cypress.py +++ b/server/core/management/commands/prepare_surveys_for_cypress.py @@ -1,6 +1,7 @@ from django.core.management import BaseCommand from books.factories import ModuleFactory +from books.models import Module from portfolio.factories import ProjectFactory from portfolio.models import ProjectEntry from surveys.models import Survey @@ -17,13 +18,15 @@ survey_data = { { "name": "A: Max gibt ihr das Geld und muss das Billardspiel absagen.", "placeHolder": "Passende Tugenden erfassen...", - "type": "text" + "type": "text", + "correctAnswer": "Triss" }, { "name": "question2", "placeHolder": "Passende Tugenden erfassen...", "title": "B: Max gibt ihr das Geld nicht und geht Billard spielen.", - "type": "text" + "type": "text", + "correctAnswer": "Jaskier" } ], "name": "Fall 1", @@ -43,13 +46,15 @@ survey_data = { "placeHolder": "Passende Tugenden erfassen...", "title": "A: Silvio bringt seinen Mitfahrer in Sicherheit.", "type": "text", - "useDisplayValuesInTitle": False + "useDisplayValuesInTitle": False, + "correctAnswer": "Yennefer" }, { "name": "question3", "placeHolder": "Passende Tugenden erfassen...", "title": "B: Silvio sperrt die Strasse ab.", - "type": "text" + "type": "text", + "correctAnswer": "Geralt" } ], "name": "panel1", @@ -70,7 +75,7 @@ class Command(BaseCommand): Survey.objects.all().delete() self.stdout.write("Creating survey") - module = ModuleFactory() + module = Module.objects.get(slug='lohn-und-budget') Survey.objects.create( title='Test',