Merge branch 'develop' into clean-up-updatenotifications-and-nunjuck-templating

This commit is contained in:
Michael Teeuw 2021-10-06 15:21:54 +02:00 committed by GitHub
commit 5bfbd3eaa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 767 additions and 773 deletions

View File

@ -15,9 +15,12 @@ _This release is scheduled to be released on 2022-01-01._
- ESLint version supports now ECMAScript 2018 - ESLint version supports now ECMAScript 2018
- Cleaned up `updatenotification` module and switched to nunjuck template. - Cleaned up `updatenotification` module and switched to nunjuck template.
- Move calendar tests from category `electron` to `e2e`.
### Fixed ### Fixed
- Fix feels_like data from openweathermaps current weather being ignored (#2678).
## [2.17.1] - 2021-10-01 ## [2.17.1] - 2021-10-01
### Fixed ### Fixed

View File

@ -127,6 +127,8 @@ WeatherProvider.register("openweathermap", {
currentWeather.humidity = currentWeatherData.main.humidity; currentWeather.humidity = currentWeatherData.main.humidity;
currentWeather.temperature = currentWeatherData.main.temp; currentWeather.temperature = currentWeatherData.main.temp;
currentWeather.feelsLikeTemp = currentWeatherData.main.feels_like;
if (this.config.windUnits === "metric") { if (this.config.windUnits === "metric") {
currentWeather.windSpeed = this.config.useKmh ? currentWeatherData.wind.speed * 3.6 : currentWeatherData.wind.speed; currentWeather.windSpeed = this.config.useKmh ? currentWeatherData.wind.speed * 3.6 : currentWeatherData.wind.speed;
} else { } else {

1202
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,12 +47,12 @@
"homepage": "https://magicmirror.builders", "homepage": "https://magicmirror.builders",
"devDependencies": { "devDependencies": {
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.4.2", "eslint-plugin-jest": "^24.5.2",
"eslint-plugin-jsdoc": "^36.1.0", "eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"express-basic-auth": "^1.2.0", "express-basic-auth": "^1.2.0",
"husky": "^7.0.2", "husky": "^7.0.2",
"jest": "^27.2.2", "jest": "^27.2.4",
"jsdom": "^17.0.0", "jsdom": "^17.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nyc": "^15.1.0", "nyc": "^15.1.0",
@ -114,8 +114,7 @@
], ],
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"<rootDir>/tests/electron/modules/mocks", "<rootDir>/tests/electron/modules/mocks",
"<rootDir>/tests/electron/global-setup.js", "<rootDir>/tests/electron/global-setup.js"
"<rootDir>/tests/electron/modules/basic-auth.js"
] ]
}, },
{ {
@ -131,7 +130,8 @@
], ],
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"<rootDir>/tests/e2e/global-setup.js", "<rootDir>/tests/e2e/global-setup.js",
"<rootDir>/tests/e2e/mock-console.js" "<rootDir>/tests/e2e/mock-console.js",
"<rootDir>/tests/e2e/modules/basic-auth.js"
] ]
} }
] ]

View File

@ -3,7 +3,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -25,7 +25,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rejas * By Rejas
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -24,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -5,7 +5,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -27,7 +27,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -22,7 +22,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,7 +3,7 @@
* By Rejas * By Rejas
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -21,7 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -4,7 +4,7 @@
* @param {string} err The error message. * @param {string} err The error message.
*/ */
function mockError(err) { function mockError(err) {
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) { if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined") || err.includes("write EPIPE")) {
jest.fn(); jest.fn();
} else { } else {
console.dir(err); console.dir(err);

View File

@ -0,0 +1,139 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("./basic-auth.js");
describe("Calendar module", function () {
/**
* @param {string} element css selector
* @param {string} result expected number
* @param {string} not reverse result
*/
function testElementLength(element, result, not) {
const elem = document.querySelectorAll(element);
expect(elem).not.toBe(null);
if (not === "not") {
expect(elem.length).not.toBe(result);
} else {
expect(elem.length).toBe(result);
}
}
afterAll(function () {
helpers.stopApplication();
});
describe("Default configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/default.js");
helpers.getDocument(done, 3000);
});
it("should show the default maximumEntries of 10", () => {
testElementLength(".calendar .event", 10);
});
it("should show the default calendar symbol in each event", () => {
testElementLength(".calendar .event .fa-calendar", 0, "not");
});
});
describe("Custom configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/custom.js");
helpers.getDocument(done, 3000);
});
it("should show the custom maximumEntries of 4", () => {
testElementLength(".calendar .event", 4);
});
it("should show the custom calendar symbol in each event", () => {
testElementLength(".calendar .event .fa-birthday-cake", 4);
});
it("should show two custom icons for repeating events", () => {
testElementLength(".calendar .event .fa-undo", 2);
});
it("should show two custom icons for day events", () => {
testElementLength(".calendar .event .fa-calendar-day", 2);
});
});
describe("Recurring event", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
helpers.getDocument(done, 3000);
});
it("should show the recurring birthday event 6 times", () => {
testElementLength(".calendar .event", 6);
});
});
describe("Changed port", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
serverBasicAuth.listen(8010);
helpers.getDocument(done, 3000);
});
afterAll(function (done) {
serverBasicAuth.close(done());
});
it("should return TestEvents", function () {
testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
helpers.getDocument(done, 3000);
});
it("should return TestEvents", function () {
testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth by default", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
helpers.getDocument(done, 3000);
});
it("should return TestEvents", function () {
testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
helpers.getDocument(done, 3000);
});
it("should return TestEvents", function () {
testElementLength(".calendar .event", 0, "not");
});
});
describe("Fail Basic auth", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
serverBasicAuth.listen(8020);
helpers.getDocument(done, 3000);
});
afterAll(function (done) {
serverBasicAuth.close(done());
});
it("should show Unauthorized error", function () {
const elem = document.querySelector(".calendar");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Error in the calendar module. Authorization failed");
});
});
});

View File

@ -1,150 +0,0 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("./basic-auth.js");
describe("Calendar module", function () {
helpers.setupTimeout(this);
let app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("Default configuration", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
});
it("should show the default maximumEntries of 10", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const events = await app.client.$$(".calendar .event");
return expect(events.length).toBe(10);
});
it("should show the default calendar symbol in each event", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const icons = await app.client.$$(".calendar .event .fa-calendar");
return expect(icons.length).not.toBe(0);
});
});
describe("Custom configuration", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/custom.js";
});
it("should show the custom maximumEntries of 4", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const events = await app.client.$$(".calendar .event");
return expect(events.length).toBe(4);
});
it("should show the custom calendar symbol in each event", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
const icons = await app.client.$$(".calendar .event .fa-birthday-cake");
return expect(icons.length).toBe(4);
});
it("should show two custom icons for repeating events", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEventRepeat", 10000);
const icons = await app.client.$$(".calendar .event .fa-undo");
return expect(icons.length).toBe(2);
});
it("should show two custom icons for day events", async () => {
await app.client.waitUntilTextExists(".calendar", "TestEventDay", 10000);
const icons = await app.client.$$(".calendar .event .fa-calendar-day");
return expect(icons.length).toBe(2);
});
});
describe("Recurring event", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/recurring.js";
});
it("should show the recurring birthday event 6 times", async () => {
await app.client.waitUntilTextExists(".calendar", "Mar 25th", 10000);
const events = await app.client.$$(".calendar .event");
return expect(events.length).toBe(6);
});
});
describe("Changed port", function () {
beforeAll(function () {
serverBasicAuth.listen(8010);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js";
});
afterAll(function (done) {
serverBasicAuth.close(done());
});
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
});
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth by default", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
});
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
});
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});
describe("Fail Basic auth", function () {
beforeAll(function () {
serverBasicAuth.listen(8020);
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
});
afterAll(function (done) {
serverBasicAuth.close(done());
});
it("should show Unauthorized error", function () {
return app.client.waitUntilTextExists(".calendar", "Error in the calendar module. Authorization failed", 10000);
});
});
});