mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 21:00:57 +00:00
fixes #3267 AGAIN, correctly, add testcase add testcase for #3679 , broadcast clipping incorrectly I added a test module (tests/testNotification) to catch the notification and check the count. (one way to configure) i put this module in the tests folder, and added /tests to the server paths. (can't have a module in a nested folder, like tests/modules/xxx) but I have a problem. i can run the test config (MM_CONFIG_FILE), and the two modules work correctly, but in the spec runner, the calendar module times out on the broadcast test.. there is only local ics file access, no outside hosts I forced my system date to 1/1/24 (same as runner) and again the manual testcase works fine I added two test config.js,(configs/calendar) one works great (symbols) , one fails (broadcast test) I added additional delay in the calendarspec runner to try to debug the module, but it still not long enough.. no messages of trouble when I get into the browser.. BUT, this may be because of the log being turned off... (just thought of this) I created a special ICS (in mocks) that has 12 events, 1 for each month.. (so I can check clipping and broadcast) the US holidays one is sensitive to the current date, and I couldn't get it to work on 1/1/2024.. also, in general, is there a mechanism to run test:just_one_runner? waiting thru the electron test to get to one testcase.. ugh..
This commit is contained in:
@@ -25,8 +25,9 @@ planned for 2025-04-01
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [calendar] Fix clipping events being broadcast (#3678)
|
- [calendar] fix clipping events being broadcast (#3678)
|
||||||
- [tests] Electron tests: Fixes for running under new github image ubuntu-24.04, replace xserver with labwc (#3676)
|
- [tests] Electron tests: Fixes for running under new github image ubuntu-24.04, replace xserver with labwc (#3676)
|
||||||
|
- [calendar] fix arrayed symbols, #3267, again, add testcase, add testcase for #3678
|
||||||
|
|
||||||
## [2.30.0] - 2025-01-01
|
## [2.30.0] - 2025-01-01
|
||||||
|
|
||||||
|
@@ -177,7 +177,7 @@ function App () {
|
|||||||
moduleFolder = defaultModuleFolder;
|
moduleFolder = defaultModuleFolder;
|
||||||
} else {
|
} else {
|
||||||
// running in Jest, allow defaultModules placed under moduleDir for testing
|
// running in Jest, allow defaultModules placed under moduleDir for testing
|
||||||
if (env.modulesDir === "modules") {
|
if (env.modulesDir === "modules" || env.modulesDir === "tests/mocks") {
|
||||||
moduleFolder = defaultModuleFolder;
|
moduleFolder = defaultModuleFolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -689,10 +689,11 @@ Module.register("calendar", {
|
|||||||
by_url_calevents.push(event);
|
by_url_calevents.push(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (limitNumberOfEntries) {
|
||||||
|
// sort entries before clipping
|
||||||
by_url_calevents.sort(function (a, b) {
|
by_url_calevents.sort(function (a, b) {
|
||||||
return a.startDate - b.startDate;
|
return a.startDate - b.startDate;
|
||||||
});
|
});
|
||||||
if (limitNumberOfEntries) {
|
|
||||||
Log.debug(`pushing ${by_url_calevents.length} events to total with room for ${remainingEntries}`);
|
Log.debug(`pushing ${by_url_calevents.length} events to total with room for ${remainingEntries}`);
|
||||||
events = events.concat(by_url_calevents.slice(0, remainingEntries));
|
events = events.concat(by_url_calevents.slice(0, remainingEntries));
|
||||||
Log.debug(`events for calendar=${events.length}`);
|
Log.debug(`events for calendar=${events.length}`);
|
||||||
@@ -911,7 +912,11 @@ Module.register("calendar", {
|
|||||||
let p = this.getCalendarProperty(url, property, defaultValue);
|
let p = this.getCalendarProperty(url, property, defaultValue);
|
||||||
if (property === "symbol" || property === "recurringSymbol" || property === "fullDaySymbol") {
|
if (property === "symbol" || property === "recurringSymbol" || property === "fullDaySymbol") {
|
||||||
const className = this.getCalendarProperty(url, "symbolClassName", this.config.defaultSymbolClassName);
|
const className = this.getCalendarProperty(url, "symbolClassName", this.config.defaultSymbolClassName);
|
||||||
if (p instanceof Array) p.push(className);
|
if (p instanceof Array) {
|
||||||
|
let t = [];
|
||||||
|
p.forEach((n) => { t.push(className + n); });
|
||||||
|
p = t;
|
||||||
|
}
|
||||||
else p = className + p;
|
else p = className + p;
|
||||||
}
|
}
|
||||||
if (!(p instanceof Array)) p = [p];
|
if (!(p instanceof Array)) p = [p];
|
||||||
|
39
tests/configs/modules/calendar/countCalendarEvents.js
Normal file
39
tests/configs/modules/calendar/countCalendarEvents.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
let config = {
|
||||||
|
address: "0.0.0.0",
|
||||||
|
ipWhitelist: [],
|
||||||
|
timeFormat: 12,
|
||||||
|
foreignModulesDir: "tests/mocks",
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "calendar",
|
||||||
|
position: "bottom_bar",
|
||||||
|
|
||||||
|
config: {
|
||||||
|
maximumEntries: 1,
|
||||||
|
calendars: [
|
||||||
|
{
|
||||||
|
fetchInterval: 10000, //7 * 24 * 60 * 60 * 1000,
|
||||||
|
symbol: ["calendar-check", "google"],
|
||||||
|
url: "http://localhost:8080/tests/mocks/12_events.ics"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
module: "testNotification",
|
||||||
|
position: "bottom_bar",
|
||||||
|
config: {
|
||||||
|
debug: true,
|
||||||
|
match: {
|
||||||
|
matchtype: "count",
|
||||||
|
notificationID: "CALENDAR_EVENTS"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {
|
||||||
|
module.exports = config;
|
||||||
|
}
|
28
tests/configs/modules/calendar/symboltest.js
Normal file
28
tests/configs/modules/calendar/symboltest.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
let config = {
|
||||||
|
address: "0.0.0.0",
|
||||||
|
ipWhitelist: [],
|
||||||
|
timeFormat: 12,
|
||||||
|
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "calendar",
|
||||||
|
position: "bottom_bar",
|
||||||
|
config: {
|
||||||
|
maximumEntries: 1,
|
||||||
|
calendars: [
|
||||||
|
{
|
||||||
|
fetchInterval: 7 * 24 * 60 * 60 * 1000,
|
||||||
|
symbol: ["calendar-check", "google"],
|
||||||
|
url: "https://ics.calendarlabs.com/76/mm3137/US_Holidays.ics"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {
|
||||||
|
module.exports = config;
|
||||||
|
}
|
@@ -13,9 +13,9 @@ describe("Calendar module", () => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const doTestCount = async () => {
|
const doTestCount = async (locator = ".calendar .event") => {
|
||||||
expect(global.page).not.toBeNull();
|
expect(global.page).not.toBeNull();
|
||||||
const loc = await global.page.locator(".calendar .event");
|
const loc = await global.page.locator(locator);
|
||||||
const elem = loc.first();
|
const elem = loc.first();
|
||||||
await elem.waitFor();
|
await elem.waitFor();
|
||||||
expect(elem).not.toBeNull();
|
expect(elem).not.toBeNull();
|
||||||
@@ -32,8 +32,8 @@ describe("Calendar module", () => {
|
|||||||
// uses playwright nth locator syntax
|
// uses playwright nth locator syntax
|
||||||
const doTestTableContent = async (table_row, table_column, content, row = first) => {
|
const doTestTableContent = async (table_row, table_column, content, row = first) => {
|
||||||
const elem = await global.page.locator(table_row);
|
const elem = await global.page.locator(table_row);
|
||||||
const date = await global.page.locator(table_column).locator(`nth=${row}`);
|
const column = await elem.locator(table_column).locator(`nth=${row}`);
|
||||||
await expect(date.textContent()).resolves.toContain(content);
|
await expect(column.textContent()).resolves.toContain(content);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,4 +279,21 @@ describe("Calendar module", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("count and check symbols", () => {
|
||||||
|
it("in array", async () => {
|
||||||
|
await helpers.startApplication("tests/configs/modules/calendar/symboltest.js", "08 Oct 2024 12:30:00 GMT-07:00", ["js/electron.js"], "America/Chicago");
|
||||||
|
// just
|
||||||
|
await expect(doTestCount(".calendar .event .symbol .fa-fw")).resolves.toBe(2);
|
||||||
|
await expect(doTestCount(".calendar .event .symbol .fa-calendar-check")).resolves.toBe(1);
|
||||||
|
await expect(doTestCount(".calendar .event .symbol .fa-google")).resolves.toBe(1);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("count events broadcast", () => {
|
||||||
|
it("get 12 with maxentries set to 1", async () => {
|
||||||
|
await helpers.startApplication("tests/configs/modules/calendar/countCalendarEvents.js", "01 Jan 2024 12:30:00 GMT-076:00", ["js/electron.js"], "America/Chicago");
|
||||||
|
await expect(doTestTableContent(".testNotification", ".elementCount", "12", first)).resolves.toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
164
tests/mocks/12_events.ics
Normal file
164
tests/mocks/12_events.ics
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Calendar Labs//Calendar 1.0//EN
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
METHOD:PUBLISH
|
||||||
|
X-WR-CALNAME:US Holidays
|
||||||
|
X-WR-TIMEZONE:Etc/GMT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 1
|
||||||
|
DTSTART:20190101
|
||||||
|
DTEND:20190101
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949sada28d231582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 2
|
||||||
|
DTSTART:20190201
|
||||||
|
DTEND:20190201
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2wds8d231582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 3
|
||||||
|
DTSTART:20190301
|
||||||
|
DTEND:20190301
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2SDD8d231582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 4
|
||||||
|
DTSTART:20190401
|
||||||
|
DTEND:20190401
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2SDD8d231582FDSFD470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 5
|
||||||
|
DTSTART:20190501
|
||||||
|
DTEND:20190501
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2SDD8d2DD315824702598@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 6
|
||||||
|
DTSTART:20190601
|
||||||
|
DTEND:20190601
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2SDD8d2DD31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 7
|
||||||
|
DTSTART:20190701
|
||||||
|
DTEND:20190701
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52942SDD8d2DD31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 8
|
||||||
|
DTSTART:20190801
|
||||||
|
DTEND:20190801
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e52949a2SDD8d2DDt31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 9
|
||||||
|
DTSTART:20190901
|
||||||
|
DTEND:20190901
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e529449a2SDD8d2DDt315824702798@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 10
|
||||||
|
DTSTART:20191001
|
||||||
|
DTEND:20191001
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e529449a2SDD8d2DDt31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 11
|
||||||
|
DTSTART:20191101
|
||||||
|
DTEND:20191101
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e5294449a2SDD8d2DDt31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VEVENT
|
||||||
|
SUMMARY:Start of Month 12
|
||||||
|
DTSTART:20191201
|
||||||
|
DTEND:20191201
|
||||||
|
RRULE:FREQ=YEARLY;WKST=SU;INTERVAL=1
|
||||||
|
LOCATION:United States
|
||||||
|
DESCRIPTION:Visit https://calendarlabs.com/holidays/us/new-years-day.php to know more about New Year's Day. \n\n Like us on Facebook: http://fb.com/calendarlabs to get updates
|
||||||
|
UID:5e5294a2SDD8d2DDt31582470298@calendarlabs.com
|
||||||
|
DTSTAMP:20200223T150458Z
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
TRANSP:TRANSPARENT
|
||||||
|
SEQUENCE:0
|
||||||
|
END:VEVENT
|
||||||
|
END:VCALENDAR
|
59
tests/mocks/testNotification/testNotification.js
Normal file
59
tests/mocks/testNotification/testNotification.js
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
Module.register("testNotification", {
|
||||||
|
defaults: {
|
||||||
|
debug: false,
|
||||||
|
match: {
|
||||||
|
notificationID: "",
|
||||||
|
matchtype: "count"
|
||||||
|
//or
|
||||||
|
// type: 'contents' // look for item in field of content
|
||||||
|
}
|
||||||
|
},
|
||||||
|
count: 0,
|
||||||
|
table: null,
|
||||||
|
notificationReceived (notification, payload) {
|
||||||
|
if (notification === this.config.match.notificationID) {
|
||||||
|
if (this.config.match.matchtype === "count") {
|
||||||
|
this.count = payload.length;
|
||||||
|
if (this.count) {
|
||||||
|
this.table = document.createElement("table");
|
||||||
|
this.addTableRow(this.table, null, `${this.count}:elementCount`);
|
||||||
|
if (this.config.debug) {
|
||||||
|
payload.forEach((e, i) => {
|
||||||
|
this.addTableRow(this.table, i, e.title);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateDom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maketd (row, info) {
|
||||||
|
let td = document.createElement("td");
|
||||||
|
row.appendChild(td);
|
||||||
|
if (info !== null) {
|
||||||
|
let colinfo = info.toString().split(":");
|
||||||
|
if (colinfo.length === 2) td.className = colinfo[1];
|
||||||
|
td.innerText = colinfo[0];
|
||||||
|
}
|
||||||
|
return td;
|
||||||
|
},
|
||||||
|
addTableRow (table, col1 = null, col2 = null, col3 = null) {
|
||||||
|
let tableRow = document.createElement("tr");
|
||||||
|
table.appendChild(tableRow);
|
||||||
|
|
||||||
|
let tablecol1 = this.maketd(tableRow, col1);
|
||||||
|
let tablecol2 = this.maketd(tableRow, col2);
|
||||||
|
let tablecol3 = this.maketd(tableRow, col3);
|
||||||
|
|
||||||
|
return tableRow;
|
||||||
|
},
|
||||||
|
getDom () {
|
||||||
|
let wrapper = document.createElement("div");
|
||||||
|
if (this.table) {
|
||||||
|
wrapper.appendChild(this.table);
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
Reference in New Issue
Block a user