[#4180] added support for instant event (#417)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2025-12-12 17:33:33 +01:00
committed by GitHub
parent 6161e295ce
commit 22d674c6b5
2 changed files with 12 additions and 6 deletions
+8 -4
View File
@@ -13,7 +13,7 @@ import {
import { TIMEZONES } from "../../../src/utils/timezone-data";
describe("parseCalendarEvent", () => {
const baseColor = "#00FF00";
const baseColor = { light: "#00FF00" };
const calendarId = "calendar-123";
it("parses a full event with MAILTO in caps correctly", () => {
@@ -215,12 +215,12 @@ describe("parseCalendarEvent", () => {
);
expect(result.end).toBeDefined();
expect(result.timezone).toBeDefined();
const endDate = new Date(result.end);
const endDate = new Date(result.end ?? "");
const startDate = new Date(result.start);
expect(endDate.getTime() - startDate.getTime()).toBe(60 * 60 * 1000);
});
it("returns error if end and duration is missing", () => {
it("returns 30 minutes event if end and duration are missing", () => {
const rawDataMissing: any = [
["UID", {}, "text", "event-1"],
["DTSTART", {}, "date-time", "2025-07-18T09:00:00Z"],
@@ -232,7 +232,11 @@ describe("parseCalendarEvent", () => {
calendarId,
"/calendars/test.ics"
);
expect(result.error).toMatch(/missing crucial event param/);
expect(result.end).toBeDefined();
expect(result.timezone).toBeDefined();
const endDate = new Date(result.end ?? "");
const startDate = new Date(result.start);
expect(endDate.getTime() - startDate.getTime()).toBe(30 * 60 * 1000);
});
it("parses alarm block correctly", () => {
+4 -2
View File
@@ -188,7 +188,7 @@ export function parseCalendarEvent(
}
event.URL = eventURL;
if (!event.uid || !event.start || (!event.end && !duration)) {
if (!event.uid || !event.start) {
console.error(
`missing crucial event param in calendar ${calendarid} `,
data
@@ -201,7 +201,9 @@ export function parseCalendarEvent(
if (!event.end) {
const start = event.start ? new Date(event.start) : new Date();
const timeToAdd = moment.duration(duration).asMilliseconds();
const timeToAdd = duration
? moment.duration(duration).asMilliseconds()
: moment.duration(30, "minutes").asMilliseconds();
const artificialEnd = new Date(start.getTime() + timeToAdd);
event.end = formatDateToICal(artificialEnd, false, eventTimezone);
}