Hide documents link conditionally

This commit is contained in:
Ramon Wenger 2024-11-12 16:02:50 +01:00
parent 55515dd10f
commit 93660cf421
2 changed files with 27 additions and 4 deletions

View File

@ -1,9 +1,11 @@
<script setup lang="ts">
import SubNavigation from "@/components/header/SubNavigation.vue";
import { useCurrentCourseSession } from "@/composables";
import { useExpertCockpitPageData } from "@/pages/cockpit/cockpitPage/composables";
import { ATTENDANCE_ROUTE, COCKPIT_ROUTE, DOCUMENTS_ROUTE } from "@/router/names";
import { useTranslation } from "i18next-vue";
import log from "loglevel";
import { computed } from "vue";
const props = defineProps<{
courseSlug: string;
@ -25,10 +27,25 @@ const documentsRoute = {
const { t } = useTranslation();
const items = [
const courseSession = useCurrentCourseSession();
const enableDocuments = computed(() => {
return !!courseSession.value.course.configuration.enable_circle_documents;
});
const items = computed(() => [
{ id: 1, name: t("a.Übersicht"), route: defaultRoute },
{ id: 2, name: t("a.Teilnehmer"), route: attendanceRoute },
{ id: 3, name: t("a.Unterlagen"), route: documentsRoute },
...(enableDocuments.value
? [
{
id: 3,
name: t("a.Unterlagen"),
route: documentsRoute,
dataCy: "circle-documents",
},
]
: []),
{
id: 4,
@ -40,7 +57,7 @@ const items = [
name: "MS Teams",
route: "https://vbvbern.sharepoint.com/sites/myVBV-AFA_K-CI",
},
];
]);
</script>
<template>

View File

@ -1,20 +1,24 @@
import {EXPERT_COCKPIT_URL, login} from "./helpers";
import { EXPERT_COCKPIT_URL, login } from "./helpers";
describe("settings.cy.js", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
cy.intercept("/server/graphql").as("graphql");
});
describe("with circle documents enabled", () => {
it("student can see circle documents", () => {
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/learn/fahrzeug");
cy.wait(["@graphql", "@graphql"]);
cy.get('[data-cy="circle-document-section"]').should("exist");
});
it("trainer can see circle documents", () => {
login("test-trainer1@example.com", "test");
cy.visit(EXPERT_COCKPIT_URL);
cy.wait(["@graphql", "@graphql"]);
cy.get('[data-cy="circle-documents"]').should("exist");
});
});
@ -27,6 +31,7 @@ describe("settings.cy.js", () => {
it("student cannot see circle documents", () => {
login("test-student1@example.com", "test");
cy.visit("/course/test-lehrgang/learn/fahrzeug");
cy.wait(["@graphql", "@graphql"]);
cy.get('[data-cy="circle-title"]').should("contain", "Fahrzeug");
cy.get('[data-cy="circle-document-section"]').should("not.exist");
});
@ -34,6 +39,7 @@ describe("settings.cy.js", () => {
it("trainer cannot see circle documents", () => {
login("test-trainer1@example.com", "test");
cy.visit(EXPERT_COCKPIT_URL);
cy.wait(["@graphql", "@graphql"]);
cy.get('[data-cy="circle-documents"]').should("not.exist");
});
});