This commit is contained in:
Ivymaster
2026-10-15 17:19:48 +02:00
parent 2b740a5a09
commit 054d515821
11 changed files with 610 additions and 110 deletions
-1
View File
@@ -1062,7 +1062,6 @@ class KalenderLib
$updatedEntryResult = $this->_loadKalenderEntry($kalender_id);
if (isError($updatedEntryResult)) return $updatedEntryResult;
log_message('error', 'Kalender event updated: ' . json_encode($updatedEntryResult));
return success(getData($updatedEntryResult));
}
+1 -1
View File
@@ -53,7 +53,7 @@ export default {
<div class="header-userdefined">
<slot />
</div>
<div class="header-modes">
<div class="header-modes" data-cy="calender-header-modes">
<div class="d-flex gap-1 justify-content-end" role="group">
<button
v-if="btnMonth"
@@ -352,7 +352,7 @@ export default {
},
},
template: /* html */`
<div class="fhc-calendar-mode-table-view position-absolute top-0 start-0 w-100 h-100 d-flex flex-column">
<div class="fhc-calendar-mode-table-view position-absolute top-0 start-0 w-100 h-100 d-flex flex-column" data-cy="calender-table-view">
<core-filter-cmpt
ref="tableViewTable"
:tabulator-options="tabulatorOptions"
@@ -200,7 +200,7 @@ export default {
></form-input>
<div class="d-flex justify-content-end gap-2 mt-3">
<button type="button" class="btn btn-secondary" @click="hide">
<button type="button" class="btn btn-secondary" @click="hide" data-cy="closeRoomSelection">
{{ $p.t('ui','abbrechen') }}
</button>
<button
@@ -192,6 +192,37 @@ INSERT INTO lehre.tbl_kalender_lehreinheit
VALUES
(51004, 35);
-- Calendar setup for room selection tests
INSERT INTO lehre.tbl_kalender
(von, bis, typ, status_kurzbz, vorgaenger_kalender_id, eindeutige_kalender_gruppen_id, insertamum, insertvon, updateamum, updatevon)
VALUES
(date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '14:30:00', date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '15:15:00', 'lehreinheit', 'live', NULL, null, now(), 'demoadmin', NULL, 'demoadmin'),
(date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '15:15:00', date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '16:00:00', 'lehreinheit', 'live', NULL, null, now(), 'demoadmin', NULL, 'demoadmin');
INSERT INTO lehre.tbl_kalender_lehreinheit
(lehreinheit_id, kalender_id)
VALUES
(51004, 36),
(51004, 37);
INSERT INTO lehre.tbl_kalender_ort
(location, ort_kurzbz, kalender_id)
VALUES
(NULL, 'Bro_F7.37', 37);
-- Calendar setup for event deletion tests
INSERT INTO lehre.tbl_kalender
(von, bis, typ, status_kurzbz, vorgaenger_kalender_id, eindeutige_kalender_gruppen_id, insertamum, insertvon, updateamum, updatevon)
VALUES
(date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '16:10:00', date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '16:55:00', 'lehreinheit', 'live', NULL, null, now(), 'demoadmin', NULL, 'demoadmin'),
(date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '16:55:00', date_trunc('week', CURRENT_DATE) + INTERVAL '3 day' + TIME '17:40:00', 'lehreinheit', 'live', NULL, null, now(), 'demoadmin', NULL, 'demoadmin');
INSERT INTO lehre.tbl_kalender_lehreinheit
(lehreinheit_id, kalender_id)
VALUES
(51004, 38),
(51004, 39);
-- Assign a UUID to every root calendar entry and propagate it to its children.
UPDATE lehre.tbl_kalender
SET eindeutige_kalender_gruppen_id = gen_random_uuid()
@@ -733,4 +733,229 @@ describe("Tempus Kalender API", () => {
});
});
});
it("event creation fails for inactive roomless and active room selection dialog config option, if no room is selected, for the first attempt", () => {
tempusApi.getDegreeProgramTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "dialog_room_planning";
tempusApi
.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;
tempusApi
.updateSettingsData(settingsData)
.then((response) => {
const lehreinheitId = course.lehreinheit_id;
expect(lehreinheitId, "lehreinheit id for test event creation").to
.exist;
const startDateTime = `${getDateForDay("monday")} 17:50`;
const endDateTime = `${getDateForDay("monday")} 18:35`;
tempusApi
.createKalenderEvent(lehreinheitId, startDateTime, endDateTime, [])
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.nested.property(
"data.needs_room_selection",
true,
);
expect(response.body).to.have.nested.property(
"meta.status",
"success",
);
});
});
});
});
});
it("event creation fails for inactive roomless and active room selection dialog config option, if no room is selected, for the second attempt", () => {
tempusApi.getDegreeProgramTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "dialog_room_planning";
tempusApi
.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;
tempusApi
.updateSettingsData(settingsData)
.then((response) => {
const lehreinheitId = course.lehreinheit_id;
expect(lehreinheitId, "lehreinheit id for test event creation").to
.exist;
const startDateTime = `${getDateForDay("monday")} 17:50`;
const endDateTime = `${getDateForDay("monday")} 18:35`;
tempusApi
.createKalenderEvent(lehreinheitId, startDateTime, endDateTime, [], false)
.then((response) => {
expect(response.status).to.eq(500);
expect(response.body.errors).to.be.an("array");
let hasRoomlessPlanningError = response.body.errors.some(
(error) => error.errorCode === "roomless_planning_error",
);
expect(
hasRoomlessPlanningError,
"response contains roomless planning error",
).to.be.true;
});
});
});
});
});
it("event creation works for inactive roomless and active priority room config option, if no room is selected", () => {
tempusApi.getDegreeProgramTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "priority_room_planning";
tempusApi
.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;
tempusApi
.updateSettingsData(settingsData)
.then((response) => {
const lehreinheitId = course.lehreinheit_id;
expect(lehreinheitId, "lehreinheit id for test event creation").to
.exist;
const startDateTime = `${getDateForDay("monday")} 17:50`;
const endDateTime = `${getDateForDay("monday")} 18:35`;
tempusApi
.createKalenderEvent(lehreinheitId, startDateTime, endDateTime, [])
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.not.have.nested.property(
"data.needs_room_selection",
true,
);
expect(response.body).to.have.nested.property(
"meta.status",
"success",
);
});
});
});
});
});
it("event creation fails for active roomless and active room selection dialog config option, if no room is selected, for the first attempt", () => {
tempusApi.getDegreeProgramTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = true;
settingsData.room_planning = "dialog_room_planning";
tempusApi
.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;
tempusApi
.updateSettingsData(settingsData)
.then((response) => {
const lehreinheitId = course.lehreinheit_id;
expect(lehreinheitId, "lehreinheit id for test event creation").to
.exist;
const startDateTime = `${getDateForDay("monday")} 17:50`;
const endDateTime = `${getDateForDay("monday")} 18:35`;
tempusApi
.createKalenderEvent(lehreinheitId, startDateTime, endDateTime, [], true)
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.nested.property(
"data.needs_room_selection",
true,
);
expect(response.body).to.have.nested.property(
"meta.status",
"success",
);
});
});
});
});
});
it("event creation works for active roomless and active room selection dialog config option, if no room is selected, for the second attempt", () => {
tempusApi.getDegreeProgramTree().then((stgTree) => {
let studyPlan = stgTree.find((plan) =>
plan.name.includes(TEMPUS_TEST_STUDY_PLAN_SHORT_CODE),
);
expect(studyPlan, "study plan for test event creation").to.exist;
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = true;
settingsData.room_planning = "dialog_room_planning";
tempusApi
.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;
tempusApi
.updateSettingsData(settingsData)
.then((response) => {
const lehreinheitId = course.lehreinheit_id;
expect(lehreinheitId, "lehreinheit id for test event creation").to
.exist;
const startDateTime = `${getDateForDay("monday")} 17:50`;
const endDateTime = `${getDateForDay("monday")} 18:35`;
tempusApi
.createKalenderEvent(lehreinheitId, startDateTime, endDateTime, [], false)
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.not.have.nested.property(
"data.needs_room_selection",
true,
);
expect(response.body).to.have.nested.property(
"meta.status",
"success",
);
});
});
});
});
});
});
@@ -50,36 +50,136 @@ context("Tempus course picker tests", () => {
});
});
it("adds a course teaching unit to the calendar when it is dropped", () => {
it("for active room selection dialog config option, shows room selection dialog when adding a course from the course-picker", () => {
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "dialog_room_planning";
tempusApi.updateSettingsData(settingsData).then((response) => {
tempusApi.deletePlannerEventsForDay("monday");
tempusPage.visitAndWaitForPlanner();
tempusPage.waitForCalendarToFinishLoading();
tempusPage.selectCourseByName(TARGETED_STUDY_PLAN_SHORT_CODE);
waitForOk("@fetchCoursePickerCourses");
tempusPage.getCoursePickerRows().should("have.length.greaterThan", 0);
tempusPage.getCalendarEvents().then(($events) => {
const initialEventCount = $events.length;
tempusPage.dropCourseOnCalendarPart(0, 10);
waitForOk("@addCalendarEvent");
tempusPage.getRoomSelectionModal().should("be.visible");
tempusPage.selectFirstRoomAndSave();
waitForOk("@addCalendarEvent");
waitForOk("@fetchPlanData");
tempusPage.waitForCalendarToFinishLoading();
tempusPage
.getCalendarEvents()
.should("have.length", initialEventCount + 1);
});
});
});
it("for active room selection dialog config option, does not add an event to the calendar when the room selection dialog is closed", () => {
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "dialog_room_planning";
tempusApi.updateSettingsData(settingsData).then((response) => {
tempusApi.deletePlannerEventsForDay("monday");
tempusPage.getCalendarSection().should("exist");
tempusPage.visitAndWaitForPlanner();
tempusPage.waitForCalendarToFinishLoading();
tempusPage.selectCourseByName(TARGETED_STUDY_PLAN_SHORT_CODE);
waitForOk("@fetchCoursePickerCourses");
cy.wait(1000);
tempusPage.getCoursePickerRows().should("have.length.greaterThan", 0);
tempusPage.getCalendarEvents().then(($events) => {
cy.wrap($events.length).as("initialEventCount");
});
const initialEventCount = $events.length;
tempusPage.getCoursePickerRows().should("have.length.greaterThan", 0);
tempusPage.dropCourseOnCalendarPart(0, 10);
tempusPage.dropCourseOnCalendarPart(0, 10);
waitForOk("@addCalendarEvent");
tempusPage.selectFirstRoomAndSave();
waitForOk("@addCalendarEvent");
waitForOk("@fetchPlanData");
tempusPage.getRoomSelectionModal().should("be.visible");
tempusPage.getRoomSelectionModal().find("button[data-cy='closeRoomSelection']").click();
tempusPage.getRoomSelectionModal().should("not.exist");
tempusPage.waitForCalendarToFinishLoading();
cy.wait(1000);
cy.get("@initialEventCount").then((initialEventCount) => {
tempusPage
.getCalendarEvents()
.should("have.length", initialEventCount + 1);
tempusPage.waitForCalendarToFinishLoading();
tempusPage.getCalendarEvents().should("have.length", initialEventCount);
});
});
});
it("for active room selection dialog config option, does not add an event to the calendar when no room is selected", () => {
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "dialog_room_planning";
tempusApi.updateSettingsData(settingsData).then((response) => {
tempusApi.deletePlannerEventsForDay("monday");
tempusPage.visitAndWaitForPlanner();
tempusPage.waitForCalendarToFinishLoading();
tempusPage.selectCourseByName(TARGETED_STUDY_PLAN_SHORT_CODE);
waitForOk("@fetchCoursePickerCourses");
tempusPage.getCoursePickerRows().should("have.length.greaterThan", 0);
tempusPage.getCalendarEvents().then(($events) => {
const initialEventCount = $events.length;
tempusPage.dropCourseOnCalendarPart(0, 10);
tempusPage.getRoomSelectionModal().should("be.visible");
tempusPage.getRoomSelectionModal().find("button[data-cy='saveRoomSelection']").click();
tempusPage.getRoomSelectionModal().should("exist");
tempusPage.waitForCalendarToFinishLoading();
tempusPage.getCalendarEvents().should("have.length", initialEventCount);
});
});
});
it("for active priority room config option, adds an event to the calendar without room selection dialog", () => {
let settingsData = tempusApi.getSettingsData();
settingsData.roomless_planning = false;
settingsData.room_planning = "priority_room_planning";
tempusApi.updateSettingsData(settingsData).then((response) => {
tempusApi.deletePlannerEventsForDay("monday");
tempusPage.visitAndWaitForPlanner();
tempusPage.waitForCalendarToFinishLoading();
tempusPage.selectCourseByName(TARGETED_STUDY_PLAN_SHORT_CODE);
waitForOk("@fetchCoursePickerCourses");
tempusPage.getCoursePickerRows().should("have.length.greaterThan", 0);
tempusPage.getCalendarEvents().then(($events) => {
const initialEventCount = $events.length;
tempusPage.dropCourseOnCalendarPart(0, 10);
tempusPage.getRoomSelectionModal().should("not.exist");
tempusPage.getCalendarEvents().should("have.length", initialEventCount);
tempusPage.waitForCalendarToFinishLoading();
tempusPage.getCalendarEvents().should("have.length", initialEventCount);
});
});
});
});
@@ -59,51 +59,99 @@ context("Tempus event mutation tests", () => {
});
});
// it("shows an updated room in all previews after syncing", () => {
// tempusPage.syncAndReloadPlanner();
it("selects and displays a room for an event", () => {
tempusPage
.getCalendarEventsByWeekdayAndTimeRange(
"Thursday",
"14:30:00",
"15:15:00",
)
.should("have.length.greaterThan", 0)
.first()
.rightclick();
// tempusPage
// .getCalendarEventsWithLehreinheitAndRoomByWeekdayAndStartTime(
// "Wednesday",
// "08:00:00",
// )
// .should("have.length.greaterThan", 0);
tempusPage.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
// tempusPage
// .getCalendarEventsWithLehreinheitAndRoomByWeekdayAndStartTime(
// "Wednesday",
// "08:00:00",
// )
// .first()
// .invoke("attr", "data-fhc-draggable-value")
// .then((eventJSON) => {
// expect(eventJSON).to.exist;
tempusPage.selectFirstRoomAndSave().then((selectedRoom) => {
tempusPage.waitForUpdatedEventId().then((updatedEventId) => {
waitForOk("@fetchPlanData");
tempusPage.waitForCalendarToFinishLoading();
// const eventData = JSON.parse(eventJSON);
// const eventId = eventData?.id;
// let originalRoom = eventData?.orig?.ort_kurzbz;
// if (Array.isArray(originalRoom)) originalRoom = originalRoom.length ? originalRoom[0] : "";
tempusPage.expectCalendarEventRoom(updatedEventId, selectedRoom);
});
});
});
// expect(eventId, "planner event id").to.exist;
// expect(originalRoom, "original event room").to.be.a("string").and.not.be
// .empty;
it("changes an event room", () => {
tempusPage
.getCalendarEventsByWeekdayAndTimeRange(
"Thursday",
"15:15:00",
"16:00:00",
)
.should("have.length.greaterThan", 0)
.first()
.invoke("attr", "data-fhc-draggable-value")
.then((eventJSON) => {
expect(eventJSON).to.exist;
// tempusPage.changeEventRoom(eventId, originalRoom).then((result) => {
// const { newRoom, updatedEventId } = result;
const eventData = JSON.parse(eventJSON);
const eventId = eventData?.id;
let originalRoom = eventData?.orig?.ort_kurzbz;
if (Array.isArray(originalRoom))
originalRoom = originalRoom.length ? originalRoom[0] : "";
// tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
expect(eventId, "planner event id").to.exist;
expect(originalRoom, "original event room").to.be.a("string").and.not
.be.empty;
// tempusPage.syncAndReloadPlanner();
// tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
tempusPage.changeEventRoom(eventId, originalRoom).then((result) => {
expect(result.newRoom, "updated room").to.not.eq(originalRoom);
tempusPage.expectCalendarEventRoom(
result.updatedEventId,
result.newRoom,
);
});
});
});
// tempusPage.selectRoleAndWait(LEKTOR);
// tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
it("adds multiple rooms to an event", () => {
tempusPage
.getCalendarEventsByWeekdayAndTimeRange(
"Thursday",
"15:15:00",
"16:00:00",
)
.should("have.length.greaterThan", 0)
.first()
.invoke("attr", "data-fhc-draggable-value")
.then((eventJSON) => {
expect(eventJSON).to.exist;
const eventData = JSON.parse(eventJSON);
const eventId = eventData?.id;
const currentRooms = eventData?.orig?.ort_kurzbz ?? [];
expect(eventId, "planner event id").to.exist;
tempusPage.getCalendarEventById(eventId).rightclick();
tempusPage.getEventContextMenuOption("Raumauswahl").click({ force: true });
waitForOk("@fetchRoomSuggestions");
tempusPage
.selectAdditionalRoomsAndSave(currentRooms)
.then((additionalRooms) => {
tempusPage.waitForUpdatedEventId().then((updatedEventId) => {
waitForOk("@fetchPlanData");
tempusPage.waitForCalendarToFinishLoading();
tempusPage.expectCalendarEventRooms(updatedEventId, additionalRooms);
});
});
});
});
// tempusPage.selectRoleAndWait(STUDENT);
// tempusPage.expectCalendarEventRoom(updatedEventId, newRoom);
// });
// });
// });
it("moves an event from the calendar to the parking slot", () => {
tempusPage.getEventParkingSlot().should("exist");
@@ -117,71 +165,91 @@ context("Tempus event mutation tests", () => {
tempusPage.getParkedEvents().should("have.length", 1);
});
// it("keeps a deleted event in the planner preview until syncing, but hides it in other previews", () => {
// tempusPage.syncAndReloadPlanner();
it("keeps a deleted planner event visible in lecturer and student previews", () => {
tempusPage.syncAndReloadPlanner();
// tempusPage
// .getCalendarEventsByWeekdayAndStartTime("Wednesday", "09:40:00")
// .first()
// .invoke("attr", "data-fhc-draggable-value")
// .then((eventJSON) => {
// expect(eventJSON).to.exist;
tempusPage
.getCalendarEventsBySoftTimeRange("16:10:00", "16:55:00")
.first()
.invoke("attr", "data-fhc-draggable-value")
.then((eventJSON) => {
expect(eventJSON).to.exist;
// let eventId = JSON.parse(eventJSON)?.id;
// expect(eventId).to.exist;
// tempusPage
// .getCalendarEventById(eventId)
// .should("be.visible")
// .rightclick();
// tempusPage.getEventContextMenuOption("Delete").click();
const eventGroupId =
JSON.parse(eventJSON)?.orig?.eindeutige_kalender_gruppen_id;
expect(eventGroupId).to.exist;
// cy.wait("@deleteCalendarEvent");
// waitForOk("@fetchPlanData");
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.rightclick();
// tempusPage.waitForCalendarToFinishLoading();
tempusPage
.getEventContextMenuOption("Delete")
.click({ force: true });
// tempusPage.getCalendarEventById(eventId).should("be.visible");
waitForOk("@fetchPlanData");
// tempusPage.selectRoleAndWait(LEKTOR);
// tempusPage.getCalendarEventById(eventId).should("not.exist");
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("not.exist");
// tempusPage.selectRoleAndWait(STUDENT);
// tempusPage.getCalendarEventById(eventId).should("not.exist");
// });
// });
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("exist");
// it("removes a deleted event from all previews after syncing", () => {
// tempusPage.syncAndReloadPlanner();
tempusPage.selectRoleAndWait(STUDENT);
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("exist");
});
});
// tempusPage
// .getCalendarEventsByWeekdayAndStartTime("Wednesday", "10:25:00")
// .first()
// .invoke("attr", "data-fhc-draggable-value")
// .then((eventJSON) => {
// expect(eventJSON).to.exist;
it("keeps a deleted planner event invisible after syncing", () => {
tempusPage.syncAndReloadPlanner();
// let eventId = JSON.parse(eventJSON)?.id;
// expect(eventId).to.exist;
// tempusPage
// .getCalendarEventById(eventId)
// .should("be.visible")
// .rightclick();
// tempusPage.getEventContextMenuOption("Delete").click();
tempusPage
.getCalendarEventsBySoftTimeRange("16:55:00", "17:40:00")
.first()
.invoke("attr", "data-fhc-draggable-value")
.then((eventJSON) => {
expect(eventJSON).to.exist;
// cy.wait("@deleteCalendarEvent");
// waitForOk("@fetchPlanData");
const eventGroupId =
JSON.parse(eventJSON)?.orig?.eindeutige_kalender_gruppen_id;
expect(eventGroupId).to.exist;
// tempusPage.syncAndReloadPlanner();
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.rightclick();
// tempusPage.getCalendarEventById(eventId).should("not.exist");
tempusPage
.getEventContextMenuOption("Delete")
.click({ force: true });
// tempusPage.selectRoleAndWait(LEKTOR);
// tempusPage.getCalendarEventById(eventId).should("not.exist");
waitForOk("@fetchPlanData");
// tempusPage.selectRoleAndWait(STUDENT);
// tempusPage.getCalendarEventById(eventId).should("not.exist");
// });
// });
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("not.exist");
tempusPage.syncAndReloadPlanner();
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("not.exist");
tempusPage.selectRoleAndWait(LEKTOR);
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("exist");
tempusPage.selectRoleAndWait(STUDENT);
tempusPage
.getCalendarEventByUniqueCalenderGroupId(eventGroupId)
.should("exist");
});
});
it("resizes an event from the bottom in the planner preview", () => {
tempusPage.getCalendarSection().should("exist");
@@ -18,6 +18,22 @@ context("Tempus smoke tests", () => {
tempusPage.getPreviewRoleOptionsHolder().should("be.visible");
});
it("loads events in every calendar mode", () => {
tempusPage
.getCalendarModeButtons()
.should("have.length.greaterThan", 0)
.each(($modeButton) => {
cy.wrap($modeButton).click().should("have.class", "active");
tempusPage.waitForCalendarToFinishLoading();
if ($modeButton.find(".fa-table-list").length) {
tempusPage.getCalendarTableRows().should("have.length.greaterThan", 0);
} else {
tempusPage.getCalendarEvents().should("have.length.greaterThan", 0);
}
});
});
it("opens the courses menu", () => {
tempusPage.getSlideInCoursesMenu().should("exist").should("be.hidden");
@@ -135,7 +135,7 @@ export const tempusApi = {
),
),
createKalenderEvent: (lehreinheitId, startDateTime, endDateTime) =>
createKalenderEvent: (lehreinheitId, startDateTime, endDateTime, roomShortCodes = [], isFirstAttempt = true) =>
cy.request({
method: "POST",
url: `${KALENDER_API}/Kalender/addKalenderEvent`,
@@ -143,6 +143,8 @@ export const tempusApi = {
lehreinheit_id: lehreinheitId,
start_date: startDateTime,
end_date: endDateTime,
ort_kurzbz: roomShortCodes,
first_run: isFirstAttempt,
},
failOnStatusCode: false,
}),
@@ -133,6 +133,12 @@ class TempusPage {
this.getTempusOverview().find(".fhc-calendar-base");
getCalendarBaseGrid = () =>
this.getCalendarSection().find("[data-cy='calendar-base-grid']");
getCalendarModeButtons = () =>
this.getCalendarSection().find("[data-cy='calender-header-modes'] button");
getCalendarTableRows = () =>
this.getCalendarSection().find(
"[data-cy='calender-table-view'] .tabulator-row",
);
getCoursePicker = () => this.getTempusOverview().find("[data-cy='coursepicker']");
getPreviewRoleOptionsHolder = () =>
this.getTempusOverview().find("[data-cy='previewRoleOptionsHolder']");
@@ -281,6 +287,17 @@ class TempusPage {
);
return eventData?.orig?.beginn === startTime;
});
getCalendarEventsByWeekdayAndTimeRange = (weekday, startTime, endTime) =>
this.getCalendarEventsByWeekday(weekday).filter((index, event) => {
const eventData = JSON.parse(
event.getAttribute("data-fhc-draggable-value"),
);
return (
eventData?.orig?.beginn === startTime &&
eventData?.orig?.ende === endTime
);
});
getCalendarEventsWithLehreinheitAndRoomByWeekdayAndStartTime = (
weekday,
startTime,
@@ -365,6 +382,36 @@ class TempusPage {
.then(() => room);
});
selectAdditionalRoomsAndSave = (currentRooms, roomCount = 2) =>
this.getRoomSelectionOptions()
.should("have.length.greaterThan", roomCount)
.then(($roomOptions) => {
const selectedRooms = new Set(
(Array.isArray(currentRooms) ? currentRooms : [currentRooms]).filter(
Boolean,
),
);
const additionalRoomOptions = [...$roomOptions]
.filter((roomOption) => !selectedRooms.has(roomOption.textContent.trim()))
.slice(0, roomCount);
expect(additionalRoomOptions, "additional room suggestions").to.have.length(
roomCount,
);
const additionalRooms = additionalRoomOptions.map((roomOption) =>
roomOption.textContent.trim(),
);
additionalRoomOptions.forEach((roomOption) => cy.wrap(roomOption).click());
return cy
.get("[data-cy='saveRoomSelection']")
.should("be.visible")
.click({ force: true })
.then(() => additionalRooms);
});
waitForUpdatedEventId = () =>
cy.wait("@updateCalendarEvent").then((interception) => {
expect(interception.response.statusCode).to.eq(200);
@@ -481,6 +528,18 @@ class TempusPage {
});
};
expectCalendarEventRooms = (eventId, expectedRooms) => {
this.getCalendarEventRoom(eventId)
.scrollIntoView()
.should("be.visible")
.invoke("text")
.then((roomText) => {
expectedRooms.forEach((room) => {
expect(roomText.trim(), "event rooms").to.include(room);
});
});
};
visitAndWaitForPlanner = () => {
cy.login();
this.setupIntercepts();