135 lines
4.7 KiB
JavaScript
135 lines
4.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", () => {
|
|
describe("with data", () => {
|
|
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/test-lehrgang/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("feedback summary box", () => {
|
|
it("contains correct numbers", () => {
|
|
getDashboardStatistics("feedback.average").should("have.text", "3.3");
|
|
getDashboardStatistics("feedback.count").should("have.text", "6");
|
|
});
|
|
it("contains correct details link", () => {
|
|
clickOnDetailsLink("feedback");
|
|
cy.url().should("contain", "/statistic/test-lehrgang/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/test-lehrgang/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»");
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("with deducted points", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand(
|
|
"cypress_reset --create-assignment-evaluation --assignment-evaluation-scores 6,6,6,3,3 --assignment-points-deducted 14 --create-edoniq-test-results 19 24 8"
|
|
);
|
|
login("test-supervisor1@example.com", "test");
|
|
cy.visit("/");
|
|
});
|
|
|
|
it("contains numbers with deduction", () => {
|
|
// we have no completed assignments, but some are in progress
|
|
// -> makes sure that the numbers are correct
|
|
getDashboardStatistics("assignments.completed").should("have.text", "2");
|
|
getDashboardStatistics("assignments.passed").should("have.text", "0%");
|
|
|
|
// check data on the details page
|
|
cy.get(
|
|
'[data-cy="dashboard.stats.assignments"] [data-cy="basebox.detailsLink"]'
|
|
).click();
|
|
cy.get(
|
|
'[data-cy="Edoniq Wissens- und Verständisfragen - Circle Fahrzeug (Demo)"]'
|
|
).should("contain", "0 von 3 bestanden");
|
|
|
|
cy.get(
|
|
'[data-cy="Überprüfen einer Motorfahrzeugs-Versicherungspolice"]'
|
|
).should("contain", "0 von 3 bestanden");
|
|
});
|
|
});
|
|
});
|