Add cypress tests

This commit is contained in:
Christian Cueni 2024-07-25 13:57:06 +02:00
parent fd3effc673
commit 848647fb97
7 changed files with 59 additions and 7 deletions

View File

@ -17,10 +17,14 @@ const props = withDefaults(defineProps<Props>(), {
<template #firstRow> <template #firstRow>
<slot name="leading"></slot> <slot name="leading"></slot>
<img class="mr-2 h-11 w-11 rounded-full" :src="props.avatarUrl" /> <img class="mr-2 h-11 w-11 rounded-full" :src="props.avatarUrl" />
<p class="text-bold lg:leading-[45px]"> <div :class="props.extraInfo ? 'leading-5' : ''">
{{ props.name }} <p class="text-bold" :class="props.extraInfo ? '' : 'lg:leading-[45px]'">
<span v-if="props.extraInfo" class="font-normal">{{ props.extraInfo }}</span> {{ props.name }}
</p> </p>
<p v-if="props.extraInfo" class="font-normal" data-cy="extra-info">
{{ props.extraInfo }}
</p>
</div>
</template> </template>
<template #center> <template #center>
<slot name="center"></slot> <slot name="center"></slot>

View File

@ -225,7 +225,7 @@ watch(
:avatar-url="csu.avatar_url" :avatar-url="csu.avatar_url"
:class="0 === index ? 'border-none' : ''" :class="0 === index ? 'border-none' : ''"
:extra-info=" :extra-info="
csu.optional_attendance ? `(${$t('a.Optionale Anwesenheit')})` : '' csu.optional_attendance ? `${$t('a.Optionale Anwesenheit')}` : ''
" "
> >
<template #leading> <template #leading>

View File

@ -55,8 +55,8 @@ onMounted(() => {
<p class="mb-2">{{ user.email }}</p> <p class="mb-2">{{ user.email }}</p>
<p class="text-gray-800"> <p class="text-gray-800">
{{ $t("a.Teilnehmer") }} {{ $t("a.Teilnehmer") }}
<span v-if="user.optional_attendance"> <span v-if="user.optional_attendance" data-cy="optional-attendance">
({{ $t("a.Optionale Anwesenheit") }}) {{ $t("a.Optionale Anwesenheit") }}
</span> </span>
</p> </p>
</div> </div>

View File

@ -0,0 +1,11 @@
import { login } from "../helpers";
describe("cockpitAttendaceCheck.cy.js", () => {
it("will display optional participants", () => {
cy.manageCommand("cypress_reset --set-optional-attendance-flag");
login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit/attendance");
cy.get('[data-cy="extra-info"]').should("contain", "Optionale Anwesenheit");
});
});

View File

@ -0,0 +1,17 @@
import { login } from "../helpers";
import { TEST_STUDENT1_USER_ID } from "../../consts";
describe("publicProfileAttendance.cy.js", () => {
it("will display optional attendance", () => {
cy.manageCommand("cypress_reset --set-optional-attendance-flag");
login("test-trainer1@example.com", "test");
cy.visit(
`course/test-lehrgang/profile/${TEST_STUDENT1_USER_ID}/learning-path`,
);
cy.get('[data-cy="optional-attendance"]').should(
"contain",
"Optionale Anwesenheit",
);
});
});

View File

@ -71,5 +71,6 @@ class ProfileViewTest(APITestCase):
"organisation_postal_code": "", "organisation_postal_code": "",
"organisation_city": "", "organisation_city": "",
"organisation_country": None, "organisation_country": None,
"optional_attendance": False,
}, },
) )

View File

@ -120,6 +120,11 @@ from vbv_lernwelt.shop.models import CheckoutInformation
default=False, default=False,
help="Will set only the is_vv flag for the test course and enable learning mentors for the course", help="Will set only the is_vv flag for the test course and enable learning mentors for the course",
) )
@click.option(
"--set-optional-attendance-flag/--no-optional-attendance-flag",
default=False,
help="Will set the optional attendance flag for the test-student1@example.com",
)
def command( def command(
create_assignment_completion, create_assignment_completion,
create_assignment_evaluation, create_assignment_evaluation,
@ -133,6 +138,7 @@ def command(
create_learning_mentor, create_learning_mentor,
set_only_is_uk_flag, set_only_is_uk_flag,
set_only_is_vv_flag, set_only_is_vv_flag,
set_optional_attendance_flag,
): ):
print("cypress reset data") print("cypress reset data")
CourseCompletion.objects.all().delete() CourseCompletion.objects.all().delete()
@ -478,4 +484,17 @@ def command(
course.configuration.is_uk = False course.configuration.is_uk = False
course.configuration.enable_learning_mentor = False course.configuration.enable_learning_mentor = False
if set_optional_attendance_flag:
course_session_user = CourseSessionUser.objects.get(
user__id=TEST_STUDENT1_USER_ID
)
course_session_user.optional_attendance = True
course_session_user.save()
else:
course_session_user = CourseSessionUser.objects.get(
user_id=TEST_STUDENT1_USER_ID
)
course_session_user.optional_attendance = False
course_session_user.save()
course.configuration.save() course.configuration.save()