vbv/cypress/e2e/learning_mentor/overview/mentorAndMember.cy.js

118 lines
3.1 KiB
JavaScript

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_TASKS_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_TASKS_URL);
cy.get(MENTOR_MAIN_NAVIGATION).should("exist");
});
it("shows the mentees navigation link", () => {
cy.visit(MENTOR_TASKS_URL);
cy.get(MENTOR_MENTEES_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_MENTEES_URL);
});
it("shows the overview navigation link", () => {
cy.visit(MENTOR_TASKS_URL);
cy.get(MENTOR_OVERVIEW_NAVIGATION_LINK).click();
cy.url().should("include", MENTOR_TASKS_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");
});
});