Compare commits
No commits in common. "bed3e47f8e21b912fc3ad66d1a1b4bb371ff285b" and "782e62d56d8bb6f76ffcc11751e035bbf6b1b3e1" have entirely different histories.
bed3e47f8e
...
782e62d56d
|
@ -1,2 +1 @@
|
||||||
* text=auto eol=lf
|
* text=auto eol=lf
|
||||||
*.ics text eol=crlf
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import express from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const CALENDARS_DIR = path.join(__dirname, 'calendar');
|
const CALENDARS_DIR = path.join(__dirname, 'calendar')
|
||||||
const TEST_CALENDARS_DIR = path.join(__dirname, 'test_calendars');
|
const TEST_CALENDARS_DIR = path.join(__dirname, 'test_calendars');
|
||||||
const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ describe('Calendar Merging API', () => {
|
||||||
await new Promise(resolve => setTimeout(resolve, 100));
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
const getTestCalendarFilename = (filename) => {
|
const loadCalendarFile = (filename) => {
|
||||||
return path.join(TEST_CALENDARS_DIR, filename);
|
return path.join(TEST_CALENDARS_DIR, filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,33 +34,8 @@ describe('Calendar Merging API', () => {
|
||||||
return fs.readFileSync(path.join(EXPECTED_OUTPUTS_DIR, filename), 'utf8');
|
return fs.readFileSync(path.join(EXPECTED_OUTPUTS_DIR, filename), 'utf8');
|
||||||
};
|
};
|
||||||
|
|
||||||
test('Preserve nextcloud calendar', async () => {
|
|
||||||
const input = getTestCalendarFilename('nextcloud-minimal.ics');
|
|
||||||
const response = await request(server)
|
|
||||||
.post('/merge')
|
|
||||||
.send({
|
|
||||||
linkGroupName: 'nextcloud-minimal',
|
|
||||||
calendars: [
|
|
||||||
{
|
|
||||||
url: input,
|
|
||||||
prefix: '',
|
|
||||||
override: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
expect(response.status).toBe(200);
|
|
||||||
// Check if the file was created in the test directory
|
|
||||||
const filePath = path.join(CALENDARS_DIR, 'nextcloud-minimal.ics');
|
|
||||||
console.log('Checking if file exists at:', filePath);
|
|
||||||
expect(fs.existsSync(filePath)).toBe(true);
|
|
||||||
// Load expected output and compare
|
|
||||||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
|
||||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Preserve date-based calendar', async () => {
|
test('Preserve date-based calendar', async () => {
|
||||||
const input = getTestCalendarFilename('US_Holidays.ics');
|
const input = loadCalendarFile('US_Holidays.ics');
|
||||||
const response = await request(server)
|
const response = await request(server)
|
||||||
.post('/merge')
|
.post('/merge')
|
||||||
.send({
|
.send({
|
||||||
|
@ -82,6 +57,7 @@ describe('Calendar Merging API', () => {
|
||||||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
expect(actualOutput).toBe(expectedOutput);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('Merge date-based calendar', async () => {
|
// test('Merge date-based calendar', async () => {
|
||||||
|
@ -91,12 +67,12 @@ describe('Calendar Merging API', () => {
|
||||||
// linkGroupName: 'Date Based Calendar',
|
// linkGroupName: 'Date Based Calendar',
|
||||||
// calendars: [
|
// calendars: [
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'),
|
// url: loadCalendarFile('holiday_calendar_2023.ics'),
|
||||||
// prefix: 'holiday_calendar_2023',
|
// prefix: 'holiday_calendar_2023',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('US_Holidays.ics'),
|
// url: loadCalendarFile('US_Holidays.ics'),
|
||||||
// prefix: 'US_holidays',
|
// prefix: 'US_holidays',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
|
@ -117,7 +93,7 @@ describe('Calendar Merging API', () => {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
test('Merge time-based calendar', async () => {
|
test('Merge time-based calendar', async () => {
|
||||||
const input = getTestCalendarFilename('work_task_calendar.ics');
|
const input = loadCalendarFile('work_task_calendar.ics');
|
||||||
const response = await request(server)
|
const response = await request(server)
|
||||||
.post('/merge')
|
.post('/merge')
|
||||||
.send({
|
.send({
|
||||||
|
@ -145,7 +121,7 @@ describe('Calendar Merging API', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('EAT Event', async () => {
|
test('EAT Event', async () => {
|
||||||
const input = getTestCalendarFilename('eat_time_zone_event.ics');
|
const input = loadCalendarFile('eat_time_zone_event.ics');
|
||||||
const response = await request(server)
|
const response = await request(server)
|
||||||
.post('/merge')
|
.post('/merge')
|
||||||
.send({
|
.send({
|
||||||
|
@ -179,7 +155,7 @@ describe('Calendar Merging API', () => {
|
||||||
// linkGroupName: 'No Prefix Calendar',
|
// linkGroupName: 'No Prefix Calendar',
|
||||||
// calendars: [
|
// calendars: [
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
// url: loadCalendarFile('sf_public_holidays.ics'),
|
||||||
// prefix: '',
|
// prefix: '',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
|
@ -206,7 +182,7 @@ describe('Calendar Merging API', () => {
|
||||||
// linkGroupName: 'Override Calendar',
|
// linkGroupName: 'Override Calendar',
|
||||||
// calendars: [
|
// calendars: [
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('sf_public_holidays.ics'),
|
// url: loadCalendarFile('sf_public_holidays.ics'),
|
||||||
// prefix: 'Override Event',
|
// prefix: 'Override Event',
|
||||||
// override: true,
|
// override: true,
|
||||||
// },
|
// },
|
||||||
|
@ -233,12 +209,12 @@ describe('Calendar Merging API', () => {
|
||||||
// linkGroupName: 'UTCEAT Time Zone Calendar',
|
// linkGroupName: 'UTCEAT Time Zone Calendar',
|
||||||
// calendars: [
|
// calendars: [
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('utc_time_zone_event.ics'),
|
// url: loadCalendarFile('utc_time_zone_event.ics'),
|
||||||
// prefix: 'UTC_Event',
|
// prefix: 'UTC_Event',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('eat_time_zone_event.ics'),
|
// url: loadCalendarFile('eat_time_zone_event.ics'),
|
||||||
// prefix: 'EAT_Event',
|
// prefix: 'EAT_Event',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
|
@ -264,12 +240,12 @@ describe('Calendar Merging API', () => {
|
||||||
// linkGroupName: 'Merged Date and Time Based Calendar',
|
// linkGroupName: 'Merged Date and Time Based Calendar',
|
||||||
// calendars: [
|
// calendars: [
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('holiday_calendar_2023.ics'), // Date-based calendar
|
// url: loadCalendarFile('holiday_calendar_2023.ics'), // Date-based calendar
|
||||||
// prefix: 'Holiday_2023',
|
// prefix: 'Holiday_2023',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// url: getTestCalendarFilename('work_task_calendar.ics'), // Time-based calendar
|
// url: loadCalendarFile('work_task_calendar.ics'), // Time-based calendar
|
||||||
// prefix: 'Work_Task',
|
// prefix: 'Work_Task',
|
||||||
// override: false,
|
// override: false,
|
||||||
// },
|
// },
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import ICAL from '../src/lib/ical.timezones';
|
import ICAL from '../src/lib/ical.timezones';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
// Describe the test suite for Calendar Utility Functions
|
// Describe the test suite for Calendar Utility Functions
|
||||||
|
@ -35,16 +34,19 @@ describe('Calendar Utility Functions', () => {
|
||||||
|
|
||||||
// Test case: reading data from a file
|
// Test case: reading data from a file
|
||||||
it('reads and parses data from a file', async () => {
|
it('reads and parses data from a file', async () => {
|
||||||
const testCalendar = { url: path.join(__dirname, 'test_calendars', 'nextcloud.ics'), };
|
const testCalendar = { url: './test/test_calendars/eat_time_zone_event.ics' };
|
||||||
|
|
||||||
// Call the fetchCalendarData function
|
// Call the fetchCalendarData function
|
||||||
const result = await fetchCalendarData(testCalendar);
|
const result = await fetchCalendarData(testCalendar);
|
||||||
const parsed = ICAL.parse(result.data);
|
|
||||||
const component = new ICAL.Component(parsed);
|
|
||||||
const firstEvent = new ICAL.Event(component.getAllSubcomponents('vevent')[0]);
|
|
||||||
// Assert that the fetched and parsed data matches
|
|
||||||
expect(firstEvent.startDate.toJSON()).toEqual({"day": 20, "hour": 21, "isDate": false, "minute": 15, "month": 11, "second": 0, "timezone": "Europe/Berlin", "year": 2024});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Expected parsed output
|
||||||
|
const expectedParsedData = ICAL.parse(
|
||||||
|
fs.readFileSync(testCalendar.url, 'utf-8')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert that the fetched and parsed data matches
|
||||||
|
expect(ICAL.parse(result.data)).toEqual(expectedParsedData);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
PRODID:-//SabreDAV//SabreDAV//EN
|
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Berlin
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
TZNAME:CEST
|
|
||||||
DTSTART:19700329T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
TZNAME:CET
|
|
||||||
DTSTART:19701025T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
|
||||||
END:STANDARD
|
|
||||||
END:VTIMEZONE
|
|
||||||
BEGIN:VEVENT
|
|
||||||
DTEND;TZID=Europe/Berlin:20241120T215000
|
|
||||||
DTSTAMP:20241113T212909Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20241120T211500
|
|
||||||
LOCATION:FaceTime
|
|
||||||
RRULE:FREQ=WEEKLY;BYDAY=WE
|
|
||||||
SEQUENCE:0
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
|
@ -1,131 +0,0 @@
|
||||||
BEGIN:VCALENDAR
|
|
||||||
VERSION:2.0
|
|
||||||
CALSCALE:GREGORIAN
|
|
||||||
PRODID:-//SabreDAV//SabreDAV//EN
|
|
||||||
X-WR-CALNAME:Progodyssey Ryan (stackspin-a51baefe-70df-4cce-9be1-048354b619
|
|
||||||
b8)
|
|
||||||
X-APPLE-CALENDAR-COLOR:#ddcb55
|
|
||||||
REFRESH-INTERVAL;VALUE=DURATION:PT4H
|
|
||||||
X-PUBLISHED-TTL:PT4H
|
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Berlin
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
TZNAME:CEST
|
|
||||||
DTSTART:19700329T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
TZNAME:CET
|
|
||||||
DTSTART:19701025T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
|
||||||
END:STANDARD
|
|
||||||
END:VTIMEZONE
|
|
||||||
BEGIN:VEVENT
|
|
||||||
CREATED:20241113T212909Z
|
|
||||||
DTEND;TZID=Europe/Berlin:20241120T215000
|
|
||||||
DTSTAMP:20241113T212909Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20241120T211500
|
|
||||||
LAST-MODIFIED:20241113T212909Z
|
|
||||||
LOCATION:FaceTime
|
|
||||||
RRULE:FREQ=WEEKLY;BYDAY=WE
|
|
||||||
SEQUENCE:0
|
|
||||||
STATUS:CONFIRMED
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
TRANSP:OPAQUE
|
|
||||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
|
||||||
RELATED-TO;RELTYPE=SIBLING:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
|
||||||
BEGIN:VALARM
|
|
||||||
ACKNOWLEDGED:20241113T202052Z
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:This is an event reminder.
|
|
||||||
TRIGGER:-PT20M
|
|
||||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
BEGIN:VEVENT
|
|
||||||
CREATED:20241113T213036Z
|
|
||||||
DTEND;TZID=Europe/Berlin:20241204T212500
|
|
||||||
DTSTAMP:20241113T213036Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20241204T203000
|
|
||||||
LAST-MODIFIED:20241113T213036Z
|
|
||||||
LOCATION:FaceTime
|
|
||||||
SEQUENCE:1
|
|
||||||
STATUS:CONFIRMED
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
TRANSP:OPAQUE
|
|
||||||
UID:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
|
||||||
RELATED-TO;RELTYPE=SIBLING:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
|
||||||
RECURRENCE-ID;TZID=Europe/Berlin:20241204T211500
|
|
||||||
BEGIN:VALARM
|
|
||||||
ACKNOWLEDGED:20241113T202052Z
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:This is an event reminder.
|
|
||||||
TRIGGER:-PT20M
|
|
||||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
BEGIN:VEVENT
|
|
||||||
CREATED:20241107T101403Z
|
|
||||||
DTEND;TZID=Europe/Berlin:20241111T134500
|
|
||||||
DTSTAMP:20241118T103806Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20241111T121500
|
|
||||||
LAST-MODIFIED:20241118T103803Z
|
|
||||||
LOCATION:https://call.element.io/room/#/progodyssey?password=bU95nPdV2u-BGJ
|
|
||||||
4zw9cPGw&roomId=%21QsGQUxdyuMfGKhGvNH%3Acall.ems.host
|
|
||||||
RRULE:FREQ=WEEKLY;BYDAY=MO
|
|
||||||
SEQUENCE:4
|
|
||||||
STATUS:CONFIRMED
|
|
||||||
SUMMARY:JR Coprogramming Session
|
|
||||||
TRANSP:OPAQUE
|
|
||||||
UID:8c251542-6cbf-4396-b83d-490be79c97a9
|
|
||||||
BEGIN:VALARM
|
|
||||||
ACKNOWLEDGED:20241118T103803Z
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:This is an event reminder.
|
|
||||||
SUMMARY:Coprogramming Session
|
|
||||||
TRIGGER:-PT1H
|
|
||||||
UID:55C3B462-E182-4A2B-A500-3F249FC860C2
|
|
||||||
X-WR-ALARMUID:55C3B462-E182-4A2B-A500-3F249FC860C2
|
|
||||||
END:VALARM
|
|
||||||
BEGIN:VALARM
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:Reminder
|
|
||||||
TRIGGER:-PT1H
|
|
||||||
UID:9AABB2AB-A755-4723-87CF-10B119670E7F
|
|
||||||
X-APPLE-DEFAULT-ALARM:TRUE
|
|
||||||
X-WR-ALARMUID:9AABB2AB-A755-4723-87CF-10B119670E7F
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
BEGIN:VEVENT
|
|
||||||
CREATED:20241107T101605Z
|
|
||||||
DTEND;TZID=Europe/Berlin:20241113T215500
|
|
||||||
DTSTAMP:20241113T212909Z
|
|
||||||
DTSTART;TZID=Europe/Berlin:20241113T213000
|
|
||||||
LAST-MODIFIED:20241113T212909Z
|
|
||||||
LOCATION:FaceTime
|
|
||||||
RRULE:FREQ=WEEKLY;BYDAY=WE;UNTIL=20241120T202959Z
|
|
||||||
SEQUENCE:4
|
|
||||||
STATUS:CONFIRMED
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
TRANSP:OPAQUE
|
|
||||||
UID:17cf7d22-9bee-4a8e-9023-878b1a1b73a0
|
|
||||||
RELATED-TO;RELTYPE=SIBLING:5f4ad965-16a8-48eb-8233-78bf93a8b35e
|
|
||||||
BEGIN:VALARM
|
|
||||||
ACKNOWLEDGED:20241113T202052Z
|
|
||||||
ACTION:DISPLAY
|
|
||||||
DESCRIPTION:This is an event reminder.
|
|
||||||
SUMMARY:JR Weekly Check-In
|
|
||||||
TRIGGER:-PT20M
|
|
||||||
UID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
X-WR-ALARMUID:99250427-AB45-4111-A999-DB417FC290D1
|
|
||||||
END:VALARM
|
|
||||||
END:VEVENT
|
|
||||||
END:VCALENDAR
|
|
Loading…
Reference in New Issue