BUG: fix for failing tests due to ended semester

This commit is contained in:
Ivymaster
2026-07-08 15:33:33 +02:00
parent 1805fc643e
commit a50ee86940
19 changed files with 246 additions and 204 deletions
+4 -1
View File
@@ -479,6 +479,7 @@ export default {
class="fhc-calendar-base-grid"
style="display:grid;width:100%;height:100%;overflow:auto"
:style="'grid-template-' + axisRow + 's:auto' + (allDayEvents ? ' auto ' : ' ') + '1fr;grid-template-' + axisCol + 's:auto ' + styleGridCols"
data-cy="calendar-base-grid"
>
<div
class="grid-header"
@@ -556,6 +557,8 @@ export default {
<div
v-for="(part, i) in axisPartsSave"
:key="i"
data-cy="calendar-grid-part"
:data-drop-index="index * axisPartsSave.length + i + 1"
class="part-body"
style="position:relative"
:style="'grid-' + axisCol + ':' + (1+index) + ';grid-' + axisRow + ':ps_' + i + '/pe_' + i"
@@ -597,4 +600,4 @@ export default {
</div>
</div>
`
}
}
@@ -116,6 +116,7 @@ export default {
v-draggable:move.noimage="draggable ? dragKalenderCollection : {}"
v-cal-click:event="isHeaderOrFooter ? event : event.orig"
@contextmenu.prevent="onRightClick"
data-cy="calendar-event"
>
<div
v-if="resizable"
@@ -19,6 +19,7 @@ export default {
class="fhc-calendar-base-grid-line-event event"
v-draggable:move.noimage="dragKalenderCollection"
style="border:1px"
data-cy="calendar-event"
>
<div class="title">
{{ event.orig.topic || event.orig.titel || event.orig.lehrfach }}
@@ -360,6 +360,7 @@ export default {
:title="node.data.studiengang_kz"
v-drag-click="() => toggleTreeNode(node)"
v-drop:link-strict.student-collection="(evt, students) => dropStudents(node, students)"
data-cy="course-tree-row"
>
{{ node.data.name }}
</span>
@@ -368,6 +369,7 @@ export default {
:data-tree-item-key="node.key"
:title="node.data.studiengang_kz"
v-drag-click="() => toggleTreeNode(node)"
data-cy="course-tree-row"
>
{{ node.data.name }}
</span>
@@ -81,7 +81,7 @@ export default {
</div>
<div class="event-text" v-tooltip="tooltipString">
<span class="event-topic">{{ event.topic }}</span>
<span class="event-place">{{ event.ort_kurzbz }}</span>
<span data-cy="calendar-event-room" class="event-place">{{ event.ort_kurzbz }}</span>
<span
v-for="(lektor,index) in event.lektor.slice(0, 3)"
class="event-lectors"
@@ -86,7 +86,7 @@ export default {
>
... +{{ event.lektor.length - 3 }}
</span>
<span class="event-place">{{ event.ort_kurzbz }}</span>
<span data-cy="calendar-event-room" class="event-place">{{ event.ort_kurzbz }}</span>
</div>
</div>
`,
+9 -1
View File
@@ -25,4 +25,12 @@ DECLARE res varchar(32);
SELECT studiensemester_kurzbz into res FROM public.tbl_studiensemester WHERE start<=now() AND ende>=now() ORDER BY start DESC LIMIT 1;
return res;
END;
$$ LANGUAGE plpgsql;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION LastActiveSemester() RETURNS varchar(32) AS $$
DECLARE res varchar(32);
BEGIN
SELECT studiensemester_kurzbz into res FROM public.tbl_studiensemester WHERE start<=now() ORDER BY start DESC LIMIT 1;
return res;
END;
$$ LANGUAGE plpgsql;
+7 -8
View File
@@ -122,7 +122,7 @@ INSERT INTO lehre.tbl_studienplan_semester (studienplan_id, studiensemester_kurz
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51001, 5221, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5221, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5221, 1);
VALUES(51001, 5221, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5221, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5221, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -137,7 +137,7 @@ INSERT INTO lehre.tbl_lehreinheitmitarbeiter
VALUES(51001, 'demolektor1', 'Lektor', 0, NULL, 1.00, NULL, true, NULL, NULL, '2023-08-24 14:58:40.000', 'oesi', NULL, 0.00, NULL, NULL);
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51002, 5121, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5121, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5121, 1);
VALUES(51002, 5121, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5121, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5121, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -148,7 +148,7 @@ INSERT INTO lehre.tbl_lehreinheitmitarbeiter
VALUES(51002, 'demolektor2', 'Lektor', 0, NULL, 1.00, NULL, true, NULL, NULL, '2023-08-24 14:58:40.000', 'oesi', NULL, 0.00, NULL, NULL);
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51003, 5141, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5141, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5141, 1);
VALUES(51003, 5141, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5141, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5141, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -159,7 +159,7 @@ INSERT INTO lehre.tbl_lehreinheitmitarbeiter
VALUES(51003, 'demolektor3', 'Lektor', 0, NULL, 1.00, NULL, true, NULL, NULL, '2023-08-24 14:58:40.000', 'oesi', NULL, 0.00, NULL, NULL);
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51004, 5211, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5211, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5211, 1);
VALUES(51004, 5211, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5211, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5211, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -170,7 +170,7 @@ INSERT INTO lehre.tbl_lehreinheitmitarbeiter
VALUES(51004, 'demolektor4', 'Lektor', 0, NULL, 1.00, NULL, true, NULL, NULL, '2023-08-24 14:58:40.000', 'oesi', NULL, 0.00, NULL, NULL);
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51005, 5311, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5311, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5311, 1);
VALUES(51005, 5311, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5311, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5311, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -181,7 +181,7 @@ INSERT INTO lehre.tbl_lehreinheitmitarbeiter
VALUES(51005, 'demolektor4', 'Lektor', 0, NULL, 1.00, NULL, true, NULL, NULL, '2023-08-24 14:58:40.000', 'oesi', NULL, 0.00, NULL, NULL);
INSERT INTO lehre.tbl_lehreinheit (lehreinheit_id, lehrveranstaltung_id, studiensemester_kurzbz, lehrfach_id_old, lehrform_kurzbz, stundenblockung, wochenrythmus, start_kw, raumtyp, raumtypalternativ, sprache, lehre, anmerkung, unr, lvnr, updateamum, updatevon, insertamum, insertvon, ext_id, lehrfach_id, gewicht)
VALUES(51006, 5321, CurrentSemester(), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5321, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5321, 1);
VALUES(51006, 5321, COALESCE(CurrentSemester(), LastActiveSemester()), NULL, 'VO', 2, 1, NULL, 'Dummy', 'Dummy', 'German', true, NULL, 5321, NULL, '2023-08-24 14:54:43.000', 'oesi', '2023-08-24 14:54:43.000', 'oesi', NULL, 5321, 1);
INSERT INTO lehre.tbl_lehreinheitgruppe
(lehreinheit_id, studiengang_kz, semester, verband, gruppe, gruppe_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id)
@@ -210,7 +210,7 @@ VALUES(510021, 31002, 31002, 5, 1, 'B', '', NULL, 'demolektor1', 'EG04', '2025-0
INSERT INTO public.tbl_studentlehrverband
(student_uid, studiensemester_kurzbz, studiengang_kz, semester, verband, gruppe, updateamum, updatevon, insertamum, insertvon, ext_id)
VALUES('s125b101', 'SS2026', 5, 2, ' ', ' ', NULL, NULL, '2026-06-11 14:33:58.403', 'auto', NULL);
VALUES('s125b101', LastActiveSemester(), 5, 2, ' ', ' ', NULL, NULL, '2026-06-11 14:33:58.403', 'auto', NULL);
INSERT INTO public.tbl_gruppe (gruppe_kurzbz, studiengang_kz, semester, bezeichnung, beschreibung, sichtbar, lehre, aktiv, sort, mailgrp, generiert, updateamum, updatevon, insertamum, insertvon, ext_id, orgform_kurzbz, content_visible, gesperrt, direktinskription, zutrittssystem, aufnahmegruppe) VALUES
('GRP_51003', 5, 2, 'BS5 2 ENG', null, false, false, true, NULL, false, false, now(), 'demoadmin', now(), 'demoadmin', NULL, NULL, true, false, true, false, false),
@@ -229,4 +229,3 @@ INSERT INTO public.tbl_benutzergruppe (uid, gruppe_kurzbz, updateamum, updatevon
('s125b101', 'GRP_51003', now(), 'demoadmin', now(), 'demoadmin', NULL, NULL),
('s125b101', 'GRP_51004', now(), 'demoadmin', now(), 'demoadmin', NULL, NULL)
;
+3 -3
View File
@@ -177,9 +177,9 @@ VALUES
(51006, 31),
(51004, 32);
INSERT INTO public.tbl_variablenname
(name, defaultwert)
VALUES('ignore_resources_collisions', 'false');
-- INSERT INTO public.tbl_variablenname
-- (name, defaultwert)
-- VALUES('ignore_resources_collisions', 'false');
INSERT INTO public.tbl_variable
(name, uid, wert)
+3 -1
View File
@@ -1,4 +1,6 @@
node_modules
.env
.env.*
!.env.example
!.env.example
/cypress/screenshots
/cypress/videos
@@ -1,68 +1,34 @@
import { tempusApi } from "../../../../support/api/tempusApi";
import { getDateForDay } from "../../../../support/helpers/date";
import {
getTempusTestSemester,
TEMPUS_TEST_STUDY_PLAN_SHORT_CODE,
} from "../../../../support/helpers/tempusTestData";
const TARGETED_STUDY_PLAN_SHORT_CODE = "STG5";
const resetEventsBeforeTest = () => {
tempusApi
.getPlannerEvents(getDateForDay("monday"), getDateForDay("monday"))
.then((events) => {
events.forEach((event) => {
tempusApi.deleteKalenderEvent(event.kalender_id);
});
});
tempusApi
.getPlannerEvents(getDateForDay("tuesday"), getDateForDay("tuesday"))
.then((events) => {
events.forEach((event) => {
if (
event.type === "lehreinheit" &&
event.beginn === "20:15:00" &&
event.ende === "21:00:00"
) {
tempusApi.updateKalenderEvent(
event.kalender_id,
`${event.datum} 19:30`,
`${event.datum} 20:15`,
);
}
});
});
tempusApi
.getPlannerEvents(getDateForDay("sunday"), getDateForDay("sunday"))
.then((events) => {
events.forEach((event) => {
if (
event.type === "lehreinheit" &&
event.beginn === "18:35:00" &&
event.ende === "19:20:00" &&
event.lektor.some((lector) => lector.kurzbz === "DemoLKT1")
) {
tempusApi.updateKalenderEvent(
event.kalender_id,
`${event.datum} 17:50`,
`${event.datum} 18:35`,
);
}
});
});
};
let TEMPUS_TEST_SEMESTER;
describe("Tempus Kalender API", () => {
before(() => {
cy.login();
getTempusTestSemester().then((semester) => {
TEMPUS_TEST_SEMESTER = semester;
});
});
beforeEach(() => {
cy.login();
resetEventsBeforeTest();
tempusApi.resetTempusScenario();
});
it("event creation works for non collision case", () => {
tempusApi.getStudyPlansTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TARGETED_STUDY_PLAN_SHORT_CODE),
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
tempusApi
.getCoursesByStudyPlan(studyPlan.studiengang_kz, "SS2026")
.getCoursesByStudyPlan(studyPlan.studiengang_kz, TEMPUS_TEST_SEMESTER)
.then((courses) => {
let course = courses.find((course) => course.lehrfach === "MAT");
expect(course, "course for test event creation").to.exist;
@@ -94,12 +60,12 @@ describe("Tempus Kalender API", () => {
it("prohibited event creation due to zeitsperre collision", () => {
tempusApi.getStudyPlansTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TARGETED_STUDY_PLAN_SHORT_CODE),
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
tempusApi
.getCoursesByStudyPlan(studyPlan.studiengang_kz, "SS2026")
.getCoursesByStudyPlan(studyPlan.studiengang_kz, TEMPUS_TEST_SEMESTER)
.then((courses) => {
let course = courses.find((course) =>
course.lektoren.some((lector) => lector.kurzbz === "DemoLKT1"),
@@ -142,12 +108,12 @@ describe("Tempus Kalender API", () => {
it("prohibited event creation due to student group collision", () => {
tempusApi.getStudyPlansTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TARGETED_STUDY_PLAN_SHORT_CODE),
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
tempusApi
.getCoursesByStudyPlan(studyPlan.studiengang_kz, "SS2026")
.getCoursesByStudyPlan(studyPlan.studiengang_kz, TEMPUS_TEST_SEMESTER)
.then((courses) => {
let course = courses.find(
(course) =>
@@ -194,12 +160,12 @@ describe("Tempus Kalender API", () => {
tempusApi.getStudyPlansTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TARGETED_STUDY_PLAN_SHORT_CODE),
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
tempusApi
.getCoursesByStudyPlan(studyPlan.studiengang_kz, "SS2026")
.getCoursesByStudyPlan(studyPlan.studiengang_kz, TEMPUS_TEST_SEMESTER)
.then((courses) => {
let course = courses.find(
(course) =>
@@ -252,12 +218,12 @@ describe("Tempus Kalender API", () => {
it("prohibited event creation due to lector collision", () => {
tempusApi.getStudyPlansTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TARGETED_STUDY_PLAN_SHORT_CODE),
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
tempusApi
.getCoursesByStudyPlan(studyPlan.studiengang_kz, "SS2026")
.getCoursesByStudyPlan(studyPlan.studiengang_kz, TEMPUS_TEST_SEMESTER)
.then((courses) => {
let course = courses.find((course) =>
course.lektoren.some((lector) => lector.kurzbz === "DemoLKT4"),
@@ -1,19 +1,9 @@
import { waitForOk } from "../../../../support/helpers/network";
import { getDateForDay } from "../../../../support/helpers/date";
import { tempusPage } from "../../../../support/pages/tempus.po";
import { tempusApi } from "../../../../support/api/tempusApi";
const TARGETED_STUDY_PLAN_SHORT_CODE = "STG5";
const deleteMondayEvents = () =>
tempusApi
.getPlannerEvents(getDateForDay("monday"), getDateForDay("monday"))
.then((events) => {
events.forEach((event) => {
tempusApi.deleteKalenderEvent(event.kalender_id);
});
});
context("Tempus course picker tests", () => {
before(() => {
tempusPage.visitAndWaitForPlanner();
@@ -61,7 +51,7 @@ context("Tempus course picker tests", () => {
});
it("can drag and drop one course event into the calendar", () => {
deleteMondayEvents();
tempusApi.deletePlannerEventsForDay("monday");
tempusPage.getCalendarSection().should("exist");
tempusPage.waitForCalendarToFinishLoading();
@@ -1,5 +1,4 @@
import { waitForOk } from "../../../../support/helpers/network";
import { getDateForDay } from "../../../../support/helpers/date";
import { tempusApi } from "../../../../support/api/tempusApi";
import {
LEKTOR,
@@ -13,13 +12,7 @@ context("Tempus event mutation tests", () => {
beforeEach(() => {
tempusPage.visitAndWaitForPlanner();
tempusApi
.getPlannerEvents(getDateForDay("monday"), getDateForDay("monday"))
.then((events) => {
events.forEach((event) => {
tempusApi.deleteKalenderEvent(event.kalender_id);
});
});
tempusApi.deletePlannerEventsForDay("monday");
});
it("room change on planner preview updates planner event, but keeps original room on other previews", () => {
@@ -51,52 +44,16 @@ context("Tempus event mutation tests", () => {
tempusPage.expectCalendarEventRoom(eventId, originalRoom);
tempusPage
.getCalendarEventById(eventId)
.should("be.visible")
.rightclick();
tempusPage.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
tempusPage.changeEventRoom(eventId, originalRoom).then((result) => {
const { newRoom, updatedEventId } = result;
tempusPage
.getRaumauswahlRoomOptions()
.should("have.length.greaterThan", 0)
.then(($roomOptions) => {
const roomOption = [...$roomOptions].find((option) => {
const room = option.innerText.trim();
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
return room && room !== originalRoom;
});
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage.expectCalendarEventRoom(eventId, originalRoom);
expect(roomOption, "different room suggestion").to.exist;
cy.wrap(roomOption.innerText.trim()).as("newRoom");
cy.wrap(roomOption).click();
});
cy.wait("@updateCalendarEvent").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
const updatedEventId = tempusPage.getUpdatedKalenderId(interception);
expect(updatedEventId, "updated planner event id").to.exist;
cy.wrap(updatedEventId).as("updatedEventId");
});
waitForOk("@fetchPlanData");
tempusPage.waitForCalendarToFinishLoading();
cy.get("@newRoom").then((newRoom) => {
console.log(eventId)
console.log(newRoom)
cy.get("@updatedEventId").then((updatedEventId) => {
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage.expectCalendarEventRoom(eventId, originalRoom);
tempusPage.selectRoleAndWait(STUDENT);
tempusPage.expectCalendarEventRoom(eventId, originalRoom);
});
tempusPage.selectRoleAndWait(STUDENT);
tempusPage.expectCalendarEventRoom(eventId, originalRoom);
});
});
});
@@ -128,54 +85,19 @@ context("Tempus event mutation tests", () => {
expect(originalRoom, "original event room").to.be.a("string").and.not.be
.empty;
tempusPage
.getCalendarEventById(eventId)
.scrollIntoView()
.should("be.visible")
.rightclick();
tempusPage.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
tempusPage.changeEventRoom(eventId, originalRoom).then((result) => {
const { newRoom, updatedEventId } = result;
tempusPage
.getRaumauswahlRoomOptions()
.should("have.length.greaterThan", 0)
.then(($roomOptions) => {
const roomOption = [...$roomOptions].find((option) => {
const room = option.innerText.trim();
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
return room && room !== originalRoom;
});
tempusPage.syncAndReloadPlanner();
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
expect(roomOption, "different room suggestion").to.exist;
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
cy.wrap(roomOption.innerText.trim()).as("newRoom");
cy.wrap(roomOption).click();
});
cy.wait("@updateCalendarEvent").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
const updatedEventId = tempusPage.getUpdatedKalenderId(interception);
expect(updatedEventId, "updated planner event id").to.exist;
cy.wrap(updatedEventId).as("updatedEventId");
});
waitForOk("@fetchPlanData");
tempusPage.waitForCalendarToFinishLoading();
cy.get("@newRoom").then((newRoom) => {
cy.get("@updatedEventId").then((updatedEventId) => {
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
tempusPage.syncAndReloadPlanner();
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
tempusPage.selectRoleAndWait(STUDENT);
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
});
tempusPage.selectRoleAndWait(STUDENT);
tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
});
});
});
@@ -45,7 +45,7 @@ context("Tempus filter tests", () => {
selectedRoom,
);
cy.wrap($event)
.find(".event-place")
.find("[data-cy='calendar-event-room']")
.invoke("text")
.then((eventPlace) => {
expect(eventPlace.trim(), "event body room").to.eq(selectedRoom);
@@ -1,5 +1,4 @@
import { waitForOk } from "../../../../support/helpers/network";
import { getDateForDay } from "../../../../support/helpers/date";
import { tempusApi } from "../../../../support/api/tempusApi";
import {
LEKTOR,
@@ -12,13 +11,7 @@ context("Tempus role preview tests", () => {
beforeEach(() => {
tempusPage.visitAndWaitForPlanner();
tempusApi
.getPlannerEvents(getDateForDay("monday"), getDateForDay("monday"))
.then((events) => {
events.forEach((event) => {
tempusApi.deleteKalenderEvent(event.kalender_id);
});
});
tempusApi.deletePlannerEventsForDay("monday");
});
it("shows the same number of calendar events for all role previews", () => {
@@ -44,7 +44,7 @@ context("Tempus smoke tests", () => {
tempusPage.getEventContextMenu().should("be.visible");
});
it("shows Raumauswahl modal when selecting Raumauswahl from event context menu", () => {
it("shows room selection modal when selecting 'room selection' from event context menu", () => {
tempusPage.waitForCalendarToFinishLoading();
tempusPage
.getCalendarEventsWithLehreinheit()
@@ -54,7 +54,7 @@ context("Tempus smoke tests", () => {
tempusPage.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
tempusPage.getRaumauswahlModal().should("be.visible");
tempusPage.getRoomSelectionModal().should("be.visible");
});
it("shows resources modal when selecting Ressourcen zuordnen from event context menu", () => {
@@ -1,5 +1,25 @@
import { getDateForDay } from "../helpers/date";
const KALENDER_API = "/index.ci.php/api/frontend/v1/tempus";
const updatePlannerEventsForDay = (day, predicate, startTime, endTime) => {
const date = getDateForDay(day);
return tempusApi.getPlannerEvents(date, date).then((events) =>
cy.wrap(events).each((event) => {
if (!predicate(event)) {
return null;
}
return tempusApi.updateKalenderEvent(
event.kalender_id,
`${event.datum} ${startTime}`,
`${event.datum} ${endTime}`,
);
}),
);
};
export const tempusApi = {
getStudyPlansTree: () =>
cy
@@ -15,6 +35,23 @@ export const tempusApi = {
return response.body.data;
}),
getStudySemesters: () =>
cy
.request({
method: "GET",
url: `/index.ci.php/api/frontend/v1/organisation/Studiensemester/getAll`,
qs: {
order: "DESC",
},
})
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.nested.property("meta.status", "success");
expect(response.body.data).to.be.an("array");
return response.body.data;
}),
getCoursesByStudyPlan: (studyPlanId, semesterShortCode) =>
cy
.request({
@@ -51,6 +88,43 @@ export const tempusApi = {
return response.body.data;
}),
deletePlannerEventsForDay: (day) => {
const date = getDateForDay(day);
return tempusApi.getPlannerEvents(date, date).then((events) =>
cy.wrap(events).each((event) =>
tempusApi.deleteKalenderEvent(event.kalender_id),
),
);
},
resetTempusScenario: () =>
tempusApi
.deletePlannerEventsForDay("monday")
.then(() =>
updatePlannerEventsForDay(
"tuesday",
(event) =>
event.type === "lehreinheit" &&
event.beginn === "20:15:00" &&
event.ende === "21:00:00",
"19:30",
"20:15",
),
)
.then(() =>
updatePlannerEventsForDay(
"sunday",
(event) =>
event.type === "lehreinheit" &&
event.beginn === "18:35:00" &&
event.ende === "19:20:00" &&
event.lektor?.some((lector) => lector.kurzbz === "DemoLKT1"),
"17:50",
"18:35",
),
),
createKalenderEvent: (lehreinheitId, startDateTime, endDateTime) =>
cy.request({
method: "POST",
@@ -0,0 +1,35 @@
import { tempusApi } from "../api/tempusApi";
export const TEMPUS_TEST_STUDY_PLAN_SHORT_CODE = "STG5";
const getLocalDateString = () => {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, "0");
const day = String(today.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
};
const getSemesterStartDate = (semester) => semester.start?.slice(0, 10);
export const getTempusTestSemester = () =>
tempusApi.getStudySemesters().then((semesters) => {
const today = getLocalDateString();
const activeSemester = semesters
.filter((semester) => {
const startDate = getSemesterStartDate(semester);
return startDate && startDate <= today;
})
.sort((a, b) =>
getSemesterStartDate(b).localeCompare(getSemesterStartDate(a)),
)[0];
expect(
activeSemester,
`Tempus test semester starting on or before ${today}`,
).to.exist;
return activeSemester.studiensemester_kurzbz;
});
@@ -22,7 +22,7 @@ const roleFetchAliases = {
class TempusPage {
selectors = {
calendarBaseGrid: "div[data-cy='tempus'] .fhc-calendar-base-grid",
calendarBaseGrid: "div[data-cy='tempus'] [data-cy='calendar-base-grid']",
parkingSlot: "div[data-cy='tempus'] #parkingslot",
};
@@ -108,22 +108,26 @@ class TempusPage {
getCalendarSection = () =>
this.getTempusOverview().find(".fhc-calendar-base");
getCalendarBaseGrid = () =>
this.getCalendarSection().find(".fhc-calendar-base-grid");
this.getCalendarSection().find("[data-cy='calendar-base-grid']");
getCoursePicker = () => this.getTempusOverview().find(".course-picker");
getPreviewRoleOptionsHolder = () =>
this.getTempusOverview().find("[data-cy='previewRoleOptionsHolder']");
getAllCoursesSliderBtn = () =>
this.getSidebarMenu().find("button[title='Verband']").first();
getCourseTreeRows = () =>
this.getSlideInCoursesMenu().find(".p-treetable-tbody tr");
this.getSlideInCoursesMenu()
.find("[data-cy='course-tree-row']")
.closest("[role='row']");
getCourseTreeRowByName = (courseShortName) =>
this.getSlideInCoursesMenu()
.contains("[data-cy='course-tree-row']", courseShortName)
.closest("[role='row']");
getCoursePickerRows = () => this.getCoursePicker().find(".course-picker-row");
getCoursePickerSearchInput = () => this.getCoursePicker().find("input");
getCalendarEventsPerWeekHolders = () =>
this.getCalendarBaseGrid().find(".fhc-calendar-base-grid-line");
getCalendarEvents = () =>
this.getCalendarSection().then(($calendar) => {
return $calendar.find(".fhc-calendar-base-grid-line-event");
});
this.getCalendarSection().find("[data-cy='calendar-event']");
getLecturerWishOverlays = () =>
this.getCalendarSection().find(".bg-lecturer-wish");
getCalendarEventsWithRoom = () =>
@@ -195,7 +199,7 @@ class TempusPage {
getCalendarEventById = (id) =>
this.getCalendarEvents().filter(`div[data-id="event-${id}"]`);
getCalendarPartDropTarget = (partIndex) =>
`${this.selectors.calendarBaseGrid} .part-body:nth-of-type(${partIndex})`;
`${this.selectors.calendarBaseGrid} [data-cy='calendar-grid-part'][data-drop-index='${partIndex}']`;
getEventGridRowFromStyle = (style) =>
/grid-row:\s*([^;]+)/.exec(style)?.[1]?.trim();
getEventGridRow = (id) =>
@@ -205,7 +209,7 @@ class TempusPage {
getCalendarEventsByWeekday = (weekday) =>
this.getCalendarEventsPerWeekHolders()
.eq(weekdayToGridRowMap[weekday] - 1)
.find(".fhc-calendar-base-grid-line-event");
.find("[data-cy='calendar-event']");
getCalendarEventsByStartTime = (startTime) =>
this.getCalendarEvents().filter((index, event) => {
const eventData = JSON.parse(
@@ -262,12 +266,54 @@ class TempusPage {
return retval?.kalender_id ?? retval;
};
chooseDifferentRoomForEvent = (eventId, originalRoom) => {
this.getCalendarEventById(eventId)
.scrollIntoView()
.should("be.visible")
.rightclick();
this.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
return this.getRaumauswahlRoomOptions()
.should("have.length.greaterThan", 0)
.then(($roomOptions) => {
const roomOption = [...$roomOptions].find((option) => {
const room = option.innerText.trim();
return room && room !== originalRoom;
});
expect(roomOption, "different room suggestion").to.exist;
const newRoom = roomOption.innerText.trim();
return cy.wrap(roomOption).click().then(() => newRoom);
});
};
waitForUpdatedEventId = () =>
cy.wait("@updateCalendarEvent").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
const updatedEventId = this.getUpdatedKalenderId(interception);
expect(updatedEventId, "updated planner event id").to.exist;
return updatedEventId;
});
changeEventRoom = (eventId, originalRoom) =>
this.chooseDifferentRoomForEvent(eventId, originalRoom).then((newRoom) =>
this.waitForUpdatedEventId().then((updatedEventId) => {
waitForOk("@fetchPlanData");
this.waitForCalendarToFinishLoading();
return cy.wrap({ newRoom, updatedEventId });
}),
);
getMondayFirstColumnEventData = ($body) =>
[
...$body
.find(`${this.selectors.calendarBaseGrid} .fhc-calendar-base-grid-line`)
.first()
.find(".fhc-calendar-base-grid-line-event"),
.find("[data-cy='calendar-event']"),
]
.map((event) => {
const eventJSON = event.getAttribute("data-fhc-draggable-value");
@@ -286,18 +332,18 @@ class TempusPage {
getEventContextMenu = () => cy.get("[data-cy='eventContextMenu']");
getEventContextMenuOption = (option) =>
this.getEventContextMenu().contains("button", option);
getRaumauswahlModal = () =>
getRoomSelectionModal = () =>
cy
.contains(".bootstrap-modal.show .modal-title", "Raumauswahl")
.closest(".bootstrap-modal.show");
getRaumauswahlRoomOptions = () =>
this.getRaumauswahlModal().find(".list-group-item span");
this.getRoomSelectionModal().find(".list-group-item span");
getResourcesModal = () =>
cy
.get("[data-cy='resourcesAssignmentModal']")
.closest(".bootstrap-modal.show");
getCalendarEventRoom = (id) =>
this.getCalendarEventById(id).find(".event-place");
this.getCalendarEventById(id).find("[data-cy='calendar-event-room']");
getStundenrasterToggle = () =>
cy.contains(".form-check-label", "Stundenraster").parent();
getHistoryModal = () => cy.get("[data-cy='historyModal']");
@@ -305,7 +351,7 @@ class TempusPage {
getReservationModal = () => cy.get("[data-cy='reservationModal']");
getEventParkingSlot = () => this.getSidebarMenu().find("#parkingslot");
getParkedEvents = () =>
this.getEventParkingSlot().find(".fhc-calendar-base-grid-line-event");
this.getEventParkingSlot().find("[data-cy='calendar-event']");
getPreviewRoleButton = (role) =>
this.getPreviewRoleOptionsHolder().contains("button", role);
@@ -324,7 +370,7 @@ class TempusPage {
selectCourseByName = (courseShortName) => {
this.openCoursesMenu();
this.getCourseTreeRows().contains(courseShortName).click();
this.getCourseTreeRowByName(courseShortName).click();
};
selectPreviewRole = (role) => {