chore: cypress tests for learning mentor

This commit is contained in:
Livio Bieri 2024-03-26 16:17:26 +01:00
parent a804df5ae4
commit ed685b9c78
12 changed files with 318 additions and 8 deletions

View File

@ -22,6 +22,7 @@ const removeMyMentee = async (menteeId: string) => {
<div
v-for="participant in summary.participants"
:key="participant.id"
data-cy="lm-my-mentee-list-item"
class="flex flex-col items-start justify-between gap-4 border-b py-2 last:border-b-0 md:flex-row md:items-center md:gap-16"
>
<div class="flex items-center space-x-2">
@ -42,6 +43,7 @@ const removeMyMentee = async (menteeId: string) => {
</div>
<div class="space-x-5">
<router-link
data-cy="lm-my-mentee-profile"
:to="{
name: 'profileLearningPath',
params: {
@ -53,7 +55,11 @@ const removeMyMentee = async (menteeId: string) => {
>
{{ $t("cockpit.profileLink") }}
</router-link>
<button class="underline" @click="removeMyMentee(participant.id)">
<button
class="underline"
data-cy="lm-my-mentee-remove"
@click="removeMyMentee(participant.id)"
>
{{ $t("a.Entfernen") }}
</button>
</div>

View File

@ -113,6 +113,7 @@ const inviteMentor = async () => {
<div
v-for="learningMentor in mentors"
:key="learningMentor.id"
data-cy="lm-my-mentor-list-item"
class="flex flex-col justify-between gap-4 border-b py-2 last:border-b-0 md:flex-row md:gap-16"
>
<div class="flex items-center space-x-2">
@ -129,7 +130,11 @@ const inviteMentor = async () => {
{{ learningMentor.mentor.email }}
</div>
</div>
<button class="underline" @click="removeMyMentor(learningMentor.id)">
<button
class="underline"
data-cy="lm-my-mentor-remove"
@click="removeMyMentor(learningMentor.id)"
>
{{ $t("a.Entfernen") }}
</button>
</div>

View File

@ -13,6 +13,7 @@ const dashboardStore = useDashboardStore();
<div>
<router-link
class="btn-blue"
data-cy="lm-dashboard-link"
:to="getLearningMentorUrl(dashboardStore.currentDashboardConfig.slug)"
>
{{ $t("a.Übersicht anschauen") }}

View File

@ -74,7 +74,7 @@ const showCompetenceCertificates = computed(() => {
<router-link
class="btn-blue"
:to="getLearningPathUrl(dashboardStore.currentDashboardConfig.slug)"
:data-cy="`continue-course-${dashboardStore.currentDashboardConfig.id}`"
data-cy="progress-dashboard-continue-course-link"
>
{{ $t("general.nextStep") }}
</router-link>

View File

@ -14,7 +14,6 @@ const dashboardStore = useDashboardStore();
<router-link
class="btn-blue"
:to="getCockpitUrl(dashboardStore.currentDashboardConfig.slug)"
:data-cy="`continue-course-${dashboardStore.currentDashboardConfig.id}`"
>
{{ $t("a.Cockpit anschauen") }}
</router-link>

View File

@ -22,7 +22,11 @@ onMounted(() => {
<template>
<div class="bg-gray-200">
<nav v-if="isMentoring" class="border-b bg-white px-4 lg:px-8">
<nav
v-if="isMentoring"
class="border-b bg-white px-4 lg:px-8"
data-cy="lm-main-navigation"
>
<ul class="flex flex-col lg:flex-row">
<li
class="border-t-2 border-t-transparent"
@ -32,12 +36,17 @@ onMounted(() => {
.startsWith('learningMentor'),
}"
>
<router-link :to="{ name: 'learningMentorOverview' }" class="block py-3">
<router-link
data-cy="lm-overview-navigation-link"
:to="{ name: 'learningMentorOverview' }"
class="block py-3"
>
{{ $t("a.Übersicht") }}
</router-link>
</li>
<li
data-cy="lm-mentees-navigation-link"
class="border-t-2 border-t-transparent lg:ml-12"
:class="{
'border-b-2 border-b-blue-900': route.name === 'mentorsAndParticipants',

View File

@ -19,10 +19,10 @@ const isMyMenteesVisible = computed(() =>
<div class="container-large space-y-20">
<template v-if="isMyMenteesVisible || isMyMentorsVisible">
<div v-if="isMyMentorsVisible">
<MyMentors />
<MyMentors data-cy="lm-my-mentors" />
</div>
<div v-if="isMyMenteesVisible">
<MyMentees />
<MyMentees data-cy="lm-my-mentees" />
</div>
</template>
</div>

View File

@ -0,0 +1,6 @@
Since the learning mentor behaves differently depending on the user's role, the learning mentor is tested in the
following roles:
- [x] As a learning mentor (no other roles). -> `justMentor.cy.js`
- [x] As a course session user (member, no other roles). -> `justMember.cy.js`
- [x] As a course session user (member) and a learning mentor. `mentorAndMember.cy.js`

View File

@ -0,0 +1,23 @@
export const MENTOR_OVERVIEW_URL = "/course/versicherungsvermittler-in/learning-mentor";
export const MENTOR_MENTEES_URL = "/course/versicherungsvermittler-in/learning-mentor/participants";
export const MENTOR_DASHBOARD_LINK = "[data-cy=lm-dashboard-link]";
export const MEMBER_DASHBOARD_LINK = "[data-cy=progress-dashboard-continue-course-link]";
export const MENTOR_MAIN_NAVIGATION = "[data-cy=lm-main-navigation]";
export const MENTOR_OVERVIEW_NAVIGATION_LINK = "[data-cy=lm-overview-navigation-link]";
export const MENTOR_MENTEES_NAVIGATION_LINK = "[data-cy=lm-mentees-navigation-link]";
// /participants
export const MENTOR_MY_MENTEES = "[data-cy=lm-my-mentees]";
export const MENTOR_MY_MENTORS = "[data-cy=lm-my-mentors]";
export const MENTOR_MENTEE_LIST_ITEM = "[data-cy=lm-my-mentee-list-item]";
export const MENTOR_MENTEE_REMOVE = "[data-cy=lm-my-mentee-remove]";
export const MENTOR_MENTEE_PROFILE = "[data-cy=lm-my-mentee-profile]";
export const MENTEE_MENTOR_LIST_ITEM = "[data-cy=lm-my-mentor-list-item]";
export const MENTEE_MENTOR_REMOVE = "[data-cy=lm-my-mentor-remove]";

View File

@ -0,0 +1,58 @@
import {login} from "../../helpers";
import {
MEMBER_DASHBOARD_LINK,
MENTEE_MENTOR_LIST_ITEM,
MENTEE_MENTOR_REMOVE,
MENTOR_MENTEES_NAVIGATION_LINK,
MENTOR_MENTEES_URL,
MENTOR_MY_MENTEES,
MENTOR_MY_MENTORS,
MENTOR_OVERVIEW_NAVIGATION_LINK,
MENTOR_OVERVIEW_URL
} from "../constants";
describe("memberOnly.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --create-learning-mentor");
login("student-vv@eiger-versicherungen.ch", "test");
});
it("shows the correct dashboard", () => {
cy.visit("/");
cy.get(MEMBER_DASHBOARD_LINK).should("exist");
});
it("shows NO mentees navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_MENTEES_NAVIGATION_LINK).should("not.exist");
})
it("shows NO overview navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_OVERVIEW_NAVIGATION_LINK).should("not.exist");
})
it("shows NO mentees", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTEES).should("not.exist");
});
it("shows my mentors", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTORS).should("exist");
});
it("can remove a mentor", () => {
// given
const mentor = "Micheala Weber-Mentor";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTEE_MENTOR_LIST_ITEM, mentor)
.find(MENTEE_MENTOR_REMOVE)
.click();
// then
cy.contains(MENTOR_MY_MENTORS, mentor).should("not.exist");
})
});

View File

@ -0,0 +1,112 @@
import {login} from "../../helpers";
import {
MEMBER_DASHBOARD_LINK,
MENTEE_MENTOR_LIST_ITEM,
MENTEE_MENTOR_REMOVE,
MENTOR_MAIN_NAVIGATION,
MENTOR_MENTEE_LIST_ITEM,
MENTOR_MENTEE_PROFILE,
MENTOR_MENTEE_REMOVE,
MENTOR_MENTEES_NAVIGATION_LINK,
MENTOR_MENTEES_URL,
MENTOR_MY_MENTEES,
MENTOR_MY_MENTORS,
MENTOR_OVERVIEW_NAVIGATION_LINK,
MENTOR_OVERVIEW_URL
} from "../constants";
describe("mentorAndMember.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --create-learning-mentor");
login("test-student-and-mentor2@example.com", "test");
});
it("shows the correct dashboard", () => {
cy.visit("/");
cy.get(MEMBER_DASHBOARD_LINK).should("exist");
});
it("shows the learning mentor navigation", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_MAIN_NAVIGATION).should("exist");
});
it("shows the mentees navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_MENTEES_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_MENTEES_URL);
})
it("shows the overview navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_OVERVIEW_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_OVERVIEW_URL);
})
it("shows my mentees", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTEES).should("exist");
});
it("shows my mentors", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTORS).should("exist");
});
it("shows the correct mentees", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTEES).should("contain", "Viktor Vollgas");
});
it("shows the profile of a mentee", () => {
// given
const mentee = "Viktor Vollgas";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee)
.find(MENTOR_MENTEE_PROFILE)
.click();
// then
const expectedMenteeProfileUrl = "/course/versicherungsvermittler-in/profile/5ff59857-8de5-415e-a387-4449f9a0337a"
cy.url().should("include", expectedMenteeProfileUrl);
cy.contains(mentee).should("exist");
})
it("can remove a mentee", () => {
// given
const mentee = "Viktor Vollgas";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee)
.find(MENTOR_MENTEE_REMOVE)
.click();
// then
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee).should("not.exist");
cy.contains("Aktuell begleitest du niemanden als Lernbegleitung").should("exist");
})
it("shows the correct mentors", () => {
const mentor = "Micheala Weber-Mentor";
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTORS).should("contain", mentor);
})
it("can remove a mentor", () => {
// given
const mentor = "Micheala Weber-Mentor";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTEE_MENTOR_LIST_ITEM, mentor)
.find(MENTEE_MENTOR_REMOVE)
.click();
// then
cy.contains(MENTOR_MY_MENTORS, mentor).should("not.exist");
cy.contains("Aktuell hast du noch keine Person als Lernbegleitung eingeladen").should("exist");
})
});

View File

@ -0,0 +1,91 @@
import {login} from "../../helpers";
import {
MENTOR_DASHBOARD_LINK,
MENTOR_MAIN_NAVIGATION,
MENTOR_MENTEE_LIST_ITEM,
MENTOR_MENTEE_PROFILE,
MENTOR_MENTEE_REMOVE,
MENTOR_MENTEES_NAVIGATION_LINK,
MENTOR_MENTEES_URL,
MENTOR_MY_MENTEES,
MENTOR_MY_MENTORS,
MENTOR_OVERVIEW_NAVIGATION_LINK,
MENTOR_OVERVIEW_URL
} from "../constants";
describe("mentorOnly.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset --create-learning-mentor");
login("test-mentor1@example.com", "test");
});
it("shows the correct dashboard", () => {
cy.visit("/");
cy.get(MENTOR_DASHBOARD_LINK).click();
cy.url().should("include", MENTOR_OVERVIEW_URL);
});
it("shows the learning mentor navigation", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_MAIN_NAVIGATION).should("exist");
});
it("shows the mentees navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_MENTEES_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_MENTEES_URL);
})
it("shows the overview navigation link", () => {
cy.visit(MENTOR_OVERVIEW_URL);
cy.get(MENTOR_OVERVIEW_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_OVERVIEW_URL);
})
it("shows my mentees", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTEES).should("exist");
});
it("shows no mentors", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTORS).should("not.exist");
});
it("shows the correct mentees", () => {
cy.visit(MENTOR_MENTEES_URL);
cy.get(MENTOR_MY_MENTEES).should("contain", "Robert Student-plus-Mentor");
cy.get(MENTOR_MY_MENTEES).should("contain", "Viktor Vollgas");
});
it("shows the profile of a mentee", () => {
// given
const mentee = "Viktor Vollgas";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee)
.find(MENTOR_MENTEE_PROFILE)
.click();
// then
const expectedMenteeProfileUrl = "/course/versicherungsvermittler-in/profile/5ff59857-8de5-415e-a387-4449f9a0337a"
cy.url().should("include", expectedMenteeProfileUrl);
cy.contains(mentee).should("exist");
})
it("can remove a mentee", () => {
// given
const mentee = "Viktor Vollgas";
// when
cy.visit(MENTOR_MENTEES_URL);
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee)
.find(MENTOR_MENTEE_REMOVE)
.click();
// then
cy.contains(MENTOR_MENTEE_LIST_ITEM, mentee).should("not.exist");
cy.contains(MENTOR_MENTEE_LIST_ITEM, "Robert Student-plus-Mentor").should("exist")
})
});