diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b824b7795..b601450f47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ _This release is scheduled to be released on 2024-10-01._ - [weather] Fixed issue with the UK Met Office provider following a change in their API paths and header info. - [core] add check for node_helper loading for multiple instances of same module (#3502) - [weather] Fixed issue for respecting unit config on broadcasted notifications -- [tests] Fixes calendar e2e test (#3532) +- [tests] Fixes calendar test by moving it from e2e to electron with fixed date (#3532) ## [2.28.0] - 2024-07-01 diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index e2f9266c3e..e88c003ad1 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -88,17 +88,6 @@ describe("Calendar module", () => { }); }); - describe("Events from multiple calendars", () => { - beforeAll(async () => { - await helpers.startApplication("tests/configs/modules/calendar/show-duplicates-in-calendar.js"); - await helpers.getDocument(); - }); - - it("should show multiple events with the same title and start time from different calendars", async () => { - await expect(testElementLength(".calendar .event", 20)).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 () => { diff --git a/tests/electron/modules/calendar_spec.js b/tests/electron/modules/calendar_spec.js index bf10ecd752..5624b51b23 100644 --- a/tests/electron/modules/calendar_spec.js +++ b/tests/electron/modules/calendar_spec.js @@ -13,6 +13,15 @@ describe("Calendar module", () => { return true; }; + const doTestCount = async () => { + expect(global.page).not.toBeNull(); + const loc = await global.page.locator(".calendar .event"); + const elem = loc.first(); + await elem.waitFor(); + expect(elem).not.toBeNull(); + return await loc.count(); + }; + afterEach(async () => { await helpers.stopApplication(); }); @@ -44,6 +53,13 @@ describe("Calendar module", () => { }); }); + describe("Events from multiple calendars", () => { + it("should show multiple events with the same title and start time from different calendars", async () => { + await helpers.startApplication("tests/configs/modules/calendar/show-duplicates-in-calendar.js", "15 Sep 2024 12:30:00 GMT"); + await expect(doTestCount()).resolves.toBe(20); + }); + }); + /* * RRULE TESTS: * Add any tests that check rrule functionality here. @@ -51,13 +67,7 @@ describe("Calendar module", () => { describe("rrule", () => { it("Issue #3393 recurrence dates past rrule until date", async () => { await helpers.startApplication("tests/configs/modules/calendar/rrule_until.js", "07 Mar 2024 10:38:00 GMT-07:00", ["js/electron.js"], "America/Los_Angeles"); - 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(1); + await expect(doTestCount()).resolves.toBe(1); }); }); @@ -74,38 +84,20 @@ describe("Calendar module", () => { describe("Exdate: LA crossover DST before midnight GMT", () => { it("LA crossover DST before midnight GMT should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_la_before_midnight.js", "19 Oct 2023 12:30:00 GMT-07:00", ["js/electron.js"], "America/Los_Angeles"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); describe("Exdate: LA crossover DST at midnight GMT local STD", () => { it("LA crossover DST before midnight GMT should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_la_at_midnight_std.js", "19 Oct 2023 12:30:00 GMT-07:00", ["js/electron.js"], "America/Los_Angeles"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); describe("Exdate: LA crossover DST at midnight GMT local DST", () => { it("LA crossover DST before midnight GMT should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_la_at_midnight_dst.js", "19 Oct 2023 12:30:00 GMT-07:00", ["js/electron.js"], "America/Los_Angeles"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); @@ -122,37 +114,19 @@ describe("Calendar module", () => { describe("Exdate: SYD crossover DST before midnight GMT", () => { it("LA crossover DST before midnight GMT should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_syd_before_midnight.js", "14 Sep 2023 12:30:00 GMT+10:00", ["js/electron.js"], "Australia/Sydney"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); describe("Exdate: SYD crossover DST at midnight GMT local STD", () => { it("LA crossover DST before midnight GMT should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_syd_at_midnight_std.js", "14 Sep 2023 12:30:00 GMT+10:00", ["js/electron.js"], "Australia/Sydney"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); describe("Exdate: SYD crossover DST at midnight GMT local DST", () => { it("SYD crossover DST at midnight GMT local DST should have 2 events", async () => { await helpers.startApplication("tests/configs/modules/calendar/exdate_syd_at_midnight_dst.js", "14 Sep 2023 12:30:00 GMT+10:00", ["js/electron.js"], "Australia/Sydney"); - 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(2); + await expect(doTestCount()).resolves.toBe(2); }); }); });