Add cypress tests for course specific settings

This commit is contained in:
Christian Cueni 2024-05-04 11:29:48 +02:00
parent dd68da5138
commit 1d995bff91
8 changed files with 143 additions and 27 deletions

View File

@ -47,7 +47,7 @@ const previousRoute = getPreviousRoute();
const learningUnitHasFeedbackPage = computed(
() =>
courseSession.value.course.configuration.enable_learning_mentor &&
!courseSession.value.course.configuration.is_uk &&
courseSession.value.course.configuration.is_vv &&
!isReadOnly.value
);

View File

@ -57,7 +57,7 @@ const isOwnEvaluation = computed(() => {
<div v-if="isLoaded">
<div>
<div class="flex flex-col items-center justify-between pb-4 md:flex-row">
<h2 class="py-4">{{ headerTitle }}</h2>
<h2 class="py-4" data-cy="self-evaluation-title">{{ headerTitle }}</h2>
<ItDropdownSelect
v-model="selectedCircle"
class="text-bold w-full min-w-[18rem] border-2 border-gray-300 md:w-24"

View File

@ -71,6 +71,7 @@ onMounted(async () => {
<router-link
:to="`/course/${courseSlug}/competence/self-evaluation-and-feedback`"
class="block py-3"
data-cy="self-evaluation-and-feedback-navigation-link"
>
{{
hasEvaluationFeedback

View File

@ -66,21 +66,21 @@ const showDocumentSection = computed(() => {
const expertAsContact = computed(() => {
return (
lpQueryResult.course.value?.configuration.enable_learning_mentor &&
lpQueryResult.course.value?.configuration.is_vv
lpQueryResult.course.value?.configuration.is_uk
);
});
const courseConfig = computed(() => {
if (expertAsContact.value) {
return {
contactDescription: "circlePage.contactLearningMentorDescription",
contactButton: "circlePage.contactLearningMentorButton",
contactDescription: "circlePage.contactExpertDescription",
contactButton: "circlePage.contactExpertButton",
showContact: true,
};
} else {
return {
contactDescription: "circlePage.contactExpertDescription",
contactButton: "circlePage.contactExpertButton",
contactDescription: "circlePage.contactLearningMentorDescription",
contactButton: "circlePage.contactLearningMentorButton",
showContact: true,
};
}
@ -105,12 +105,13 @@ interface Mentor {
const experts = computed<Expert[] | null>(() => {
if (courseConfig.value.showContact) {
console.log("expertAsContact", expertAsContact.value);
if (expertAsContact.value) {
return circleExperts.value;
} else {
if (mentors.value?.length > 0) {
return mentors.value.map((m: Mentor) => m.mentor);
}
} else {
return circleExperts.value;
}
}
return null;
@ -243,7 +244,10 @@ watch(
<DocumentSection v-if="showDocumentSection" :circle="circle" />
<div v-if="!props.readonly" class="expert mt-8 border p-6">
<h3 class="text-blue-dark">{{ $t("circlePage.gotQuestions") }}</h3>
<div class="mt-4 leading-relaxed">
<div
class="mt-4 leading-relaxed"
data-cy="circle-contact-description"
>
{{
$t(courseConfig.contactDescription, {
circleName: circle?.title,

View File

@ -179,4 +179,13 @@ describe("competenceCertificate.cy.js", () => {
.and("contain", "von 24 Punkten")
.and("contain", "Bewertung freigegeben");
});
it("should display link to details", () => {
cy.manageCommand("cypress_reset");
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/competence/self-evaluation-and-feedback");
cy.get('[data-cy^="self-eval-"][data-cy$="-detail-url"]:first').contains(
"Selbsteinschätzung anschauen"
);
});
});

View File

@ -1,4 +1,4 @@
import {login} from "../helpers";
import { login } from "../helpers";
describe("selfEvaluation.cy.js", () => {
beforeEach(() => {
@ -12,26 +12,25 @@ describe("selfEvaluation.cy.js", () => {
});
it("self evaluation should be neutral", () => {
cy.get("[data-cy=\"test-lehrgang-lp-circle-reisen-lu-reisen\"]")
.find("[data-cy=\"no-status\"]")
cy.get('[data-cy="test-lehrgang-lp-circle-reisen-lu-reisen"]')
.find('[data-cy="no-status"]')
.should("exist");
});
it("self evaluation from KompetenzNavi", () => {
cy.get("[data-cy=\"test-lehrgang-lp-circle-reisen-lu-reisen\"]")
.find("[data-cy=\"no-status\"]")
cy.get('[data-cy="test-lehrgang-lp-circle-reisen-lu-reisen"]')
.find('[data-cy="no-status"]')
.should("exist");
// data in KompetenzNavi/Übersicht is correct
cy.visit("/course/test-lehrgang/competence");
cy.get("[data-cy=\"self-evaluation-fail\"]").should("have.text", "0");
cy.get("[data-cy=\"self-evaluation-success\"]").should("have.text", "0");
cy.get("[data-cy=\"self-evaluation-unknown\"]").should("have.text", "4");
cy.get('[data-cy="self-evaluation-fail"]').should("have.text", "0");
cy.get('[data-cy="self-evaluation-success"]').should("have.text", "0");
cy.get('[data-cy="self-evaluation-unknown"]').should("have.text", "4");
// learning unit id = 692 also known as:
// Bedarfsanalyse, Ist- und Soll-Situation <<Reisen>>
const identifier = "self-eval-692"
const identifier = "self-eval-692";
// data in KompetenzNavi/Selbsteinschätzungen is correct
cy.visit("/course/test-lehrgang/competence/self-evaluation-and-feedback");
@ -44,7 +43,10 @@ describe("selfEvaluation.cy.js", () => {
// starting the self evaluation will return to KompetenzNavi
cy.makeSelfEvaluation([true, false]);
cy.url().should("include", "/course/test-lehrgang/competence/self-evaluation-and-feedback");
cy.url().should(
"include",
"/course/test-lehrgang/competence/self-evaluation-and-feedback"
);
// check data again on KompetenzNavi
cy.get(`[data-cy="${identifier}-fail"]`).should("have.text", "1");

View File

@ -0,0 +1,85 @@
import { login } from "./helpers";
describe("courseSpecificSettings.cy.js", () => {
describe("uk Course", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --set-only-is-uk-flag");
login("test-student1@example.com", "test");
});
it("should display 'Selbsteinschätzung in üK'", () => {
cy.visit("/course/test-lehrgang/competence/self-evaluation-and-feedback");
cy.get('[data-cy="self-evaluation-title"]').contains(
"Selbsteinschätzung",
{ matchCase: false, exact: true }
);
cy.get(
'[data-cy="self-evaluation-and-feedback-navigation-link"]'
).contains("Selbsteinschätzung", {
matchCase: false,
exact: true,
});
});
it("should display 'Praxisbildner'", () => {
cy.visit("/course/test-lehrgang/learn");
cy.get('[data-cy="navigation-learning-mentor-link"]').contains(
"Praxisbildner"
);
cy.get('[data-cy="navigation-learning-mentor-link"]').click();
cy.get('[data-cy="lm-my-lms-title"]').contains("Meine Praxisbildner");
cy.get('[data-cy="lm-invite-mentor-button"]').contains(
"Neuen Praxisbildner einladen"
);
});
it("should display trainer in contact box", () => {
cy.visit("/course/test-lehrgang/learn/fahrzeug#ls-vorbereitung");
cy.get('[data-cy="circle-contact-description"]').contains(
"Tausche dich mit der Trainer/-in für den Circle Fahrzeug aus."
);
});
});
describe("VV course", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --set-only-is-vv-flag");
login("test-student1@example.com", "test");
});
it("should display 'Selbst- und Fremdeinschätzung in VV'", () => {
cy.visit("/course/test-lehrgang/competence/self-evaluation-and-feedback");
cy.get('[data-cy="self-evaluation-title"]').contains(
"Selbst- und Fremdeinschätzung",
{ matchCase: false, exact: true }
);
cy.get(
'[data-cy="self-evaluation-and-feedback-navigation-link"]'
).contains("Selbst- und Fremdeinschätzung", {
matchCase: false,
exact: true,
});
});
it("should display 'Lernbegleitung'", () => {
cy.visit("/course/test-lehrgang/learn");
cy.get('[data-cy="navigation-learning-mentor-link"]').contains(
"Lernbegleitung"
);
cy.get('[data-cy="navigation-learning-mentor-link"]').click();
cy.get('[data-cy="lm-my-lms-title"]').contains("Meine Lernbegleiter");
cy.get('[data-cy="lm-invite-mentor-button"]').contains(
"Neue Lernbegleitung einladen"
);
});
it("should display lernbegleitung in contact box", () => {
cy.visit("/course/test-lehrgang/learn/fahrzeug#ls-vorbereitung");
cy.get('[data-cy="circle-contact-description"]').contains(
"Tausche dich mit deiner Lernbegleitung aus."
);
});
});
});

View File

@ -103,6 +103,11 @@ from vbv_lernwelt.self_evaluation_feedback.models import (
default=False,
help="Will set only the is_uk flag for the test course and enable learning mentors for the course",
)
@click.option(
"--set-only-is-vv-flag/--no-set-only-is-vv-flag",
default=False,
help="Will set only the is_vv flag for the test course and enable learning mentors for the course",
)
def command(
create_assignment_completion,
create_assignment_evaluation,
@ -114,6 +119,7 @@ def command(
enable_circle_documents,
create_learning_mentor,
set_only_is_uk_flag,
set_only_is_vv_flag,
):
print("cypress reset data")
CourseCompletion.objects.all().delete()
@ -399,11 +405,20 @@ def command(
course.configuration.enable_circle_documents = enable_circle_documents
course.configuration.is_uk = True
if set_only_is_uk_flag:
course.configuration.is_vv = False
course.configuration.enable_learning_mentor = True
else:
course.configuration.is_vv = True
course.configuration.enable_learning_mentor = False
if set_only_is_uk_flag or set_only_is_vv_flag:
if set_only_is_uk_flag:
course.configuration.is_vv = False
course.configuration.enable_learning_mentor = True
else:
course.configuration.is_vv = True
course.configuration.enable_learning_mentor = False
if set_only_is_vv_flag:
course.configuration.is_vv = True
course.configuration.is_uk = False
course.configuration.enable_learning_mentor = True
elif not set_only_is_uk_flag:
course.configuration.is_uk = False
course.configuration.enable_learning_mentor = False
course.configuration.save()