From 9f9fcd0563e6920555c22e2870b578f35f41fe24 Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:10:11 +0100 Subject: [PATCH 1/8] Update compliments module Add config option "specialDaysUnique". If set to true, only compliments configured for special days will be shown on those days. Default setting is false. --- modules/default/compliments/compliments.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 39e6c34d49..c249f9915f 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -15,7 +15,8 @@ Module.register("compliments", { morningEndTime: 12, afternoonStartTime: 12, afternoonEndTime: 17, - random: true + random: true, + specialDayUnique: false }, lastIndexUsed: -1, // Set currentweather from module @@ -98,6 +99,10 @@ Module.register("compliments", { // Add compliments for special days for (let entry in this.config.compliments) { if (new RegExp(entry).test(date)) { + // Only display compliments configured for the day if specialDayUnique is set to true + if (this.config.specialDayUnique) { + compliments.length = 0; + } Array.prototype.push.apply(compliments, this.config.compliments[entry]); } } From 631a8e626cf1fb5eff84343470d6e01e598a9c55 Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:12:34 +0100 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10edb8aaa6..35fcb6f62c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ _This release is scheduled to be released on 2024-07-01._ ### Added +- [compliments] Added `specialDayUnique` config option, defaults to `false`. When set to `true` it replaces the existing compliments array with only the compliments that have been configured for that day (#3465) + ### Removed ### Updated From 974fbc36da4d5770e334aadf78663a1f9689f0f8 Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:01:20 +0100 Subject: [PATCH 3/8] Update CHANGELOG.md Changes suggested by rejas after review Co-authored-by: Veeck --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35fcb6f62c..7c8fd80738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ _This release is scheduled to be released on 2024-07-01._ ### Added -- [compliments] Added `specialDayUnique` config option, defaults to `false`. When set to `true` it replaces the existing compliments array with only the compliments that have been configured for that day (#3465) +- [compliments] Added `specialDayUnique` config option, defaults to `false`. (#3465) ### Removed From 435d98c89175e0fb9d13c3a7b757d028821bf1be Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:28:46 +0100 Subject: [PATCH 4/8] Add files via upload --- .../compliments_specialDayUnique_false.js | 25 +++++++++++++++++++ .../compliments_specialDayUnique_true.js | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/configs/modules/compliments/compliments_specialDayUnique_false.js create mode 100644 tests/configs/modules/compliments/compliments_specialDayUnique_true.js diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js new file mode 100644 index 0000000000..9d522d6a0c --- /dev/null +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js @@ -0,0 +1,25 @@ +let config = { + modules: [ + { + module: "compliments", + position: "middle_center", + config: { + updateInterval: 1000 * 5, // Update every 10 secs + specialDayUnique: false, + compliments: { + anytime: [ + "Typical message 1", + "Typical message 2", + "Typical message 3" + ], + "....-..-..": [ + "Special day message" + ] + }, + }, + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { module.exports = config; } diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js new file mode 100644 index 0000000000..e216454fd0 --- /dev/null +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js @@ -0,0 +1,25 @@ +let config = { + modules: [ + { + module: "compliments", + position: "middle_center", + config: { + updateInterval: 1000 * 5, // Update every 10 secs + specialDayUnique: true, + compliments: { + anytime: [ + "Typical message 1", + "Typical message 2", + "Typical message 3" + ], + "....-..-..": [ + "Special day message" + ] + }, + }, + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { module.exports = config; } From a79fdca56e6805b19a24997a5ad7c0417d162988 Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:46:18 +0100 Subject: [PATCH 5/8] Update compliments_specialDayUnique_false.js Minor typo --- .../modules/compliments/compliments_specialDayUnique_false.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js index 9d522d6a0c..4982eb13d6 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js @@ -4,7 +4,7 @@ let config = { module: "compliments", position: "middle_center", config: { - updateInterval: 1000 * 5, // Update every 10 secs + updateInterval: 1000 * 5, // Update every 5 secs specialDayUnique: false, compliments: { anytime: [ From 68ad5a52bbb87c15d88574bc9a062cef5a3c4290 Mon Sep 17 00:00:00 2001 From: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:46:34 +0100 Subject: [PATCH 6/8] Update compliments_specialDayUnique_true.js Minor typo --- .../modules/compliments/compliments_specialDayUnique_true.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js index e216454fd0..55c6a69d14 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js @@ -4,7 +4,7 @@ let config = { module: "compliments", position: "middle_center", config: { - updateInterval: 1000 * 5, // Update every 10 secs + updateInterval: 1000 * 5, // Update every 5 secs specialDayUnique: true, compliments: { anytime: [ From 79bdc834a34eca442f657dccf5009344de1f3f5f Mon Sep 17 00:00:00 2001 From: veeck Date: Sat, 22 Jun 2024 21:35:29 +0200 Subject: [PATCH 7/8] fix intendation --- .../compliments_specialDayUnique_false.js | 38 +++++++++---------- .../compliments_specialDayUnique_true.js | 38 +++++++++---------- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js index 4982eb13d6..f81f2c1c76 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js @@ -1,24 +1,22 @@ let config = { - modules: [ - { - module: "compliments", - position: "middle_center", - config: { - updateInterval: 1000 * 5, // Update every 5 secs - specialDayUnique: false, - compliments: { - anytime: [ - "Typical message 1", - "Typical message 2", - "Typical message 3" - ], - "....-..-..": [ - "Special day message" - ] - }, - }, - } - ] + modules: [ + { + module: "compliments", + position: "middle_center", + config: { + updateInterval: 1000 * 5, // Update every 5 secs + specialDayUnique: false, + compliments: { + anytime: [ + "Typical message 1", + "Typical message 2", + "Typical message 3" + ], + "....-..-..": ["Special day message"] + } + } + } + ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js index 55c6a69d14..52ed67b8db 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js @@ -1,24 +1,22 @@ let config = { - modules: [ - { - module: "compliments", - position: "middle_center", - config: { - updateInterval: 1000 * 5, // Update every 5 secs - specialDayUnique: true, - compliments: { - anytime: [ - "Typical message 1", - "Typical message 2", - "Typical message 3" - ], - "....-..-..": [ - "Special day message" - ] - }, - }, - } - ] + modules: [ + { + module: "compliments", + position: "middle_center", + config: { + updateInterval: 1000 * 5, // Update every 5 secs + specialDayUnique: true, + compliments: { + anytime: [ + "Typical message 1", + "Typical message 2", + "Typical message 3" + ], + "....-..-..": ["Special day message"] + } + } + } + ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ From 707526a18cf7f53b3f9000d5b60ccfaf523ab5eb Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Mon, 24 Jun 2024 22:07:54 +0200 Subject: [PATCH 8/8] add tests --- .../compliments_specialDayUnique_false.js | 1 - .../compliments_specialDayUnique_true.js | 1 - tests/e2e/modules/compliments_spec.js | 24 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js index f81f2c1c76..e4cb64c6ab 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_false.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_false.js @@ -4,7 +4,6 @@ let config = { module: "compliments", position: "middle_center", config: { - updateInterval: 1000 * 5, // Update every 5 secs specialDayUnique: false, compliments: { anytime: [ diff --git a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js index 52ed67b8db..3d578611c8 100644 --- a/tests/configs/modules/compliments/compliments_specialDayUnique_true.js +++ b/tests/configs/modules/compliments/compliments_specialDayUnique_true.js @@ -4,7 +4,6 @@ let config = { module: "compliments", position: "middle_center", config: { - updateInterval: 1000 * 5, // Update every 5 secs specialDayUnique: true, compliments: { anytime: [ diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js index 0604dab49f..95b342577e 100644 --- a/tests/e2e/modules/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -54,4 +54,28 @@ describe("Compliments module", () => { await expect(doTest(["Remote compliment file works!"])).resolves.toBe(true); }); }); + + describe("Feature specialDayUnique in compliments module", () => { + describe("specialDayUnique is false", () => { + beforeAll(async () => { + await helpers.startApplication("tests/configs/modules/compliments/compliments_specialDayUnique_false.js"); + await helpers.getDocument(); + }); + + it("compliments array can contain all values", async () => { + await expect(doTest(["Special day message", "Typical message 1", "Typical message 2", "Typical message 3"])).resolves.toBe(true); + }); + }); + + describe("specialDayUnique is true", () => { + beforeAll(async () => { + await helpers.startApplication("tests/configs/modules/compliments/compliments_specialDayUnique_true.js"); + await helpers.getDocument(); + }); + + it("compliments array contains only special value", async () => { + await expect(doTest(["Special day message"])).resolves.toBe(true); + }); + }); + }); });