import {login} from "./helpers"; describe("circle.cy.js", () => { beforeEach(() => { cy.manageCommand("cypress_reset"); login("test-student1@example.com", "test"); cy.visit("/course/test-lehrgang/learn/fahrzeug"); }); it("can open circle page", () => { cy.get("[data-cy=\"circle-title\"]").should("contain", "Fahrzeug"); }); it("can open learning contents and complete them by continuing", () => { cy.get( "[data-cy=\"test-lehrgang-lp-circle-fahrzeug-lc-verschaffe-dir-einen-überblick\"]" ).click(); cy.get("[data-cy=\"lc-title\"]").should( "contain", "Verschaffe dir einen Überblick" ); cy.get("[data-cy=\"complete-and-continue\"]").click({force: true}); cy.get("[data-cy=\"circle-title\"]").should("contain", "Fahrzeug"); // workaround for flaky test in CI: // for some strange reason, locally we don't have to do this // but in CI if we don't do this, the next click will not work... // => it's not great but this workaround at least gives us a stable test cy.visit("/course/test-lehrgang/learn/fahrzeug"); cy.get('[data-cy="ls-continue-button"]').click(); cy.get('[data-cy="lc-title"]').should( "contain", "Handlungsfeld «Fahrzeug»" ); cy.get("[data-cy=\"complete-and-continue\"]").click({force: true}); cy.get("[data-cy=\"circle-title\"]").should("contain", "Fahrzeug"); cy.get( "[data-cy=\"test-lehrgang-lp-circle-fahrzeug-lc-verschaffe-dir-einen-überblick-status\"]" ).should("have.attr", "aria-checked", "true"); cy.get( "[data-cy=\"test-lehrgang-lp-circle-fahrzeug-lc-handlungsfeld-fahrzeug-status\"]" ).should("have.attr", "aria-checked", "true"); }); it("continue button works", () => { cy.get("[data-cy=\"ls-continue-button\"]").should("contain", "Los geht's"); cy.get("[data-cy=\"ls-continue-button\"]").click(); cy.get("[data-cy=\"lc-title\"]").should( "contain", "Verschaffe dir einen Überblick" ); cy.get("[data-cy=\"complete-and-continue\"]").click({force: true}); cy.get("[data-cy=\"ls-continue-button\"]").should("contain", "Weiter geht's"); cy.get("[data-cy=\"ls-continue-button\"]").click(); cy.get("[data-cy=\"lc-title\"]").should( "contain", "Handlungsfeld «Fahrzeug»" ); }); it("can open learning content by url", () => { cy.visit("/course/test-lehrgang/learn/fahrzeug/handlungsfeld-fahrzeug"); cy.get("[data-cy=\"lc-title\"]").should( "contain", "Handlungsfeld «Fahrzeug»" ); cy.get("[data-cy=\"close-learning-content\"]").click(); cy.get("[data-cy=\"circle-title\"]").should("contain", "Fahrzeug"); }); it("checks number of sequences and contents", () => { cy.get("[data-cy=\"lp-learning-sequence\"]").should("have.length", 3); cy.get("[data-cy=\"lp-learning-sequence\"]") .first() .should("contain", "Vorbereitung"); cy.get("[data-cy=\"lp-learning-sequence\"]") .eq(1) .should("contain", "Training"); cy.get("[data-cy=\"lp-learning-sequence\"]") .last() .should("contain", "Transfer"); cy.get("[data-cy=\"lp-learning-content\"]").should("have.length", 10); cy.get("[data-cy=\"lp-learning-content\"]") .first() .should("contain", "Verschaffe dir einen Überblick"); cy.get("[data-cy=\"lp-learning-content\"]") .eq(4) .should("contain", "Präsenzkurs Fahrzeug"); cy.get("[data-cy=\"lp-learning-content\"]") .eq(7) .should("contain", "Reflexion"); cy.get("[data-cy=\"lp-learning-content\"]") .last() .should("contain", "Feedback"); cy.visit("/course/test-lehrgang/learn/reisen"); cy.get("[data-cy=\"lp-learning-sequence\"]").should("have.length", 4); cy.get("[data-cy=\"lp-learning-content\"]").should("have.length", 11); }); });