Add feedback trainer cypress test

This commit is contained in:
Daniel Egger 2023-09-26 18:46:51 +02:00
parent 66b50d6b1d
commit 966533e13b
10 changed files with 124 additions and 18 deletions

View File

@ -26,7 +26,9 @@
class="h-8 bg-sky-500" class="h-8 bg-sky-500"
:style="{ width: `${percentage * 100 * 0.8}%` }" :style="{ width: `${percentage * 100 * 0.8}%` }"
></div> ></div>
<div class="text-sm">{{ (percentage * 100).toFixed(1) }}%</div> <div class="text-sm" :data-cy="`percentage-value-${label}`">
{{ (percentage * 100).toFixed(1) }}%
</div>
</div> </div>
</QuestionSummary> </QuestionSummary>
</template> </template>

View File

@ -5,6 +5,7 @@
<span <span
class="col-start-2 row-span-2 inline-flex h-9 w-11 items-center justify-center rounded text-xl font-bold" class="col-start-2 row-span-2 inline-flex h-9 w-11 items-center justify-center rounded text-xl font-bold"
:style="ratingValueStyle" :style="ratingValueStyle"
data-cy="rating-scale-average"
> >
{{ rating.toFixed(1) }} {{ rating.toFixed(1) }}
</span> </span>

View File

@ -28,14 +28,14 @@
:style="greenStyle" :style="greenStyle"
></div> ></div>
<div class="self-center justify-self-center font-bold grid-in-left-label"> <div class="self-center justify-self-center font-bold grid-in-left-label">
<Popover class="relative"> <Popover class="relative" data-cy="popover-no">
<PopoverButton class="focus:outline-none"> <PopoverButton class="focus:outline-none">
{{ $t("general.no") }} {{ $t("general.no") }}
</PopoverButton> </PopoverButton>
<PopoverPanel <PopoverPanel
class="absolute top-[-200%] z-10 w-[120px] border border-gray-500 bg-white p-1 text-left text-sm font-normal" class="absolute top-[-200%] z-10 w-[120px] border border-gray-500 bg-white p-1 text-left text-sm font-normal"
> >
<p> <p data-cy="num-no">
{{ {{
`"${$t("general.no")}" ${numberOfRatings["no"]} ${$t( `"${$t("general.no")}" ${numberOfRatings["no"]} ${$t(
"feedback.answers" "feedback.answers"
@ -46,14 +46,14 @@
</Popover> </Popover>
</div> </div>
<div class="self-center justify-self-center font-bold grid-in-right-label"> <div class="self-center justify-self-center font-bold grid-in-right-label">
<Popover class="relative"> <Popover class="relative" data-cy="popover-yes">
<PopoverButton class="focus:outline-none"> <PopoverButton class="focus:outline-none">
{{ $t("general.yes") }} {{ $t("general.yes") }}
</PopoverButton> </PopoverButton>
<PopoverPanel <PopoverPanel
class="absolute top-[-200%] z-10 w-[120px] border border-gray-500 bg-white p-1 text-left text-sm font-normal" class="absolute top-[-200%] z-10 w-[120px] border border-gray-500 bg-white p-1 text-left text-sm font-normal"
> >
<p> <p data-cy="num-yes">
{{ {{
`"${$t("general.yes")}" ${numberOfRatings["yes"]} ${$t( `"${$t("general.yes")}" ${numberOfRatings["yes"]} ${$t(
"feedback.answers" "feedback.answers"
@ -71,6 +71,7 @@
import QuestionSummary from "@/components/ui/QuestionSummary.vue"; import QuestionSummary from "@/components/ui/QuestionSummary.vue";
import { Popover, PopoverButton, PopoverPanel } from "@headlessui/vue"; import { Popover, PopoverButton, PopoverPanel } from "@headlessui/vue";
import { computed } from "vue"; import { computed } from "vue";
const props = defineProps<{ const props = defineProps<{
ratings: boolean[]; ratings: boolean[];
title: string; title: string;

View File

@ -13,11 +13,17 @@
<main v-if="feedbackData"> <main v-if="feedbackData">
<h1 class="mb-2">{{ $t("feedback.feedbackPageTitle") }}</h1> <h1 class="mb-2">{{ $t("feedback.feedbackPageTitle") }}</h1>
<p class="mb-10"> <p class="mb-10">
<span class="font-bold">{{ feedbackData.amount }}</span> <span class="font-bold" data-cy="feedback-data-amount">
{{ feedbackData.amount }}
</span>
{{ $t("feedback.feedbackPageInfo") }} {{ $t("feedback.feedbackPageInfo") }}
</p> </p>
<ol> <ol v-if="feedbackData.amount > 0">
<li v-for="(question, i) in orderedQuestions" :key="i"> <li
v-for="(question, i) in orderedQuestions"
:key="i"
:data-cy="`question-${i + 1}`"
>
<RatingScale <RatingScale
v-if="ratingKeys.includes(question.key)" v-if="ratingKeys.includes(question.key)"
class="mb-8 bg-white" class="mb-8 bg-white"

View File

@ -163,7 +163,11 @@ const getIconName = (lc: LearningContent) => {
<button class="btn-primary"> <button class="btn-primary">
<router-link <router-link
:to="submittable.detailsLink" :to="submittable.detailsLink"
:data-cy="`show-details-btn-${submittable.content.slug}`" :data-cy="
isFeedback(submittable.content)
? `show-feedback-btn-${submittable.content.slug}`
: `show-details-btn-${submittable.content.slug}`
"
> >
{{ submittable.showDetailsText }} {{ submittable.showDetailsText }}
</router-link> </router-link>

View File

@ -1,7 +1,7 @@
import { TEST_STUDENT1_USER_ID } from "../../consts"; import { TEST_STUDENT1_USER_ID } from "../../consts";
import { login } from "../helpers"; import { login } from "../helpers";
describe("assignmentStudent.cy.js", () => { describe("feedbackStudent.cy.js", () => {
beforeEach(() => { beforeEach(() => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
login("test-student1@example.com", "test"); login("test-student1@example.com", "test");

View File

@ -0,0 +1,92 @@
import { login } from "../helpers";
describe("feedbackTrainer.cy.js", () => {
beforeEach(() => {
cy.visit("/course/test-lehrgang/learn/fahrzeug/feedback");
});
it("can open feedback results page with empty results", () => {
cy.manageCommand("cypress_reset");
login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit");
cy.get(
'[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]'
).click();
cy.get('[data-cy="feedback-data-amount"]').should("contain", "0");
});
it("can open feedback results page with results", () => {
cy.manageCommand("cypress_reset --create-feedback-responses");
login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit");
cy.get(
'[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]'
).click();
cy.get('[data-cy="feedback-data-amount"]').should("contain", "3");
cy.get('[data-cy="question-1"]')
.find('[data-cy="rating-scale-average"]')
.should("contain", "3.3");
cy.get('[data-cy="question-2"]')
.find('[data-cy="rating-scale-average"]')
.should("contain", "3.0");
cy.get('[data-cy="question-3"]')
.find('[data-cy="percentage-value-40%"]')
.should("contain", "33.3");
cy.get('[data-cy="question-3"]')
.find('[data-cy="percentage-value-80%"]')
.should("contain", "33.3");
cy.get('[data-cy="question-3"]')
.find('[data-cy="percentage-value-100%"]')
.should("contain", "33.3");
cy.get('[data-cy="question-4"]')
.find('[data-cy="popover-yes"]')
.click()
.find('[data-cy="num-yes"]')
.should("contain", "3");
cy.get('[data-cy="question-4"]')
.find('[data-cy="popover-no"]')
.click()
.find('[data-cy="num-no"]')
.should("contain", "0");
cy.get('[data-cy="question-5"]')
.find('[data-cy="rating-scale-average"]')
.should("contain", "2.7");
cy.get('[data-cy="question-6"]')
.find('[data-cy="rating-scale-average"]')
.should("contain", "3.0");
cy.get('[data-cy="question-7"]')
.should("contain", "Super Kurs!")
.should("contain", "Super, bin begeistert")
.should("contain", "Ok, entspricht den Erwartungen");
cy.get('[data-cy="question-8"]')
.find('[data-cy="popover-yes"]')
.click()
.find('[data-cy="num-yes"]')
.should("contain", "2");
cy.get('[data-cy="question-8"]')
.find('[data-cy="popover-no"]')
.click()
.find('[data-cy="num-no"]')
.should("contain", "1");
cy.get('[data-cy="question-9"]')
.should("contain", "Nichts Schlechtes")
.should("contain", "Es wäre praktisch, Zugang zu einer FAQ zu haben.")
.should("contain", "Mehr Videos wären schön.");
cy.get('[data-cy="question-10"]')
.should("contain", "Nur Gutes.")
.should("contain", "Das Beispiel mit der Katze fand ich sehr gut")
.should("contain", "Die Präsentation war super");
});
});

View File

@ -4,16 +4,16 @@ from vbv_lernwelt.assignment.models import Assignment, AssignmentCompletion
from vbv_lernwelt.core.constants import ( from vbv_lernwelt.core.constants import (
TEST_COURSE_SESSION_BERN_ID, TEST_COURSE_SESSION_BERN_ID,
TEST_STUDENT1_USER_ID, TEST_STUDENT1_USER_ID,
TEST_TRAINER1_USER_ID,
TEST_STUDENT2_USER_ID, TEST_STUDENT2_USER_ID,
TEST_STUDENT3_USER_ID, TEST_STUDENT3_USER_ID,
TEST_TRAINER1_USER_ID,
) )
from vbv_lernwelt.core.models import User from vbv_lernwelt.core.models import User
from vbv_lernwelt.course.creators.test_course import ( from vbv_lernwelt.course.creators.test_course import (
create_edoniq_test_result_data, create_edoniq_test_result_data,
create_feedback_response_data,
create_test_assignment_evaluation_data, create_test_assignment_evaluation_data,
create_test_assignment_submitted_data, create_test_assignment_submitted_data,
create_feedback_response_data,
) )
from vbv_lernwelt.course.models import CourseCompletion, CourseSession from vbv_lernwelt.course.models import CourseCompletion, CourseSession
from vbv_lernwelt.feedback.models import FeedbackResponse from vbv_lernwelt.feedback.models import FeedbackResponse
@ -122,8 +122,8 @@ def command(
"goal_attainment": 4, "goal_attainment": 4,
"proficiency": 100, "proficiency": 100,
"preparation_task_clarity": True, "preparation_task_clarity": True,
"instructor_competence": 4, "instructor_competence": 3,
"instructor_respect": 4, "instructor_respect": 3,
"instructor_open_feedback": "Super, bin begeistert", "instructor_open_feedback": "Super, bin begeistert",
"would_recommend": True, "would_recommend": True,
"course_negative_feedback": "Es wäre praktisch, Zugang zu einer FAQ zu haben.", "course_negative_feedback": "Es wäre praktisch, Zugang zu einer FAQ zu haben.",
@ -141,9 +141,9 @@ def command(
"goal_attainment": 2, "goal_attainment": 2,
"proficiency": 40, "proficiency": 40,
"preparation_task_clarity": True, "preparation_task_clarity": True,
"instructor_competence": 2, "instructor_competence": 1,
"instructor_respect": 2, "instructor_respect": 2,
"instructor_open_feedback": "Ok, enspricht den Erwartungen", "instructor_open_feedback": "Ok, entspricht den Erwartungen",
"would_recommend": False, "would_recommend": False,
"course_negative_feedback": "Mehr Videos wären schön.", "course_negative_feedback": "Mehr Videos wären schön.",
"course_positive_feedback": "Die Präsentation war super", "course_positive_feedback": "Die Präsentation war super",

View File

@ -18,7 +18,7 @@ class FeedbackResponseFactory(DjangoModelFactory):
[ [
"Alles gut, manchmal etwas langfädig", "Alles gut, manchmal etwas langfädig",
"Super, bin begeistert", "Super, bin begeistert",
"Ok, enspricht den Erwartungen", "Ok, entspricht den Erwartungen",
] ]
), ),
"would_recommend": FuzzyChoice([True, False]), "would_recommend": FuzzyChoice([True, False]),

View File

@ -1,7 +1,7 @@
import structlog import structlog
from vbv_lernwelt.core.models import User from vbv_lernwelt.core.models import User
from vbv_lernwelt.course.models import CourseSession, CourseCompletionStatus from vbv_lernwelt.course.models import CourseCompletionStatus, CourseSession
from vbv_lernwelt.course.services import mark_course_completion from vbv_lernwelt.course.services import mark_course_completion
from vbv_lernwelt.feedback.models import FeedbackResponse from vbv_lernwelt.feedback.models import FeedbackResponse
from vbv_lernwelt.learnpath.models import LearningContentFeedback from vbv_lernwelt.learnpath.models import LearningContentFeedback