mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Fix empty part-of-day logic (#3726)
Fixes #3727 --------- Co-authored-by: veeck <gitkraken@veeck.de>
This commit is contained in:
parent
28bcee7de6
commit
4a398f03eb
@ -42,6 +42,7 @@ planned for 2025-04-01
|
||||
- [core] Fix wrong port in log message when starting server only (#3696)
|
||||
- [calendar] Fix NewYork event processed on system in Central timezone shows wrong time #3701
|
||||
- [weather/yr] The Yr weather provider is now able to recover from bad API responses instead of freezing (#3296)
|
||||
- [compliments] Fix evening events being shown during the day (#3727)
|
||||
|
||||
## [2.30.0] - 2025-01-01
|
||||
|
||||
|
@ -139,12 +139,17 @@ Module.register("compliments", {
|
||||
let compliments = [];
|
||||
|
||||
// Add time of day compliments
|
||||
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
|
||||
compliments = [...this.config.compliments.morning];
|
||||
} else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime && this.config.compliments.hasOwnProperty("afternoon")) {
|
||||
compliments = [...this.config.compliments.afternoon];
|
||||
} else if (this.config.compliments.hasOwnProperty("evening")) {
|
||||
compliments = [...this.config.compliments.evening];
|
||||
let timeOfDay;
|
||||
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime) {
|
||||
timeOfDay = "morning";
|
||||
} else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime) {
|
||||
timeOfDay = "afternoon";
|
||||
} else {
|
||||
timeOfDay = "evening";
|
||||
}
|
||||
|
||||
if (timeOfDay && this.config.compliments.hasOwnProperty(timeOfDay)) {
|
||||
compliments = [...this.config.compliments[timeOfDay]];
|
||||
}
|
||||
|
||||
// Add compliments based on weather
|
||||
|
22
package-lock.json
generated
22
package-lock.json
generated
@ -11,7 +11,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1",
|
||||
"ansis": "^3.10.0",
|
||||
"ansis": "^3.16.0",
|
||||
"console-stamp": "^3.1.2",
|
||||
"envsub": "^4.1.0",
|
||||
"eslint": "^9.21.0",
|
||||
@ -31,8 +31,8 @@
|
||||
"undici": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin": "^4.0.1",
|
||||
"cspell": "^8.17.3",
|
||||
"@stylistic/eslint-plugin": "^4.1.0",
|
||||
"cspell": "^8.17.5",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-jsdoc": "^50.6.3",
|
||||
@ -44,7 +44,7 @@
|
||||
"lint-staged": "^15.4.3",
|
||||
"markdownlint-cli2": "^0.17.2",
|
||||
"playwright": "^1.50.1",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier": "^3.5.2",
|
||||
"sinon": "^19.0.2",
|
||||
"stylelint": "^16.14.1",
|
||||
"stylelint-config-standard": "^37.0.0",
|
||||
@ -2584,9 +2584,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@stylistic/eslint-plugin": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-4.0.1.tgz",
|
||||
"integrity": "sha512-RwKkRKiDrF4ptiur54ckDhOByQYKYZ1dEmI5K8BJCmuGpauFJXzVL1UQYTA2zq702CqMFdYiJcVFJWfokIgFxw==",
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-4.1.0.tgz",
|
||||
"integrity": "sha512-bytbL7qiici7yPyEiId0fGPK9kjQbzcPMj2aftPfzTCyJ/CRSKdtI+iVjM0LSGzGxfunflI+MDDU9vyIIeIpoQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -3078,12 +3078,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ansis": {
|
||||
"version": "3.10.0",
|
||||
"resolved": "https://registry.npmjs.org/ansis/-/ansis-3.10.0.tgz",
|
||||
"integrity": "sha512-hxDKLYT7hy3Y4sF3HxI926A3urzPxi73mZBB629m9bCVF+NyKNxbwCqqm+C/YrGPtxLwnl6d8/ZASCsz6SyvJA==",
|
||||
"version": "3.16.0",
|
||||
"resolved": "https://registry.npmjs.org/ansis/-/ansis-3.16.0.tgz",
|
||||
"integrity": "sha512-sU7d/tfZiYrsIAXbdL/CNZld5bCkruzwT5KmqmadCJYxuLxHAOBjidxD5+iLmN/6xEfjcQq1l7OpsiCBlc4LzA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/anymatch": {
|
||||
|
@ -63,7 +63,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1",
|
||||
"ansis": "^3.10.0",
|
||||
"ansis": "^3.16.0",
|
||||
"console-stamp": "^3.1.2",
|
||||
"envsub": "^4.1.0",
|
||||
"eslint": "^9.21.0",
|
||||
@ -83,8 +83,8 @@
|
||||
"undici": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin": "^4.0.1",
|
||||
"cspell": "^8.17.3",
|
||||
"@stylistic/eslint-plugin": "^4.1.0",
|
||||
"cspell": "^8.17.5",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-jsdoc": "^50.6.3",
|
||||
@ -96,7 +96,7 @@
|
||||
"lint-staged": "^15.4.3",
|
||||
"markdownlint-cli2": "^0.17.2",
|
||||
"playwright": "^1.50.1",
|
||||
"prettier": "^3.4.2",
|
||||
"prettier": "^3.5.2",
|
||||
"sinon": "^19.0.2",
|
||||
"stylelint": "^16.14.1",
|
||||
"stylelint-config-standard": "^37.0.0",
|
||||
|
22
tests/configs/modules/compliments/compliments_evening.js
Normal file
22
tests/configs/modules/compliments/compliments_evening.js
Normal file
@ -0,0 +1,22 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
timeFormat: 12,
|
||||
|
||||
modules: [
|
||||
{
|
||||
module: "compliments",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
compliments: {
|
||||
evening: ["Evening here"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
@ -49,10 +49,10 @@ exports.stopApplication = async () => {
|
||||
process.env.MOCK_DATE = undefined;
|
||||
};
|
||||
|
||||
exports.getElement = async (selector) => {
|
||||
exports.getElement = async (selector, state = "visible") => {
|
||||
expect(global.page).not.toBeNull();
|
||||
let elem = global.page.locator(selector);
|
||||
await elem.waitFor();
|
||||
const elem = global.page.locator(selector);
|
||||
await elem.waitFor({ state: state });
|
||||
expect(elem).not.toBeNull();
|
||||
return elem;
|
||||
};
|
||||
|
@ -7,9 +7,9 @@ describe("Compliments module", () => {
|
||||
* @param {Array} complimentsArray The array of compliments.
|
||||
* @returns {boolean} result
|
||||
*/
|
||||
const doTest = async (complimentsArray) => {
|
||||
await helpers.getElement(".compliments");
|
||||
const elem = await helpers.getElement(".module-content");
|
||||
const doTest = async (complimentsArray, state = "visible") => {
|
||||
await helpers.getElement(".compliments", state);
|
||||
const elem = await helpers.getElement(".module-content", state);
|
||||
expect(elem).not.toBeNull();
|
||||
expect(complimentsArray).toContain(await elem.textContent());
|
||||
return true;
|
||||
@ -34,6 +34,11 @@ describe("Compliments module", () => {
|
||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js", "01 Oct 2022 20:00:00 GMT");
|
||||
await expect(doTest(["Hello There", "Good Evening", "Evening test"])).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it("doesnt show evening compliments during the day when the other parts of day are not set", async () => {
|
||||
await helpers.startApplication("tests/configs/modules/compliments/compliments_evening.js", "01 Oct 2022 08:00:00 GMT");
|
||||
await expect(doTest([""], "attached")).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Feature date in compliments module", () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user