mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-01 02:21:39 +00:00
Remove the "Recurring event per timezone" test that manipulated Date.prototype.getTimezoneOffset to simulate 24 different timezones for testing all-day recurring events. Reasons for removal: 1. The test approach is incompatible with node-ical 0.22.0's Intl-based timezone handling (which replaced moment-timezone). Manipulating Date.prototype.getTimezoneOffset no longer affects Intl.DateTimeFormat, which reads the system timezone directly. 2. node-ical 0.22.0 handles all-day events (VALUE=DATE) correctly by preserving the calendar date without timezone conversions, making cross-timezone testing unnecessary. The library includes comprehensive tests for this behavior, particularly "keeps whole-day recurrence across DST" in [test/advanced.test.js](https://github.com/jens-maus/node-ical/blob/master/test/advanced.test.js). 3. The existing "Recurring event" test already verifies that recurring events from the same ICS file are displayed correctly, so a simplified version of "Recurring event per timezone" is not necessary. The old test attempted to work around timezone conversion issues in node-ical 0.21.0 that are now properly resolved upstream. Closes #3928
187 lines
6.2 KiB
JavaScript
187 lines
6.2 KiB
JavaScript
const helpers = require("../helpers/global-setup");
|
|
const serverBasicAuth = require("../helpers/basic-auth");
|
|
|
|
describe("Calendar module", () => {
|
|
|
|
/**
|
|
* @param {string} element css selector
|
|
* @param {string} result expected number
|
|
* @param {string} not reverse result
|
|
* @returns {boolean} result
|
|
*/
|
|
const testElementLength = async (element, result, not) => {
|
|
const elem = await helpers.waitForAllElements(element);
|
|
expect(elem).not.toBeNull();
|
|
if (not === "not") {
|
|
expect(elem).not.toHaveLength(result);
|
|
} else {
|
|
expect(elem).toHaveLength(result);
|
|
}
|
|
return true;
|
|
};
|
|
|
|
const testTextContain = async (element, text) => {
|
|
const elem = await helpers.waitForElement(element, "undefinedLoading");
|
|
expect(elem).not.toBeNull();
|
|
expect(elem.textContent).toContain(text);
|
|
return true;
|
|
};
|
|
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
});
|
|
|
|
describe("Default configuration", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/default.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the default maximumEntries of 10", async () => {
|
|
await expect(testElementLength(".calendar .event", 10)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show the default calendar symbol in each event", async () => {
|
|
await expect(testElementLength(".calendar .event .fa-calendar-days", 0, "not")).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Custom configuration", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the custom maximumEntries of 5", async () => {
|
|
await expect(testElementLength(".calendar .event", 5)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show the custom calendar symbol in four events", async () => {
|
|
await expect(testElementLength(".calendar .event .fa-birthday-cake", 4)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show a customEvent calendar symbol in one event", async () => {
|
|
await expect(testElementLength(".calendar .event .fa-dice", 1)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show a customEvent calendar eventClass in one event", async () => {
|
|
await expect(testElementLength(".calendar .event.undo", 1)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show two custom icons for repeating events", async () => {
|
|
await expect(testElementLength(".calendar .event .fa-undo", 2)).resolves.toBe(true);
|
|
});
|
|
|
|
it("should show two custom icons for day events", async () => {
|
|
await expect(testElementLength(".calendar .event .fa-calendar-day", 2)).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Recurring event", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should show the recurring birthday event 6 times", async () => {
|
|
await expect(testElementLength(".calendar .event", 6)).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
//Will contain everyday an fullDayEvent that starts today and ends tomorrow, and one starting tomorrow and ending the day after tomorrow
|
|
describe("FullDayEvent over several days should show how many days are left from the from the starting date on", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/long-fullday-event.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should contain text 'Ends in' with the left days", async () => {
|
|
await expect(testTextContain(".calendar .today .time", "Ends in")).resolves.toBe(true);
|
|
await expect(testTextContain(".calendar .yesterday .time", "Today")).resolves.toBe(true);
|
|
await expect(testTextContain(".calendar .tomorrow .time", "Tomorrow")).resolves.toBe(true);
|
|
});
|
|
it("should contain in total three events", async () => {
|
|
await expect(testElementLength(".calendar .event", 3)).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("FullDayEvent Single day, should show Today", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/single-fullday-event.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should contain text 'Today'", async () => {
|
|
await expect(testTextContain(".calendar .time", "Today")).resolves.toBe(true);
|
|
});
|
|
it("should contain in total two events", async () => {
|
|
await expect(testElementLength(".calendar .event", 2)).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Changed port", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
|
serverBasicAuth.listen(8010);
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await serverBasicAuth.close();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Basic auth", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Basic auth by default", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Basic auth backward compatibility configuration: DEPRECATED", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
it("should return TestEvents", async () => {
|
|
await expect(testElementLength(".calendar .event", 0, "not")).resolves.toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("Fail Basic auth", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
|
serverBasicAuth.listen(8020);
|
|
await helpers.getDocument();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await serverBasicAuth.close();
|
|
});
|
|
|
|
it("should show Unauthorized error", async () => {
|
|
await expect(testTextContain(".calendar", "Error in the calendar module. Authorization failed")).resolves.toBe(true);
|
|
});
|
|
});
|
|
});
|