chore: navigation tests (desktop)

This commit is contained in:
Livio Bieri 2023-09-21 15:47:39 +02:00
parent 05f111eada
commit 5247b6061b
4 changed files with 85 additions and 24 deletions

View File

@ -23,6 +23,7 @@ const { t } = useTranslation();
<div class="flex space-x-8">
<router-link
data-cy="preview-learn-path-link"
:to="courseSession.learning_path_url"
class="preview-nav-item"
:class="{ 'preview-nav-item--active': inLearningPath() }"
@ -31,6 +32,7 @@ const { t } = useTranslation();
</router-link>
<router-link
data-cy="preview-competence-profile-link"
:to="getCompetenceBaseUrl(courseSession)"
class="preview-nav-item"
:class="{ 'preview-nav-item--active': inCompetenceProfile() }"
@ -46,7 +48,7 @@ const { t } = useTranslation();
<style lang="postcss" scoped>
.preview-nav-item {
@apply inline-flex items-center border-b-4 border-transparent px-1 pt-1 text-black hover:text-gray-800;
@apply inline-flex items-center border-b-4 border-transparent px-1 pt-1 text-black hover:text-gray-900 focus:text-black;
}
.preview-nav-item--active {

View File

@ -109,6 +109,7 @@ onMounted(() => {
<div class="hidden space-x-8 lg:flex">
<template v-if="courseSessionsStore.currentCourseSessionHasCockpit">
<router-link
data-cy="navigation-cockpit-link"
:to="`${courseSessionsStore.currentCourseSession.course_url}/cockpit`"
class="nav-item"
:class="{ 'nav-item--active': inCockpit() }"
@ -117,6 +118,7 @@ onMounted(() => {
</router-link>
<router-link
data-cy="navigation-preview-link"
:to="courseSessionsStore.currentCourseSession.learning_path_url"
target="_blank"
class="nav-item"
@ -129,6 +131,7 @@ onMounted(() => {
</template>
<template v-else>
<router-link
data-cy="navigation-learning-path-link"
:to="courseSessionsStore.currentCourseSession.learning_path_url"
class="nav-item"
:class="{ 'nav-item--active': inLearningPath() }"
@ -137,6 +140,7 @@ onMounted(() => {
</router-link>
<router-link
data-cy="navigation-competence-profile-link"
:to="
getCompetenceBaseUrl(courseSessionsStore.currentCourseSession)
"

View File

@ -0,0 +1,78 @@
import {login} from "./helpers";
describe("Navigation tests", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
});
describe("Desktop view", () => {
beforeEach(() => {
cy.viewport(1280, 720);
});
describe("Expert / Trainer", () => {
beforeEach(() => {
login("test-trainer1@example.com", "test");
});
it("should show course preview on learn", () => {
cy.visit("/course/test-lehrgang/learn/");
cy.get('[data-cy="course-preview-bar"]').should("exist");
})
it("should show course preview on competence", () => {
cy.visit("/course/test-lehrgang/competence/");
cy.get('[data-cy="course-preview-bar"]').should("exist");
});
it("should have correct course preview navigation", () => {
cy.visit("/course/test-lehrgang/learn/");
it("should have see correct navigation", () => {
cy.get('[data-cy="preview-learn-path-link"]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/cockpit');
cy.get('[data-cy="preview-competence-profile-link""]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/learn');
})
})
it("should have correct expert navigation", () => {
// when course session is selected -> cockpit
cy.visit("/course/test-lehrgang/cockpit");
cy.get('[data-cy="navigation-cockpit-link"]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/cockpit');
cy.get('[data-cy="navigation-preview-link"]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/learn');
cy.get('[data-cy="navigation-learning-path-link"]').should("not.exist")
cy.get('[data-cy="navigation-competence-profile-link"]').should("not.exist")
});
});
describe("Participant", () => {
beforeEach(() => {
login("test-student1@example.com", "test");
});
it("should not show course preview on learn path", () => {
cy.visit("/course/test-lehrgang/learn");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
});
it("should not show course preview on learn path", () => {
cy.visit("/course/test-lehrgang/comptence");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
});
it("should have see correct navigation", () => {
// when course session is selected -> learn
cy.visit("/course/test-lehrgang/learn");
cy.get('[data-cy="navigation-competence-profile-link"]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/competence');
cy.get('[data-cy="navigation-learning-path-link"]').should('have.attr', 'href').and('eq', '/course/test-lehrgang/learn');
cy.get('[data-cy="navigation-cockpit-link"]').should("not.exist")
cy.get('[data-cy="navigation-preview-lin"]').should("not.exist")
});
});
});
});

View File

@ -1,23 +0,0 @@
import {login} from "./helpers";
describe("preview.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
});
it("Student does not see preview", () => {
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/learn/fahrzeug");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
});
it("Trainer sees preview exclusively on course", () => {
login("test-trainer1@example.com", "test");
cy.visit("/");
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
cy.visit("/course/test-lehrgang/learn/fahrzeug");
cy.get('[data-cy="course-preview-bar"]').should("exist");
});
});