chore: adds missing cypress test for assignment

This commit is contained in:
Livio Bieri 2023-11-06 10:00:13 +01:00
parent 9d1328c89d
commit 1fdc28419d
2 changed files with 95 additions and 64 deletions

View File

@ -18,21 +18,32 @@ const progress = computed(() => {
</script>
<template>
<BaseBox :details-link="'/statistic/assignment'">
<BaseBox
:details-link="'/statistic/assignment'"
data-cy="dashboard.stats.assignments"
>
<template #title>{{ $t("a.Kompetenznachweis-Elemente") }}</template>
<template #content>
<div class="flex items-center">
<i18next :translation="$t('a.NUMBER Elemente abgeschlossen')">
<template #NUMBER>
<span class="mr-3 text-4xl font-bold">{{ assignmentsCompleted }}</span>
<span
class="mr-3 text-4xl font-bold"
data-cy="dashboard.stats.assignments.completed"
>
{{ assignmentsCompleted }}
</span>
</template>
</i18next>
</div>
<div class="flex items-center">
<i18next :translation="$t('a.{NUMBER} Bestanden')">
<template #NUMBER>
<span class="mr-3 text-4xl font-bold">
{{ Math.round(props.avgPassed) }}%
<span
class="mr-3 text-4xl font-bold"
data-cy="dashboard.stats.assignments.passed"
>
{{ `${Math.round(props.avgPassed)}%` }}
</span>
</template>
</i18next>

View File

@ -1,81 +1,101 @@
import {login} from "../helpers";
const getDashboardStatistics = (what) => {
return cy.get(`[data-cy="dashboard.stats.${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();
})
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("/");
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", "0");
getDashboardStatistics("assignments.passed").should("have.text", "0%");
});
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");
it("contains correct details link", () => {
clickOnDetailsLink("assignments");
// 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");
});
// might be improved: roughly check
// that the correct data is displayed
cy.contains("Noch nicht bestätigt");
cy.contains("Fahrzeug - Mein erstes Auto");
cy.contains("Test Bern 2022 a");
});
});
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("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");
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»")
});
// 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("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»")
});
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»")
});
});
});