import {login} from "../helpers"; const getDashboardStatistics = (what) => { return cy.get(`[data-cy="dashboard.stats.${what}"]`); }; const clickOnDetailsLink = (within) => { cy.get(`[data-cy="dashboard.stats.${within}"]`).within(() => { cy.get('[data-cy="basebox.detailsLink"]').click(); }) }; describe("dashboardSupervisor.cy.js", () => { beforeEach(() => { cy.manageCommand("cypress_reset --create-assignment-evaluation --create-feedback-responses --create-course-completion-performance-criteria --create-attendance-days"); login("test-supervisor1@example.com", "test"); cy.visit("/"); }); describe("attendance day summary box", () => { it("contains correct numbers", () => { getDashboardStatistics("attendance.dayCompleted").should("have.text", "1"); getDashboardStatistics("attendance.participantsPresent").should("have.text", "34%"); }); it("contains correct details link", () => { clickOnDetailsLink("attendance"); cy.url().should("contain", "/statistic/attendance"); // might be improved: roughly check // that the correct data is displayed cy.contains("Durchführung «Test Bern 2022 a»"); cy.contains("Circle «Fahrzeug»"); cy.contains("Termin: 31. Oktober 2000"); }); }); describe("overall summary box", () => { it("contains correct numbers (members, experts etc.)", () => { getDashboardStatistics("participant.count").should("have.text", "4"); getDashboardStatistics("expert.count").should("have.text", "1"); getDashboardStatistics("session.count").should("have.text", "2"); }); }); describe("feedback summary box", () => { it("contains correct numbers", () => { getDashboardStatistics("feedback.average").should("have.text", "3.3"); getDashboardStatistics("feedback.count").should("have.text", "3"); }); it("contains correct details link", () => { clickOnDetailsLink("feedback"); cy.url().should("contain", "/statistic/feedback"); // might be improved: roughly check // that the correct data is displayed cy.contains("3.3 von 4"); cy.contains("Test Trainer1"); cy.contains("Durchführung «Test Bern 2022 a»") cy.contains("Circle «Fahrzeug»") }); }); describe("competence summary box", () => { it("contains correct numbers", () => { getDashboardStatistics("competence.success").should("have.text", "1"); getDashboardStatistics("competence.fail").should("have.text", "0"); }); it("contains correct details link", () => { clickOnDetailsLink("competence"); cy.url().should("contain", "/statistic/competence"); // might be improved: roughly check // that the correct data is displayed cy.contains("Selbsteinschätzung: Vorbereitung"); cy.contains("Durchführung «Test Bern 2022 a»"); cy.contains("Circle «Fahrzeug»") }); }); });