diff --git a/client/cypress/integration/solutions.spec.js b/client/cypress/integration/solutions.spec.js index 8d9c2e9f..05a71600 100644 --- a/client/cypress/integration/solutions.spec.js +++ b/client/cypress/integration/solutions.spec.js @@ -1,5 +1,5 @@ // todo: reenable with a script that does the mutations, or with a workaround for fetch request checking in cypress -// describe('Solutions', () => { +describe('Solutions', () => { // // it('does not display the solution at first, then displays them after clicking', () => { // // cy.viewport('macbook-15'); // // cy.login('nico.zickgraf', 'test'); @@ -7,51 +7,55 @@ // // cy.visit('/module/lohn-und-budget'); // // }); // -// it('toggles the solution as teacher, then the student can display it', () => { -// // cy.server(); -// cy.login('nico.zickgraf', 'test'); -// cy.visit('/module/lohn-und-budget'); -// // cy.route('POST', '/api/graphql/').as('graphQL'); -// // does not work with cypress yet, because of the fetch api -// // https://github.com/cypress-io/cypress/issues/95 -// cy.get('[data-cy=toggle-enable-solutions]').within(() => { -// cy.get('input[type=checkbox]').uncheck({force: true}); -// cy.wait(2000); -// }); -// cy.logout(); -// -// cy.login('rahel.cueni', 'test'); -// cy.visit('/module/lohn-und-budget'); -// cy.get('[data-cy=toggle-enable-solutions]') -// .should('not.exist'); -// cy.get('[data-cy=solution]').should('not.exist'); -// cy.logout(); -// -// cy.login('nico.zickgraf', 'test'); -// cy.visit('/module/lohn-und-budget'); -// cy.get('[data-cy=toggle-enable-solutions]').within(() => { -// cy.get('input[type=checkbox]').check({force: true}); -// cy.wait(2000); -// // cy.wait('@graphQL'); -// }); -// -// cy.logout(); -// -// cy.login('rahel.cueni', 'test'); -// cy.visit('/module/lohn-und-budget'); -// // cy.get('[data-cy=solution]').should('exist'); -// cy.get('[data-cy=solution]').first() -// .should('contain', 'anzeigen') -// .should('not.contain', 'Lösungssatz') -// .then($solution => { -// cy.wrap($solution).within(() => { -// cy.get('[data-cy=show-solution]').click(); -// }); -// cy.wrap($solution) -// .should('contain', 'Lösungssatz') -// .should('contain', 'ausblenden'); -// }); -// -// -// }); -// }); + it('toggles the solution as teacher, then the student can display it', () => { + cy.server(); + cy.exec("python ../server/manage.py hidesolutions"); + // cy.login('nico.zickgraf', 'test'); + // cy.visit('/module/lohn-und-budget'); + cy.route('POST', '/api/graphql/').as('graphQL'); + // does not work with cypress yet, because of the fetch api + // https://github.com/cypress-io/cypress/issues/95 + // cy.get('[data-cy=toggle-enable-solutions]').within(() => { + // cy.get('input[type=checkbox]').uncheck({force: true}); + // // cy.wait(2000); + // cy.wait('@graphQL'); + // }); + // cy.logout(); + + cy.login('rahel.cueni', 'test'); + cy.visit('/module/lohn-und-budget'); + cy.get('[data-cy=toggle-enable-solutions]') + .should('not.exist'); + cy.get('[data-cy=solution]').should('not.exist'); + cy.logout(); + + cy.login('nico.zickgraf', 'test'); + cy.visit('/module/lohn-und-budget'); + cy.get('[data-cy=toggle-enable-solutions]').click(); + cy.waitFor('UpdateSolutionVisibility'); + // cy.get('[data-cy=toggle-enable-solutions]').within(() => { + // cy.get('input[type=checkbox]').check({force: true}); + // cy.wait(2000); + + // }); + + cy.logout(); + + cy.login('rahel.cueni', 'test'); + cy.visit('/module/lohn-und-budget'); + // cy.get('[data-cy=solution]').should('exist'); + cy.get('[data-cy=solution]').first() + .should('contain', 'anzeigen') + .should('not.contain', 'Lösungssatz') + .then($solution => { + cy.wrap($solution).within(() => { + cy.get('[data-cy=show-solution]').click(); + }); + cy.wrap($solution) + .should('contain', 'Lösungssatz') + .should('contain', 'ausblenden'); + }); + + + }); +});