Add cypress test for cockpit

This commit is contained in:
Daniel Egger 2024-05-22 17:31:27 +02:00
parent aa4f0a0d92
commit ec4da1b265
5 changed files with 82 additions and 4 deletions

View File

@ -164,6 +164,7 @@ const getIconName = (lc: LearningContent) => {
v-for="submittable in submittables" v-for="submittable in submittables"
:key="submittable.id" :key="submittable.id"
class="flex flex-col justify-between gap-2 py-4 lg:flex-row lg:gap-4" class="flex flex-col justify-between gap-2 py-4 lg:flex-row lg:gap-4"
:data-cy="`submittable-${submittable.content.slug}`"
> >
<div class="flex flex-row items-center gap-2 lg:w-1/3"> <div class="flex flex-row items-center gap-2 lg:w-1/3">
<div class="min-h-9 min-w-9"> <div class="min-h-9 min-w-9">

View File

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

View File

@ -0,0 +1,69 @@
import { login } from "../helpers";
describe("cockpitPointsDeducted.cy.js", () => {
it("will show results with points", () => {
cy.manageCommand(
"cypress_reset --create-assignment-evaluation --assignment-evaluation-scores 6,4,6,3,3 --create-edoniq-test-results 19 24 0"
);
login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit");
// check edoniq test with deducted points
cy.get(
'[data-cy="submittable-test-lehrgang-lp-circle-fahrzeug-lc-wissens-und-verständnisfragen"]'
).should("contain", "1 von 3 Bewertungen freigegeben");
cy.get(
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-wissens-und-verständnisfragen"]'
).click();
cy.get('[data-cy="Student1"]')
.should("contain", "19 von 24 Punkten")
.and("contain", "79%")
.and("not.contain", "Nicht bestanden");
// check casework with deducted points
cy.visit("/course/test-lehrgang/cockpit");
cy.get(
'[data-cy="submittable-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).should("contain", "1 von 3 Bewertungen freigegeben");
cy.get(
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).click();
cy.get('[data-cy="Student1"]')
.should("contain", "22 von 24 Punkten")
.and("contain", "92%")
.and("not.contain", "Nicht bestanden");
});
it("will show results with deducted points", () => {
cy.manageCommand(
"cypress_reset --create-assignment-evaluation --assignment-evaluation-scores 6,4,6,3,3 --assignment-points-deducted 14 --create-edoniq-test-results 19 24 8"
);
login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit");
// check edoniq test with deducted points
cy.get(
'[data-cy="submittable-test-lehrgang-lp-circle-fahrzeug-lc-wissens-und-verständnisfragen"]'
).should("contain", "1 von 3 Bewertungen freigegeben");
cy.get(
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-wissens-und-verständnisfragen"]'
).click();
cy.get('[data-cy="Student1"]')
.should("contain", "11 von 24 Punkten")
.and("contain", "46%")
.and("contain", "Nicht bestanden");
// check casework with deducted points
cy.visit("/course/test-lehrgang/cockpit");
cy.get(
'[data-cy="submittable-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).should("contain", "1 von 3 Bewertungen freigegeben");
cy.get(
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).click();
cy.get('[data-cy="Student1"]')
.should("contain", "8 von 24 Punkten")
.and("contain", "33%")
.and("contain", "Nicht bestanden");
});
});

View File

@ -106,7 +106,7 @@ describe("dashboardSupervisor.cy.js", () => {
describe("with deducted points", () => { describe("with deducted points", () => {
beforeEach(() => { beforeEach(() => {
cy.manageCommand( 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" "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"); login("test-supervisor1@example.com", "test");
cy.visit("/"); cy.visit("/");
@ -116,7 +116,7 @@ describe("dashboardSupervisor.cy.js", () => {
// we have no completed assignments, but some are in progress // we have no completed assignments, but some are in progress
// -> makes sure that the numbers are correct // -> makes sure that the numbers are correct
getDashboardStatistics("assignments.completed").should("have.text", "2"); getDashboardStatistics("assignments.completed").should("have.text", "2");
getDashboardStatistics("assignments.passed").should("have.text", "17%"); getDashboardStatistics("assignments.passed").should("have.text", "0%");
// check data on the details page // check data on the details page
cy.get( cy.get(
@ -128,7 +128,7 @@ describe("dashboardSupervisor.cy.js", () => {
cy.get( cy.get(
'[data-cy="Überprüfen einer Motorfahrzeugs-Versicherungspolice"]' '[data-cy="Überprüfen einer Motorfahrzeugs-Versicherungspolice"]'
).should("contain", "1 von 3 bestanden"); ).should("contain", "0 von 3 bestanden");
}); });
}); });
}); });

View File

@ -35,4 +35,9 @@ class Migration(migrations.Migration):
to=settings.AUTH_USER_MODEL, to=settings.AUTH_USER_MODEL,
), ),
), ),
migrations.AlterField(
model_name="assignmentcompletion",
name="completion_data",
field=models.JSONField(blank=True, default=dict),
),
] ]