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_TASKS_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_MENTEES_URL); }); it("shows the learning mentor navigation", () => { cy.visit(MENTOR_MENTEES_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 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" ); }); });