chore: more tests for mobile navigation
This commit is contained in:
parent
d87f922dec
commit
dbe74f754b
|
|
@ -77,7 +77,11 @@ onMounted(() => {
|
||||||
<div class="relative flex h-16 justify-between">
|
<div class="relative flex h-16 justify-between">
|
||||||
<div class="absolute inset-y-0 left-0 flex items-center lg:hidden">
|
<div class="absolute inset-y-0 left-0 flex items-center lg:hidden">
|
||||||
<!-- Mobile menu button -->
|
<!-- Mobile menu button -->
|
||||||
<div class="flex" @click="state.showMobileNavigationMenu = true">
|
<div
|
||||||
|
data-cy="navigation-mobile-menu-button"
|
||||||
|
class="flex"
|
||||||
|
@click="state.showMobileNavigationMenu = true"
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="h-8 w-8 text-white hover:text-sky-500 focus:text-sky-500 focus:outline-none"
|
class="h-8 w-8 text-white hover:text-sky-500 focus:text-sky-500 focus:outline-none"
|
||||||
|
|
|
||||||
|
|
@ -58,24 +58,36 @@ const courseSessionsStore = useCourseSessionsStore();
|
||||||
<ul class="mt-6">
|
<ul class="mt-6">
|
||||||
<template v-if="courseSessionsStore.currentCourseSessionHasCockpit">
|
<template v-if="courseSessionsStore.currentCourseSessionHasCockpit">
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button @click="clickLink(`${courseSession.course_url}/cockpit`)">
|
<button
|
||||||
|
data-cy="navigation-mobile-cockpit-link"
|
||||||
|
@click="clickLink(`${courseSession.course_url}/cockpit`)"
|
||||||
|
>
|
||||||
{{ $t("cockpit.title") }}
|
{{ $t("cockpit.title") }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button @click="clickLink(courseSession.learning_path_url)">
|
<button
|
||||||
|
data-cy="navigation-mobile-preview-link"
|
||||||
|
@click="clickLink(courseSession.learning_path_url)"
|
||||||
|
>
|
||||||
{{ $t("a.VorschauTeilnehmer") }}
|
{{ $t("a.VorschauTeilnehmer") }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button @click="clickLink(courseSession.learning_path_url)">
|
<button
|
||||||
|
data-cy="navigation-mobile-learning-path-link"
|
||||||
|
@click="clickLink(courseSession.learning_path_url)"
|
||||||
|
>
|
||||||
{{ $t("general.learningPath") }}
|
{{ $t("general.learningPath") }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="mb-6">
|
<li class="mb-6">
|
||||||
<button @click="clickLink(getCompetenceBaseUrl(courseSession))">
|
<button
|
||||||
|
data-cy="navigation-mobile-competence-profile-link"
|
||||||
|
@click="clickLink(getCompetenceBaseUrl(courseSession))"
|
||||||
|
>
|
||||||
{{ $t("competences.title") }}
|
{{ $t("competences.title") }}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
export const login = (username, password) => {
|
export const login = (username, password) => {
|
||||||
cy.request({
|
cy.request({
|
||||||
method: "POST",
|
method: "POST", url: "/api/core/login/", body: {username, password},
|
||||||
url: "/api/core/login/",
|
});
|
||||||
body: { username, password },
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logout = () => {
|
export const logout = () => {
|
||||||
cy.request({
|
cy.request({
|
||||||
method: "POST",
|
method: "POST", url: "/api/core/logout/",
|
||||||
url: "/api/core/logout/",
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const BASE_URL = "/course/test-lehrgang";
|
||||||
|
export const EXPERT_LOGIN = ["test-trainer1@example.com", "test"];
|
||||||
|
export const PARTICIPANT_LOGIN = ["test-student1@example.com", "test"];
|
||||||
|
|
||||||
|
export const visitCoursePage = (subPath) => {
|
||||||
|
cy.visit(`${BASE_URL}/${subPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const checkNavigationLink = (dataCy, expectedLink) => {
|
||||||
|
cy.get(`[data-cy="${dataCy}"]`).should('have.attr', 'href').and('eq', `${BASE_URL}/${expectedLink}`);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
import {login} from "./helpers";
|
import {checkNavigationLink, EXPERT_LOGIN, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers";
|
||||||
|
|
||||||
const BASE_URL = "/course/test-lehrgang";
|
const openMobileNavigation = () => {
|
||||||
const EXPERT_LOGIN = ["test-trainer1@example.com", "test"];
|
cy.get('[data-cy="navigation-mobile-menu-button"]').click();
|
||||||
const PARTICIPANT_LOGIN = ["test-student1@example.com", "test"];
|
|
||||||
|
|
||||||
const visitCoursePage = (subPath) => {
|
|
||||||
cy.visit(`${BASE_URL}/${subPath}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkNavigationLink = (dataCy, expectedLink) => {
|
|
||||||
cy.get(`[data-cy="${dataCy}"]`).should('have.attr', 'href').and('eq', `${BASE_URL}/${expectedLink}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Navigation tests", () => {
|
describe("Navigation tests", () => {
|
||||||
|
|
@ -25,48 +17,68 @@ describe("Navigation tests", () => {
|
||||||
describe("Expert / Trainer", () => {
|
describe("Expert / Trainer", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
login(...EXPERT_LOGIN);
|
login(...EXPERT_LOGIN);
|
||||||
});
|
visitCoursePage("cockpit");
|
||||||
|
|
||||||
it("should show course preview on learn", () => {
|
|
||||||
visitCoursePage("learn");
|
|
||||||
cy.get('[data-cy="course-preview-bar"]').should("exist");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show course preview on competence", () => {
|
|
||||||
visitCoursePage("competence");
|
|
||||||
cy.get('[data-cy="course-preview-bar"]').should("exist");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should have correct course preview navigation", () => {
|
|
||||||
visitCoursePage("learn");
|
|
||||||
checkNavigationLink("preview-learn-path-link", "cockpit");
|
|
||||||
checkNavigationLink("preview-competence-profile-link", "learn");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have correct expert navigation", () => {
|
it("should have correct expert navigation", () => {
|
||||||
visitCoursePage("cockpit");
|
|
||||||
checkNavigationLink("navigation-cockpit-link", "cockpit");
|
checkNavigationLink("navigation-cockpit-link", "cockpit");
|
||||||
checkNavigationLink("navigation-preview-link", "learn");
|
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", () => {
|
describe("Participant", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
login(...PARTICIPANT_LOGIN);
|
login(...PARTICIPANT_LOGIN);
|
||||||
});
|
|
||||||
|
|
||||||
it("should not show course preview on learn path", () => {
|
|
||||||
visitCoursePage("learn");
|
visitCoursePage("learn");
|
||||||
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have correct navigation", () => {
|
it("should have correct navigation", () => {
|
||||||
visitCoursePage("learn");
|
|
||||||
checkNavigationLink("navigation-competence-profile-link", "competence");
|
checkNavigationLink("navigation-competence-profile-link", "competence");
|
||||||
checkNavigationLink("navigation-learning-path-link", "learn");
|
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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
import {checkNavigationLink, login, PARTICIPANT_LOGIN, visitCoursePage} from "./helpers";
|
||||||
|
|
||||||
|
describe("Preview Bar", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.manageCommand("cypress_reset");
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("Expert / Trainer", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
login("test-trainer1@example.com", "test");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show course preview on learn", () => {
|
||||||
|
visitCoursePage("learn");
|
||||||
|
cy.get('[data-cy="course-preview-bar"]').should("exist");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show course preview on competence", () => {
|
||||||
|
visitCoursePage("competence");
|
||||||
|
cy.get('[data-cy="course-preview-bar"]').should("exist");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should have correct course preview navigation", () => {
|
||||||
|
visitCoursePage("learn");
|
||||||
|
checkNavigationLink("preview-learn-path-link", "learn");
|
||||||
|
checkNavigationLink("preview-competence-profile-link", "competence");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Participant", () => {
|
||||||
|
before(() => {
|
||||||
|
login(...PARTICIPANT_LOGIN);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not show course preview on learn path", () => {
|
||||||
|
visitCoursePage("learn");
|
||||||
|
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not show course preview on competence", () => {
|
||||||
|
visitCoursePage("competence");
|
||||||
|
cy.get('[data-cy="course-preview-bar"]').should("not.exist");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue