Add cypress tests

This commit is contained in:
Daniel Egger 2024-05-22 16:24:10 +02:00
parent 401c44dbc7
commit aa4f0a0d92
7 changed files with 273 additions and 100 deletions

View File

@ -106,7 +106,12 @@ function evaluationForTask(task: AssignmentEvaluationTask) {
return expertData;
}
const maxPoints = computed(() => maxAssignmentPoints(props.assignment));
const maxPoints = computed(() => {
if (props.assignmentCompletion.completion_status === "EVALUATION_SUBMITTED") {
return props.assignmentCompletion.evaluation_max_points;
}
return maxAssignmentPoints(props.assignment);
});
const userPoints = computed(() =>
userAssignmentPoints(props.assignment, props.assignmentCompletion)
);
@ -128,12 +133,19 @@ const userPoints = computed(() =>
</h3>
<h3 v-else class="mb-6" data-cy="sub-title">{{ $t(text.evaluationSubmission) }}</h3>
<section class="mb-6 border p-6" data-cy="result-section">
<section
v-if="props.assignment.assignment_type === 'CASEWORK'"
class="flex items-center"
>
<section v-if="props.assignment.assignment_type === 'CASEWORK'">
<div class="flex items-center">
<div class="heading-1 py-4" data-cy="user-points">
<template
v-if="
props.assignmentCompletion.completion_status == 'EVALUATION_SUBMITTED'
"
>
{{ props.assignmentCompletion.evaluation_points_final }}
</template>
<template v-else>
{{ userPoints }}
</template>
</div>
<div class="pl-2" data-cy="total-points">
{{ $t("assignment.von x Punkten", { x: maxPoints }) }}
@ -145,6 +157,26 @@ const userPoints = computed(() =>
).toFixed(0)
}}%)
</div>
</div>
<div
v-if="assignmentCompletion.evaluation_points_deducted > 0"
data-cy="points-deducted"
class="mb-4 text-gray-900"
>
<div>
{{ $t("a.Punkte aus Bewertung") }}:
{{ assignmentCompletion.evaluation_points }}
</div>
<div>
{{ $t("a.Abgezogene Punkte") }}:
{{ assignmentCompletion.evaluation_points_deducted }}
</div>
<div>
{{ $t("a.Grund") }}:
{{ assignmentCompletion.evaluation_points_deducted_reason }}
</div>
</div>
</section>
<div

View File

@ -49,7 +49,7 @@ const total = (metrics: AssignmentCompletionMetricsType) => {
:items="courseStatistics.assignments.records"
>
<template #default="{ item }">
<div class="flex justify-between">
<div class="flex justify-between" :data-cy="item.assignment_title">
<div>
<h4 class="font-bold">
{{ (item as AssignmentStatisticsRecordType).assignment_title }}

View File

@ -191,7 +191,10 @@ async function startTest() {
</span>
</div>
<div v-if="assignmentCompletion.evaluation_points_deducted > 0" class="my-4">
<div
v-if="assignmentCompletion.evaluation_points_deducted > 0"
class="my-4 text-gray-900"
>
<div>
{{ $t("a.Punkte aus Bewertung") }}:
{{ assignmentCompletion.evaluation_points }}

View File

@ -46,7 +46,7 @@ describe("competenceCertificate.cy.js", () => {
it("check with finished passed edoniq test", () => {
cy.manageCommand(
"cypress_reset --create-assignment-completion --create-edoniq-test-results 19 24"
"cypress_reset --create-assignment-completion --create-edoniq-test-results 19 24 0"
);
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/competence");
@ -108,7 +108,7 @@ describe("competenceCertificate.cy.js", () => {
it("check with finished failed edoniq test", () => {
cy.manageCommand(
"cypress_reset --create-assignment-completion --create-edoniq-test-results 10 24"
"cypress_reset --create-assignment-completion --create-edoniq-test-results 10 24 0"
);
login("test-student1@example.com", "test");
@ -144,7 +144,7 @@ describe("competenceCertificate.cy.js", () => {
it("check with finished edoniq test and finished casework", () => {
cy.manageCommand(
"cypress_reset --create-assignment-evaluation --create-edoniq-test-results 19 24"
"cypress_reset --create-assignment-evaluation --create-edoniq-test-results 19 24 0"
);
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/competence");
@ -197,6 +197,110 @@ describe("competenceCertificate.cy.js", () => {
.and("contain", "Bewertung freigegeben");
});
it("check with finished edoniq test with deducted points", () => {
cy.manageCommand(
"cypress_reset --create-assignment-completion --create-edoniq-test-results 19 24 8"
);
login("test-student1@example.com", "test");
// go to certificate detail page
cy.visit(
"/course/test-lehrgang/competence/certificates/kompetenznachweis-1"
);
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1-grade"]'
).should("contain", "Note: 3.5");
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1-grade-percent"]'
).should("contain", "Ungerundete Note: 3.29");
cy.get(
'[data-cy="assignment-test-lehrgang-assignment-edoniq-wissens-und-verständisfragen-circle-fahrzeug-demo"]'
)
.should("contain", "11")
.and("contain", "Bewertung freigegeben")
.and("contain", "46%")
.and("contain", "mit Abzug")
.and("contain", "Nicht bestanden");
// it can open learning content page directly
cy.get(
'[data-cy="assignment-test-lehrgang-assignment-edoniq-wissens-und-verständisfragen-circle-fahrzeug-demo"] [data-cy="open-learning-content"]'
).click();
cy.get('[data-cy="test-result"]')
.should("contain", "11 von 24 Punkten")
.and("contain", "46%")
.and("contain", "Punkte aus Bewertung: 19")
.and("contain", "Abgezogene Punkte: 8")
.and("contain", "Grund: Edoniq Punkteabzug Test")
.and("contain", "Nicht bestanden");
});
it("check with finished casework and points deducted", () => {
cy.manageCommand(
"cypress_reset --create-assignment-evaluation --assignment-evaluation-scores 4,6,4,3,2 --assignment-points-deducted 5"
);
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/competence");
cy.get('[data-cy="certificate-total-points-text"]').contains(
"Erfahrungsnote üK: 4"
);
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1"]'
)
.should("contain", "Note: 4")
.and("contain", "1 von 2 Kompetenznachweis-Elementen");
// check on certificates page
cy.get('[data-cy="certificates-show-all-button"]').click();
cy.get('[data-cy="certificate-total-points-text"]')
.should("contain", "Erfahrungsnote üK")
.and("contain", "Note: 4")
.and("contain", "Zwischenstand");
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1"]'
)
.and("contain", "Zwischenstand")
.and("contain", "1 von 2 Kompetenznachweis-Elementen");
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1-grade"]'
).should("contain", "Note: 4");
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1-grade-percent"]'
).should("contain", "Ungerundete Note: 3.92");
// check certificate detail page
cy.get(
'[data-cy="certificate-test-lehrgang-competencenavi-certificates-kompetenznachweis-1-detail-link"]'
).click();
cy.get(
'[data-cy="assignment-test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"]'
)
.should("contain", "14")
.and("contain", "von 24 Punkten")
.and("contain", "58%")
.and("contain", "mit Abzug")
.and("contain", "Bewertung freigegeben");
cy.get(
'[data-cy="assignment-test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"] [data-cy="open-learning-content"]'
).click();
cy.get('[data-cy="user-points"]').should("contain", "14");
cy.get('[data-cy="total-points"]').should(
"contain",
"von 24 Punkten (58%)"
);
cy.get('[data-cy="points-deducted"]')
.should("contain", "Punkte aus Bewertung: 19")
.and("contain", "Abgezogene Punkte: 5")
.and("contain", "Grund: Assignment Punkteabzug Test");
});
it("should display link to details", () => {
cy.manageCommand("cypress_reset");
login("test-student1@example.com", "test");

View File

@ -13,6 +13,7 @@ const clickOnDetailsLink = (within) => {
};
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"
@ -25,7 +26,10 @@ describe("dashboardSupervisor.cy.js", () => {
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.completed").should(
"have.text",
"1"
);
getDashboardStatistics("assignments.passed").should("have.text", "34%");
});
@ -98,3 +102,33 @@ describe("dashboardSupervisor.cy.js", () => {
});
});
});
describe("with deducted points", () => {
beforeEach(() => {
cy.manageCommand(
"cypress_reset --create-assignment-evaluation --assignment-evaluation-scores 4,6,4,3,2 --assignment-points-deducted 5 --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", "17%");
// 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", "1 von 3 bestanden");
});
});
});

View File

@ -74,7 +74,7 @@ from vbv_lernwelt.self_evaluation_feedback.models import (
@click.option(
"--create-edoniq-test-results",
type=(int, int, float),
default=(None, None, 0),
default=(None, None, 0.0),
metavar="USER_POINTS MAX_POINTS POINTS_DEDUCTED",
help="Create edoniq result data for test-student1@example.com with user points and max points",
)

View File

@ -403,7 +403,7 @@ def create_test_assignment_evaluation_data(
# take the last input score as deduction if there is one left...
if points_deducted > 0:
ac.evaluation_points_deducted = points_deducted
ac.evaluation_points_deducted_reason = "Assignment Punkteabug Test"
ac.evaluation_points_deducted_reason = "Assignment Punkteabzug Test"
ac.save()
@ -434,7 +434,7 @@ def create_edoniq_test_result_data(
if evaluation_points_deducted > 0:
ac.evaluation_points_deducted = evaluation_points_deducted
ac.evaluation_points_deducted_reason = "Edoniq Punkteabug Test"
ac.evaluation_points_deducted_reason = "Edoniq Punkteabzug Test"
ac.save()