Add cypress test for "Fremdeinschätzung"

This commit is contained in:
Daniel Egger 2024-07-17 18:50:22 +02:00
parent f0013648e9
commit af2b63b15f
11 changed files with 98 additions and 17 deletions

View File

@ -77,7 +77,11 @@ function hasActionButton(): boolean {
</script>
<template>
<div v-if="courseConfig" class="mb-14 space-y-8">
<div
v-if="courseConfig"
class="mb-14 space-y-8"
:data-cy="`panel-${courseConfig.course_slug}`"
>
<div class="flex flex-col space-y-8 bg-white p-6">
<div class="border-b border-gray-300 pb-8">
<div class="flex flex-row items-start justify-between">

View File

@ -21,7 +21,7 @@ onMounted(async () => {
<div class="w-[325px]">
<BaseBox
:details-link="`/dashboard/persons?course=${props.courseId}`"
data-cy="dashboard.mentor.competenceSummary"
data-cy="dashboard.mentor.menteeCount"
>
<template #title>{{ $t("a.Personen") }}</template>
<template #content>

View File

@ -21,7 +21,7 @@ onMounted(async () => {
<div class="w-[325px]">
<BaseBox
:details-link="`/course/${props.courseSlug}/learning-mentor/tasks`"
data-cy="dashboard.mentor.competenceSummary"
data-cy="dashboard.mentor.openTasksCount"
>
<template #title>{{ $t("Zu erledigen") }}</template>
<template #content>

View File

@ -49,7 +49,12 @@ async function navigate(routeName: string) {
/>
</div>
<button type="button" class="mt-6 flex items-center" @click="emit('logout')">
<button
type="button"
class="mt-6 flex items-center"
data-cy="logout-button"
@click="emit('logout')"
>
<it-icon-logout class="inline-block" />
<span class="ml-1">{{ $t("mainNavigation.logout") }}</span>
</button>

View File

@ -343,7 +343,11 @@ const mentorTabTitle = computed(() =>
</div>
<div class="nav-item">
<div v-if="userStore.loggedIn" class="flex items-center">
<div
v-if="userStore.loggedIn"
class="flex items-center"
data-cy="header-profile"
>
<Popover class="relative">
<PopoverButton @click="popoverClick($event)">
<div v-if="userStore.avatar_url">

View File

@ -44,6 +44,7 @@ const onFailed = () => {
<button
class="inline-flex flex-1 items-center border-2 p-4 text-left"
:class="currentEvaluation === 'SUCCESS' ? 'border-green-500' : 'border-gray-300'"
data-cy="success"
@click="onPassed"
>
<it-icon-smiley-happy class="mr-4 h-16 w-16"></it-icon-smiley-happy>
@ -54,6 +55,7 @@ const onFailed = () => {
<button
class="inline-flex flex-1 items-center border-2 p-4 text-left"
:class="currentEvaluation === 'FAIL' ? 'border-orange-500' : 'border-gray-300'"
data-cy="fail"
@click="onFailed"
>
<it-icon-smiley-thinking class="mr-4 h-16 w-16"></it-icon-smiley-thinking>

View File

@ -24,7 +24,12 @@ const emit = defineEmits(["release"]);
)
}}
</div>
<ItButton variant="primary" size="large" @click="emit('release')">
<ItButton
variant="primary"
size="large"
data-cy="feedback-release-button"
@click="emit('release')"
>
{{ $t("a.Fremdeinschätzung freigeben") }}
</ItButton>
</template>

View File

@ -51,6 +51,7 @@ const getParticipantById = (id: string): Participant | null => {
v-for="item in selfEvaluationFeedback.completions"
:key="item.user_id"
class="flex flex-col items-start justify-between gap-4 border-b py-2 pl-5 pr-5 last:border-b-0 md:flex-row md:items-center md:justify-between md:gap-16"
:data-cy="`self-evalution-feedback-${item.user_id}`"
>
<!-- Left -->
<div class="flex flex-grow flex-row items-center justify-start">

View File

@ -100,6 +100,7 @@ const onRequestFeedback = async () => {
variant="primary"
size="large"
:disabled="!currentSessionRequestedMentor"
data-cy="request-feedback-button"
@click="onRequestFeedback"
>
<p v-if="!currentSessionRequestedMentor">

View File

@ -0,0 +1,54 @@
import { login, logout } from "../../helpers";
import { TEST_STUDENT1_VV_USER_ID } from "../../../consts";
describe("fremdeinschätzung.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --create-learning-mentor");
});
it("teilnehmer macht selbsteinschätzung; begleiter kann fremdeinschätzung machen", () => {
// teilnehmer macht selbsteinschätzung
login("student-vv@eiger-versicherungen.ch", "test");
cy.visit(
"/course/versicherungsvermittler-in/learn/basis/evaluate/mein-neuer-job-arbeitstechnik-soziale-medien-datenschutz-und-beratungspflichten",
);
cy.makeSelfEvaluation([true, false, true], false);
cy.get('[data-cy="dropdown-select"]').click();
cy.get('[data-cy="dropdown-select-option-Micheala Weber-Mentor"]').click();
cy.get('[data-cy="request-feedback-button"]').click();
cy.get('[data-cy="complete-and-continue"]').click({ force: true });
cy.visit("/");
cy.get('[data-cy="header-profile"]').click();
cy.get('[data-cy="logout-button"]').click();
cy.wait(1000);
// fremdeinschätzung vornehmen
login("test-mentor1@example.com", "test");
cy.visit("/");
cy.get(
'[data-cy="panel-versicherungsvermittler-in"] [data-cy="dashboard.mentor.openTasksCount"]',
).should("contain", "1");
cy.get(
'[data-cy="panel-versicherungsvermittler-in"] [data-cy="dashboard.mentor.openTasksCount"] [data-cy="basebox.detailsLink"]',
).click();
cy.contains("Fremdeinschätzung vornehmen").click();
// viktor vollgas auswählen
cy.get(
`[data-cy="self-evalution-feedback-${TEST_STUDENT1_VV_USER_ID}"]`,
).should("contain", "Selbsteinschätzung geteilt");
cy.contains("Fremdeinschätzung vornehmen").click();
cy.makeSelfEvaluation([true, true, true], false);
cy.get('[data-cy="feedback-release-button"]').click();
cy.get('[data-cy="complete-and-continue"]').click({ force: true });
cy.visit("/");
cy.get(
'[data-cy="panel-versicherungsvermittler-in"] [data-cy="dashboard.mentor.openTasksCount"]',
).should("contain", "0");
});
});

View File

@ -87,13 +87,13 @@ function loadObjectJson(
value,
djangoModelPath,
serializerModelPath,
valueAsString = false
valueAsString = false,
) {
const djangoModel = _.last(djangoModelPath.split("."));
const djangoModelImportPath = _.initial(djangoModelPath.split(".")).join(".");
const serializerModel = _.last(serializerModelPath.split("."));
const serializerModelImportPath = _.initial(
serializerModelPath.split(".")
serializerModelPath.split("."),
).join(".");
let filterPart = `${key}=${value}`;
@ -134,7 +134,7 @@ Cypress.Commands.add("loadAssignmentCompletion", (key, value) => {
value,
"vbv_lernwelt.assignment.models.AssignmentCompletion",
"vbv_lernwelt.assignment.serializers.CypressAssignmentCompletionSerializer",
true
true,
);
});
@ -144,7 +144,7 @@ Cypress.Commands.add("loadSecurityRequestResponseLog", (key, value) => {
value,
"vbv_lernwelt.core.models.SecurityRequestResponseLog",
"vbv_lernwelt.core.serializers.CypressSecurityRequestResponseLogSerializer",
true
true,
);
});
@ -154,7 +154,7 @@ Cypress.Commands.add("loadExternalApiRequestLog", (key, value) => {
value,
"vbv_lernwelt.core.models.ExternalApiRequestLog",
"vbv_lernwelt.core.serializers.CypressExternalApiRequestLogSerializer",
true
true,
);
});
@ -164,7 +164,7 @@ Cypress.Commands.add("loadFeedbackResponse", (key, value) => {
value,
"vbv_lernwelt.feedback.models.FeedbackResponse",
"vbv_lernwelt.feedback.serializers.CypressFeedbackResponseSerializer",
true
true,
);
});
@ -174,7 +174,7 @@ Cypress.Commands.add("loadCheckoutInformation", (key, value) => {
value,
"vbv_lernwelt.shop.models.CheckoutInformation",
"vbv_lernwelt.shop.serializers.CypressCheckoutInformationSerializer",
true
true,
);
});
@ -189,7 +189,7 @@ Cypress.Commands.add("loadUser", (key, value) => {
});
Cypress.Commands.add("makeSelfEvaluation", (answers) => {
Cypress.Commands.add("makeSelfEvaluation", (answers, withCompletion = true) => {
for (let i = 0; i < answers.length; i++) {
const answer = answers[i];
if (answer) {
@ -197,10 +197,15 @@ Cypress.Commands.add("makeSelfEvaluation", (answers) => {
} else {
cy.get('[data-cy="fail"]').click();
}
if (i < answers.length - 1) {
cy.get('[data-cy="next-step"]').click({ force: true });
if (withCompletion) {
if (i < answers.length - 1) {
cy.get('[data-cy="next-step"]').click({ force: true });
} else {
cy.get('[data-cy="complete-and-continue"]').click({ force: true });
}
} else {
cy.get('[data-cy="complete-and-continue"]').click({ force: true });
cy.get('[data-cy="next-step"]').click({ force: true });
}
}
});