vbv/cypress/e2e/navigation.cy.js

104 lines
2.8 KiB
JavaScript

import {
checkNavigationLink,
EXPERT_LOGIN,
login,
PARTICIPANT_LOGIN,
visitCoursePage,
} from "./helpers";
describe("navigation.cy.js", () => {
const openMobileNavigation = () => {
cy.get('[data-cy="navigation-mobile-menu-button"]').click();
};
beforeEach(() => {
cy.manageCommand("cypress_reset");
});
describe("Desktop view", () => {
beforeEach(() => {
cy.viewport(1280, 720);
});
describe("Expert / Trainer", () => {
beforeEach(() => {
login(...EXPERT_LOGIN);
visitCoursePage("cockpit");
});
it("should have correct expert navigation", () => {
checkNavigationLink("navigation-cockpit-link", "cockpit");
checkNavigationLink("navigation-preview-link", "learn");
cy.get('[data-cy="navigation-competence-profile-link"]').should(
"not.exist"
);
cy.get('[data-cy="navigation-learning-path-link"]').should("not.exist");
});
});
describe("Participant", () => {
beforeEach(() => {
login(...PARTICIPANT_LOGIN);
visitCoursePage("learn");
});
it("should have correct navigation", () => {
checkNavigationLink("navigation-competence-profile-link", "competence");
checkNavigationLink("navigation-learning-path-link", "learn");
cy.get('[data-cy="navigation-cockpit-link"]').should("not.exist");
cy.get('[data-cy="navigation-preview-link"]').should("not.exist");
});
});
});
describe("Mobile view", () => {
beforeEach(() => {
cy.viewport(375, 667);
});
describe("Expert / Trainer", () => {
beforeEach(() => {
login(...EXPERT_LOGIN);
visitCoursePage("cockpit");
openMobileNavigation();
});
it("should have correct expert navigation", () => {
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should("exist");
cy.get('[data-cy="navigation-mobile-preview-link"]').should("exist");
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should(
"not.exist"
);
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should(
"not.exist"
);
});
});
describe("Participant", () => {
beforeEach(() => {
login(...PARTICIPANT_LOGIN);
visitCoursePage("learn");
openMobileNavigation();
});
it("should have correct navigation", () => {
cy.get('[data-cy="navigation-mobile-cockpit-link"]').should(
"not.exist"
);
cy.get('[data-cy="navigation-mobile-preview-link"]').should(
"not.exist"
);
cy.get('[data-cy="navigation-mobile-competence-profile-link"]').should(
"exist"
);
cy.get('[data-cy="navigation-mobile-learning-path-link"]').should(
"exist"
);
});
});
});
});