Add cypress tests
This commit is contained in:
parent
993c9bb536
commit
f96733d9ea
|
|
@ -8,7 +8,12 @@
|
|||
</h3>
|
||||
<h4 class="grid-in-subtitle">{{ subtitle }}</h4>
|
||||
<div class="flex items-center justify-end gap-x-4 grid-in-icons">
|
||||
<a v-if="canDelete" class="flex cursor-pointer" @click="emit('delete')">
|
||||
<a
|
||||
v-if="canDelete"
|
||||
class="flex cursor-pointer"
|
||||
data-cy="document-delete-button"
|
||||
@click="emit('delete')"
|
||||
>
|
||||
<it-icon-delete class="h-8 w-8" />
|
||||
</a>
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ const canEditDocuments = computed(() => {
|
|||
const circleExperts = courseSessionDetailResult.filterCircleExperts(
|
||||
cockpitStore.currentCircle?.slug || ""
|
||||
);
|
||||
// hack-ish way to check if the user is an expert for the circle
|
||||
// supervistors are not allowd to edit documents if they are not experts in the circle
|
||||
return circleExperts.some(
|
||||
(expert) =>
|
||||
expert.user_id === userStore.id &&
|
||||
|
|
@ -157,6 +159,7 @@ async function uploadDocument(data: DocumentUploadData) {
|
|||
<button
|
||||
v-if="canEditDocuments"
|
||||
class="btn-primary mb-6 text-xl"
|
||||
data-cy="document-upload-button"
|
||||
@click="showUploadModal = true"
|
||||
>
|
||||
{{ t("circlePage.documents.action") }}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@
|
|||
{{ $t("circlePage.documents.userDescription") }}
|
||||
</div>
|
||||
</div>
|
||||
<ul v-if="circleDocuments.length" class="mt-8 border-t border-t-gray-500">
|
||||
<ul
|
||||
v-if="circleDocuments.length"
|
||||
class="mt-8 border-t border-t-gray-500"
|
||||
data-cy="circle-page-documents"
|
||||
>
|
||||
<DocumentListItem
|
||||
v-for="doc of circleDocuments"
|
||||
:key="doc.url"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
import { login } from "../helpers";
|
||||
|
||||
describe("cockpitDocuments.cy.js", () => {
|
||||
beforeEach(() => {
|
||||
cy.manageCommand("cypress_reset");
|
||||
});
|
||||
|
||||
describe("Cockpit Document list", () => {
|
||||
it("Trainer sees document mutation buttons", () => {
|
||||
login("test-trainer1@example.com", "test");
|
||||
cy.visit("/course/test-lehrgang/cockpit/documents");
|
||||
|
||||
cy.get('[data-cy="document-upload-button"]').should("exist");
|
||||
cy.get('[data-cy="document-delete-button"]').should("exist");
|
||||
});
|
||||
|
||||
it("Supervisor does not see document mutation buttons", () => {
|
||||
login("test-supervisor1@example.com", "test");
|
||||
cy.visit("/course/test-lehrgang/cockpit/documents");
|
||||
|
||||
cy.get('[data-cy="document-upload-button"]').should("not.exist");
|
||||
cy.get('[data-cy="document-delete-button"]').should("not.exist");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Preview", () => {
|
||||
it("Supervisor sees documents list", () => {
|
||||
login("test-supervisor1@example.com", "test");
|
||||
cy.visit("/course/test-lehrgang/learn/fahrzeug");
|
||||
|
||||
cy.get('[data-cy="circle-page-documents"]').should("exist");
|
||||
});
|
||||
|
||||
it("Berufsbildner sees document list", () => {
|
||||
login("test-berufsbildner1@example.com", "test");
|
||||
cy.visit("/course/test-lehrgang/learn/fahrzeug");
|
||||
|
||||
cy.get('[data-cy="circle-page-documents"]').should("exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -2,6 +2,7 @@ from collections import deque
|
|||
from datetime import datetime
|
||||
|
||||
from dateutil.relativedelta import MO, TH, TU, WE, relativedelta
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.utils import timezone
|
||||
from slugify import slugify
|
||||
from wagtail.rich_text import RichText
|
||||
|
|
@ -48,6 +49,7 @@ from vbv_lernwelt.core.utils import safe_deque_popleft
|
|||
from vbv_lernwelt.course.consts import COURSE_TEST_ID
|
||||
from vbv_lernwelt.course.factories import CoursePageFactory
|
||||
from vbv_lernwelt.course.models import (
|
||||
CircleDocument,
|
||||
Course,
|
||||
CourseCategory,
|
||||
CourseConfiguration,
|
||||
|
|
@ -63,12 +65,14 @@ from vbv_lernwelt.course_session.models import (
|
|||
)
|
||||
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||
from vbv_lernwelt.feedback.services import update_feedback_response
|
||||
from vbv_lernwelt.files.models import UploadFile
|
||||
from vbv_lernwelt.learning_mentor.models import AgentParticipantRelation
|
||||
from vbv_lernwelt.learnpath.models import (
|
||||
Circle,
|
||||
LearningContentAssignment,
|
||||
LearningContentAttendanceCourse,
|
||||
LearningContentEdoniqTest,
|
||||
LearningSequence,
|
||||
)
|
||||
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
||||
CircleFactory,
|
||||
|
|
@ -187,6 +191,27 @@ def create_test_course(
|
|||
)
|
||||
csac.due_date.save()
|
||||
|
||||
# create fake doc (will be uploaded to aws)
|
||||
ls = LearningSequence.objects.get(
|
||||
title="Vorbereitung",
|
||||
slug="test-lehrgang-lp-circle-fahrzeug-ls-vorbereitung",
|
||||
)
|
||||
fake_file = SimpleUploadedFile(
|
||||
"fake_file.txt", b"file_content_here", content_type="text/plain"
|
||||
)
|
||||
pseudo_file = UploadFile.objects.create(
|
||||
file=fake_file,
|
||||
original_file_name="Test Dokument",
|
||||
file_name="Test Dokument",
|
||||
file_type="txt",
|
||||
)
|
||||
CircleDocument.objects.create(
|
||||
file=pseudo_file,
|
||||
name="Test Dokument)",
|
||||
course_session=cs_bern,
|
||||
learning_sequence=ls,
|
||||
)
|
||||
|
||||
if include_vv:
|
||||
csac = CourseSessionAttendanceCourse.objects.create(
|
||||
course_session=cs_bern,
|
||||
|
|
|
|||
Loading…
Reference in New Issue