2022-10-17 07:20:23 +02:00
|
|
|
const helpers = require("../helpers/global-setup");
|
|
|
|
|
|
|
|
describe("Calendar module", () => {
|
2023-12-25 08:17:11 +01:00
|
|
|
|
2022-10-17 07:20:23 +02:00
|
|
|
/**
|
|
|
|
* move similar tests in function doTest
|
|
|
|
* @param {string} cssClass css selector
|
2023-11-22 23:37:17 +01:00
|
|
|
* @returns {boolean} result
|
2022-10-17 07:20:23 +02:00
|
|
|
*/
|
|
|
|
const doTest = async (cssClass) => {
|
2023-12-17 07:19:15 +01:00
|
|
|
const elem = await helpers.getElement(`.calendar .module-content .event${cssClass}`);
|
2023-11-20 20:11:41 +01:00
|
|
|
await expect(elem.isVisible()).resolves.toBe(true);
|
2023-11-22 23:37:17 +01:00
|
|
|
return true;
|
2022-10-17 07:20:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
await helpers.stopApplication();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Test css classes", () => {
|
2023-02-21 22:39:21 +01:00
|
|
|
it("has css class dayBeforeYesterday", async () => {
|
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "03 Jan 2030 12:30:00 GMT");
|
2023-11-22 23:37:17 +01:00
|
|
|
await expect(doTest(".dayBeforeYesterday")).resolves.toBe(true);
|
2023-02-21 22:39:21 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it("has css class yesterday", async () => {
|
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "02 Jan 2030 12:30:00 GMT");
|
2023-11-22 23:37:17 +01:00
|
|
|
await expect(doTest(".yesterday")).resolves.toBe(true);
|
2023-02-21 22:39:21 +01:00
|
|
|
});
|
|
|
|
|
2022-10-17 07:20:23 +02:00
|
|
|
it("has css class today", async () => {
|
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "01 Jan 2030 12:30:00 GMT");
|
2023-11-22 23:37:17 +01:00
|
|
|
await expect(doTest(".today")).resolves.toBe(true);
|
2022-10-17 07:20:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it("has css class tomorrow", async () => {
|
2023-02-07 00:03:08 +01:00
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "31 Dec 2029 12:30:00 GMT");
|
2023-11-22 23:37:17 +01:00
|
|
|
await expect(doTest(".tomorrow")).resolves.toBe(true);
|
2022-10-17 07:20:23 +02:00
|
|
|
});
|
2023-02-21 22:39:21 +01:00
|
|
|
|
|
|
|
it("has css class dayAfterTomorrow", async () => {
|
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/custom.js", "30 Dec 2029 12:30:00 GMT");
|
2023-11-22 23:37:17 +01:00
|
|
|
await expect(doTest(".dayAfterTomorrow")).resolves.toBe(true);
|
2023-02-21 22:39:21 +01:00
|
|
|
});
|
2022-10-17 07:20:23 +02:00
|
|
|
});
|
2023-12-17 07:19:15 +01:00
|
|
|
|
|
|
|
describe("Exdate check", () => {
|
|
|
|
it("should show the recurring event 51 times (excluded once) in a 364-day (inclusive) period", async () => {
|
|
|
|
// test must run on a Thursday
|
|
|
|
await helpers.startApplication("tests/configs/modules/calendar/exdate.js", "14 Dec 2023 12:30:00 GMT");
|
|
|
|
expect(global.page).not.toBeNull();
|
|
|
|
const loc = await global.page.locator(".calendar .event");
|
|
|
|
const elem = loc.first();
|
|
|
|
await elem.waitFor();
|
|
|
|
expect(elem).not.toBeNull();
|
|
|
|
const cnt = await loc.count();
|
|
|
|
expect(cnt).toBe(51);
|
|
|
|
});
|
|
|
|
});
|
2022-10-17 07:20:23 +02:00
|
|
|
});
|