vbv/cypress/e2e/dashboard/dashboardSupervisor.cy.js

109 lines
3.7 KiB
JavaScript

import { login } from "../helpers";
// ignore automatic import mess-up...
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("assignment summary box", () => {
it("contains correct numbers", () => {
// we have no completed assignments, but some are in progress
// -> makes sure that the numbers are correct
getDashboardStatistics("assignments.completed").should("have.text", "1");
getDashboardStatistics("assignments.passed").should("have.text", "34%");
});
it("contains correct details link", () => {
clickOnDetailsLink("assignments");
// might be improved: roughly check
// that the correct data is displayed
cy.contains("Noch nicht bestätigt");
cy.contains("Überprüfen einer Motorfahrzeugs-Versicherungspolice");
cy.contains("Test Bern 2022 a");
});
});
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", "2");
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»");
});
});
});