From e6fea297e57afe917e4b001b1c2dc435a7c1af50 Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 11 Apr 2021 21:55:30 +0200 Subject: [PATCH 1/3] Add test for decimalSymbol in weatherforecast --- .../modules/weather/forecastweather_units.js | 41 +++++++++++++++++++ tests/e2e/modules/weather_spec.js | 19 ++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/configs/modules/weather/forecastweather_units.js diff --git a/tests/configs/modules/weather/forecastweather_units.js b/tests/configs/modules/weather/forecastweather_units.js new file mode 100644 index 00000000..c22335f4 --- /dev/null +++ b/tests/configs/modules/weather/forecastweather_units.js @@ -0,0 +1,41 @@ +/* Magic Mirror Test config default weather + * + * By fewieden https://github.com/fewieden + * + * MIT Licensed. + */ + +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 24, + units: "imperial", + electronOptions: { + webPreferences: { + nodeIntegration: true, + enableRemoteModule: true + } + }, + + modules: [ + { + module: "weather", + position: "bottom_bar", + config: { + type: "forecast", + location: "Munich", + apiKey: "fake key", + weatherEndpoint: "/forecast/daily", + initialLoadDelay: 3000, + decimalSymbol: "_" + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index cd386f3c..bf7d9af2 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -164,7 +164,7 @@ describe("Weather module", function () { return getText(".weather .normal.medium span:nth-child(2)", "6 WSW") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); }); - it("should render decimalSymbol = ','", async function () { + it("should render custom decimalSymbol = ','", async function () { const weather = generateWeather({ main: { temp: (1.49 * 9) / 5 + 32, @@ -274,5 +274,22 @@ describe("Weather module", function () { expect(rows.length).to.be.equal(5); }); }); + + describe("Forecast weather units", function () { + before(function () { + process.env.MM_CONFIG_FILE = "tests/configs/modules/weather/forecastweather_units.js"; + }); + + it("should render custom decimalSymbol = '_'", async function () { + const weather = generateWeatherForecast(); + await setup({ template, data: weather }); + + const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"]; + + for (const [index, temp] of temperatures.entries()) { + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); + } + }); + }); }); }); From f93b819ea61cdc789e658644d9d1c67a26902a89 Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 11 Apr 2021 22:42:21 +0200 Subject: [PATCH 2/3] Fix missing await calls in tests --- tests/e2e/modules/weather_spec.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index bf7d9af2..70c88512 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -139,7 +139,7 @@ describe("Weather module", function () { const weather = generateWeather(); await setup({ template, data: weather }); - return getText(".weather .large.light span.bright", "1°C") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C"); + return (await getText(".weather .large.light span.bright", "1°C")) && (await getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C")); }); }); @@ -161,7 +161,7 @@ describe("Weather module", function () { }); await setup({ template, data: weather }); - return getText(".weather .normal.medium span:nth-child(2)", "6 WSW") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); + return (await getText(".weather .normal.medium span:nth-child(2)", "6 WSW")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); }); it("should render custom decimalSymbol = ','", async function () { @@ -177,7 +177,7 @@ describe("Weather module", function () { }); await setup({ template, data: weather }); - return getText(".weather .normal.medium span:nth-child(3)", "93,7") && getText(".weather .large.light span.bright", "34,7°") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); + return (await getText(".weather .normal.medium span:nth-child(3)", "93,7")) && (await getText(".weather .large.light span.bright", "34,7°")) && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°"); }); }); }); @@ -201,7 +201,7 @@ describe("Weather module", function () { const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"]; for (const [index, day] of days.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day); } }); @@ -212,7 +212,7 @@ describe("Weather module", function () { const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"]; for (const [index, icon] of icons.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`); + await getElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`); } }); @@ -223,7 +223,7 @@ describe("Weather module", function () { const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"]; for (const [index, temp] of temperatures.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp); } }); @@ -234,7 +234,7 @@ describe("Weather module", function () { const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"]; for (const [index, temp] of temperatures.entries()) { - getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp); + await getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp); } }); From db65ff12d7bd79b748a9949456e193c1948d3c81 Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 11 Apr 2021 22:43:47 +0200 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + tests/configs/modules/weather/forecastweather_units.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f49e8001..42f73049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ _This release is scheduled to be released on 2021-04-01._ - Fix calendar start function logging inconsistency. - Fix updatenotification start function logging inconsistency. - Checks and applies the showDescription setting for the newsfeed module again +- Fix tests in weather module and add one for decimalPoint in forecast ## [2.15.0] - 2021-04-01 diff --git a/tests/configs/modules/weather/forecastweather_units.js b/tests/configs/modules/weather/forecastweather_units.js index c22335f4..9d1a54ff 100644 --- a/tests/configs/modules/weather/forecastweather_units.js +++ b/tests/configs/modules/weather/forecastweather_units.js @@ -1,10 +1,8 @@ /* Magic Mirror Test config default weather * - * By fewieden https://github.com/fewieden - * + * By rejas * MIT Licensed. */ - let config = { port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],