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

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Felix Wiedenbach 2021-10-02 14:15:54 +02:00
commit fc06f13c30
61 changed files with 1323 additions and 1313 deletions

BIN
.github/header.psd vendored

Binary file not shown.

View File

@ -17,18 +17,21 @@ jobs:
matrix: matrix:
node-version: [12.x, 14.x, 16.x] node-version: [12.x, 14.x, 16.x]
steps: steps:
- uses: actions/checkout@v2 - name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: | - name: Install dependencies and run tests
node -v run: |
Xvfb :99 -screen 0 1024x768x16 & Xvfb :99 -screen 0 1024x768x16 &
export DISPLAY=:99 export DISPLAY=:99
npm install npm install
touch css/custom.css
npm run test:prettier npm run test:prettier
npm run test:js npm run test:js
npm run test:css npm run test:css
npm run test:unit npm run test:unit
npm run test:e2e npm run test:e2e
npm run test:electron

View File

@ -13,13 +13,17 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v2 - name: Checkout code
- run: | uses: actions/checkout@v2
- name: Install dependencies and run coverage
run: |
Xvfb :99 -screen 0 1024x768x16 & Xvfb :99 -screen 0 1024x768x16 &
export DISPLAY=:99 export DISPLAY=:99
npm ci npm ci
touch css/custom.css
npm run test:coverage npm run test:coverage
- uses: codecov/codecov-action@v1 - name: Upload coverage results to codecov
uses: codecov/codecov-action@v1
with: with:
file: ./coverage/lcov.info file: ./coverage/lcov.info
fail_ci_if_error: true fail_ci_if_error: true

View File

@ -11,8 +11,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v2 - name: Checkout code
- uses: dangoslen/changelog-enforcer@v1.6.1 uses: actions/checkout@v2
- name: Enforce changelog
uses: dangoslen/changelog-enforcer@v1.6.1
with: with:
changeLogPath: "CHANGELOG.md" changeLogPath: "CHANGELOG.md"
skipLabels: "Skip Changelog" skipLabels: "Skip Changelog"

View File

@ -5,9 +5,27 @@ This project adheres to [Semantic Versioning](https://semver.org/).
❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² ❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror²
## [2.17.0] - Unreleased (Develop Branch) ## [2.18.0] - Unreleased (Develop Branch)
_This release is scheduled to be released on 2021-10-01._ _This release is scheduled to be released on 2022-01-01._
### Added
### Updated
- Cleaned up `updatenotification` module and switched to nunjuck template.
### Fixed
## [2.17.1] - 2021-10-01
### Fixed
- Fixed error when accessing letsencrypt certificates
## [2.17.0] - 2021-10-01
Special thanks to the following contributors: @apiontek, @eouia, @jupadin, @khassel and @rejas.
### Added ### Added
@ -27,7 +45,8 @@ _This release is scheduled to be released on 2021-10-01._
- Refactored methods from weatherproviders into weatherobject (isDaytime, updateSunTime). - Refactored methods from weatherproviders into weatherobject (isDaytime, updateSunTime).
- Use of `logger.js` in jest tests. - Use of `logger.js` in jest tests.
- Run prettier over all relevant files. - Run prettier over all relevant files.
- Cleaned up updatenotification module and switched to nunjuck rendering. - Move tests needing electron in new category `electron`, use `server only` mode in `e2e` tests.
- Update dependencies in package.json.
### Fixed ### Fixed

View File

@ -48,6 +48,7 @@ process.on("uncaughtException", function (err) {
*/ */
function App() { function App() {
let nodeHelpers = []; let nodeHelpers = [];
let httpServer;
/** /**
* Loads the config file. Combines it with the defaults, and runs the * Loads the config file. Combines it with the defaults, and runs the
@ -222,7 +223,7 @@ function App() {
} }
loadModules(modules, function () { loadModules(modules, function () {
const server = new Server(config, function (app, io) { httpServer = new Server(config, function (app, io) {
Log.log("Server started ..."); Log.log("Server started ...");
for (let nodeHelper of nodeHelpers) { for (let nodeHelper of nodeHelpers) {
@ -253,6 +254,7 @@ function App() {
nodeHelper.stop(); nodeHelper.stop();
} }
} }
httpServer.close();
}; };
/** /**

View File

@ -9,12 +9,13 @@
*/ */
(function (root, factory) { (function (root, factory) {
if (typeof exports === "object") { if (typeof exports === "object") {
// add timestamps in front of log messages if (process.env.JEST_WORKER_ID === undefined) {
require("console-stamp")(console, { // add timestamps in front of log messages
pattern: "yyyy-mm-dd HH:MM:ss.l", require("console-stamp")(console, {
include: ["debug", "log", "info", "warn", "error"] pattern: "yyyy-mm-dd HH:MM:ss.l",
}); include: ["debug", "log", "info", "warn", "error"]
});
}
// Node, CommonJS-like // Node, CommonJS-like
module.exports = factory(root.config); module.exports = factory(root.config);
} else { } else {
@ -22,32 +23,57 @@
root.Log = factory(root.config); root.Log = factory(root.config);
} }
})(this, function (config) { })(this, function (config) {
let logLevel = { let logLevel;
debug: Function.prototype.bind.call(console.debug, console), let enableLog;
log: Function.prototype.bind.call(console.log, console), if (typeof exports === "object") {
info: Function.prototype.bind.call(console.info, console), // in nodejs and not running with jest
warn: Function.prototype.bind.call(console.warn, console), enableLog = process.env.JEST_WORKER_ID === undefined;
error: Function.prototype.bind.call(console.error, console), } else {
group: Function.prototype.bind.call(console.group, console), // in browser and not running with jsdom
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console), enableLog = typeof window === "object" && window.name !== "jsdom";
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
time: Function.prototype.bind.call(console.time, console),
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
};
if ((typeof exports === "object" && process.env.JEST_WORKER_ID === undefined) || typeof exports !== "object") {
logLevel.timeStamp = Function.prototype.bind.call(console.timeStamp, console);
} }
logLevel.setLogLevel = function (newLevel) { if (enableLog) {
if (newLevel) { logLevel = {
Object.keys(logLevel).forEach(function (key, index) { debug: Function.prototype.bind.call(console.debug, console),
if (!newLevel.includes(key.toLocaleUpperCase())) { log: Function.prototype.bind.call(console.log, console),
logLevel[key] = function () {}; info: Function.prototype.bind.call(console.info, console),
} warn: Function.prototype.bind.call(console.warn, console),
}); error: Function.prototype.bind.call(console.error, console),
} group: Function.prototype.bind.call(console.group, console),
}; groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
time: Function.prototype.bind.call(console.time, console),
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
};
logLevel.setLogLevel = function (newLevel) {
if (newLevel) {
Object.keys(logLevel).forEach(function (key, index) {
if (!newLevel.includes(key.toLocaleUpperCase())) {
logLevel[key] = function () {};
}
});
}
};
} else {
logLevel = {
debug: function () {},
log: function () {},
info: function () {},
warn: function () {},
error: function () {},
group: function () {},
groupCollapsed: function () {},
groupEnd: function () {},
time: function () {},
timeEnd: function () {},
timeStamp: function () {}
};
logLevel.setLogLevel = function () {};
}
return logLevel; return logLevel;
}); });

View File

@ -23,6 +23,7 @@ const Utils = require("./utils.js");
*/ */
function Server(config, callback) { function Server(config, callback) {
const port = process.env.MM_PORT || config.port; const port = process.env.MM_PORT || config.port;
const serverSockets = new Set();
let server = null; let server = null;
if (config.useHttps) { if (config.useHttps) {
@ -42,6 +43,13 @@ function Server(config, callback) {
allowEIO3: true allowEIO3: true
}); });
server.on("connection", (socket) => {
serverSockets.add(socket);
socket.on("close", () => {
serverSockets.delete(socket);
});
});
Log.log(`Starting server on port ${port} ... `); Log.log(`Starting server on port ${port} ... `);
server.listen(port, config.address || "localhost"); server.listen(port, config.address || "localhost");
@ -92,6 +100,13 @@ function Server(config, callback) {
if (typeof callback === "function") { if (typeof callback === "function") {
callback(app, io); callback(app, io);
} }
this.close = function () {
for (const socket of serverSockets.values()) {
socket.destroy();
}
server.close();
};
} }
module.exports = Server; module.exports = Server;

1128
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "magicmirror", "name": "magicmirror",
"version": "2.17.0-develop", "version": "2.18.0-develop",
"description": "The open source modular smart mirror platform.", "description": "The open source modular smart mirror platform.",
"main": "js/electron.js", "main": "js/electron.js",
"scripts": { "scripts": {
@ -12,6 +12,7 @@
"postinstall": "npm run install-fonts && echo \"MagicMirror installation finished successfully! \n\"", "postinstall": "npm run install-fonts && echo \"MagicMirror installation finished successfully! \n\"",
"test": "NODE_ENV=test jest -i --forceExit", "test": "NODE_ENV=test jest -i --forceExit",
"test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text jest -i --forceExit", "test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text jest -i --forceExit",
"test:electron": "NODE_ENV=test jest --selectProjects electron -i --forceExit",
"test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit", "test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit",
"test:unit": "NODE_ENV=test jest --selectProjects unit -i --forceExit", "test:unit": "NODE_ENV=test jest --selectProjects unit -i --forceExit",
"test:prettier": "prettier . --check", "test:prettier": "prettier . --check",
@ -46,16 +47,16 @@
"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.0", "eslint-plugin-jest": "^24.4.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.1.1", "jest": "^27.2.2",
"jsdom": "^17.0.0", "jsdom": "^17.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"prettier": "^2.4.0", "prettier": "^2.4.1",
"pretty-quick": "^3.1.1", "pretty-quick": "^3.1.1",
"sinon": "^11.1.2", "sinon": "^11.1.2",
"spectron": "^15.0.0", "spectron": "^15.0.0",
@ -66,7 +67,7 @@
"suncalc": "^1.8.0" "suncalc": "^1.8.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"electron": "^13.3.0" "electron": "^13.5.1"
}, },
"dependencies": { "dependencies": {
"colors": "^1.4.0", "colors": "^1.4.0",
@ -80,7 +81,7 @@
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"module-alias": "^2.2.2", "module-alias": "^2.2.2",
"moment": "^2.29.1", "moment": "^2.29.1",
"node-fetch": "^2.6.2", "node-fetch": "^2.6.5",
"node-ical": "^0.13.0", "node-ical": "^0.13.0",
"socket.io": "^4.2.0" "socket.io": "^4.2.0"
}, },
@ -106,14 +107,31 @@
"<rootDir>/tests/unit/mocks" "<rootDir>/tests/unit/mocks"
] ]
}, },
{
"displayName": "electron",
"testMatch": [
"**/tests/electron/**/*.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"<rootDir>/tests/electron/modules/mocks",
"<rootDir>/tests/electron/global-setup.js",
"<rootDir>/tests/electron/modules/basic-auth.js"
]
},
{ {
"displayName": "e2e", "displayName": "e2e",
"setupFilesAfterEnv": [
"<rootDir>/tests/e2e/mock-console.js"
],
"testMatch": [ "testMatch": [
"**/tests/e2e/**/*.[jt]s?(x)" "**/tests/e2e/**/*.[jt]s?(x)"
], ],
"modulePaths": [
"<rootDir>/js/"
],
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"<rootDir>/tests/e2e/modules/mocks", "<rootDir>/tests/e2e/global-setup.js",
"<rootDir>/tests/e2e/global-setup.js" "<rootDir>/tests/e2e/mock-console.js"
] ]
} }
] ]

View File

@ -6,12 +6,6 @@
exports.configFactory = function (options) { exports.configFactory = function (options) {
return Object.assign( return Object.assign(
{ {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 24,
units: "metric",
electronOptions: { electronOptions: {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,

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 = {
modules: [ modules: [
{ {
module: "alert", module: "alert",
@ -13,7 +13,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 Sergey Morozov * By Sergey Morozov
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -12,7 +12,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
position: "middle_center" position: "middle_center"
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,14 +3,14 @@
* By Sergey Morozov * By Sergey Morozov
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
modules: [ modules: [
{ {
module: "clock", module: "clock",
position: "middle_center" position: "middle_center"
} }
] ]
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -2,7 +2,7 @@
* *
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
modules: [ modules: [
{ {
module: "clock", module: "clock",
@ -13,7 +13,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: [
@ -15,7 +15,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 Sergey Morozov * By Sergey Morozov
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -15,7 +15,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 Johan Hammar * By Johan Hammar
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -15,7 +15,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 Johan Hammar * By Johan Hammar
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -15,7 +15,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 = {
language: "es", language: "es",
timeFormat: 12, timeFormat: 12,
@ -13,7 +13,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
position: "middle_center" position: "middle_center"
} }
] ]
}); };
/*************** 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 = {
language: "es", language: "es",
modules: [ modules: [
@ -12,7 +12,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
position: "middle_center" position: "middle_center"
} }
] ]
}); };
/*************** 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 = {
language: "es", language: "es",
timeFormat: 12, timeFormat: 12,
@ -16,7 +16,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 @@
* 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 = {
language: "es", language: "es",
timeFormat: 12, timeFormat: 12,
@ -17,7 +17,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

@ -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

@ -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: [
@ -17,7 +17,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: [
@ -19,7 +19,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 = {
modules: [ modules: [
{ {
module: "helloworld", module: "helloworld",
@ -21,11 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
} }
] ]
}); };
config.electronOptions.fullscreen = false;
config.electronOptions.width = 800;
config.electronOptions.height = 600;
/*************** 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 = {
modules: [ modules: [
{ {
module: "helloworld", module: "helloworld",
@ -13,7 +13,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,14 +3,14 @@
* 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 = {
modules: [ modules: [
{ {
module: "helloworld", module: "helloworld",
position: "bottom_bar" position: "bottom_bar"
} }
] ]
}); };
/*************** 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

@ -2,7 +2,7 @@
* *
* MIT Licensed. * MIT Licensed.
*/ */
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ let config = {
timeFormat: 12, timeFormat: 12,
modules: [ modules: [
@ -19,7 +19,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

@ -2,7 +2,7 @@
* *
* 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

@ -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 = {
modules: modules:
// Using exotic content. This is why don't accept go to JSON configuration file // Using exotic content. This is why don't accept go to JSON configuration file
(function () { (function () {
@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
} }
return modules; return modules;
})() })()
}); };
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -3,10 +3,9 @@
* 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 = {
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"] ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"]
}); };
delete config.modules;
/*************** DO NOT EDIT THE LINE BELOW ***************/ /*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") { if (typeof module !== "undefined") {

View File

@ -1,42 +1,13 @@
const helpers = require("./global-setup");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const helpers = require("./global-setup");
describe("Electron app environment", function () { describe("Electron app environment", function () {
helpers.setupTimeout(this); beforeAll(function (done) {
helpers.startApplication("tests/configs/default.js");
let app = null; helpers.getDocument(done);
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
}); });
afterAll(function () {
beforeEach(function () { helpers.stopApplication();
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
it("should open a browserwindow", async function () {
await app.client.waitUntilWindowLoaded();
app.browserWindow.focus();
expect(await app.client.getWindowCount()).toBe(1);
expect(await app.browserWindow.isMinimized()).toBe(false);
expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
expect(await app.browserWindow.isVisible()).toBe(true);
expect(await app.browserWindow.isFocused()).toBe(true);
const bounds = await app.browserWindow.getBounds();
expect(bounds.width).toBeGreaterThan(0);
expect(bounds.height).toBeGreaterThan(0);
expect(await app.browserWindow.getTitle()).toBe("MagicMirror²");
}); });
it("get request from http://localhost:8080 should return 200", function (done) { it("get request from http://localhost:8080 should return 200", function (done) {
@ -52,4 +23,10 @@ describe("Electron app environment", function () {
done(); done();
}); });
}); });
it("should show the title MagicMirror²", function () {
const elem = document.querySelector("title");
expect(elem).not.toBe(null);
expect(elem.textContent).toBe("MagicMirror²");
});
}); });

View File

@ -1,10 +1,7 @@
const helpers = require("./global-setup");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const helpers = require("./global-setup");
describe("All font files from roboto.css should be downloadable", function () { describe("All font files from roboto.css should be downloadable", function () {
helpers.setupTimeout(this);
let app;
const fontFiles = []; const fontFiles = [];
// Statements below filters out all 'url' lines in the CSS file // Statements below filters out all 'url' lines in the CSS file
const fileContent = require("fs").readFileSync(__dirname + "/../../fonts/roboto.css", "utf8"); const fileContent = require("fs").readFileSync(__dirname + "/../../fonts/roboto.css", "utf8");
@ -18,20 +15,10 @@ describe("All font files from roboto.css should be downloadable", function () {
} }
beforeAll(function () { beforeAll(function () {
// Set config sample for use in test helpers.startApplication("tests/configs/without_modules.js");
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
}); });
afterAll(function () { afterAll(function () {
return helpers.stopApplication(app); helpers.stopApplication();
}); });
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => { test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {

View File

@ -1,53 +1,32 @@
/* const jsdom = require("jsdom");
* Magic Mirror Global Setup Test Suite
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
const Application = require("spectron").Application;
const assert = require("assert");
const path = require("path");
const EventEmitter = require("events");
exports.getElectronPath = function () { exports.startApplication = function (configFilename, exec) {
let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron"); jest.resetModules();
if (process.platform === "win32") { if (global.app) {
electronPath += ".cmd"; global.app.stop();
} }
return electronPath; // Set config sample for use in test
process.env.MM_CONFIG_FILE = configFilename;
if (exec) exec;
global.app = require("app.js");
global.app.start();
}; };
// Set timeout - if this is run as CI Job, increase timeout exports.stopApplication = function () {
exports.setupTimeout = function (test) { if (global.app) {
if (process.env.CI) { global.app.stop();
jest.setTimeout(30000);
} else {
jest.setTimeout(10000);
} }
}; };
exports.startApplication = function (options) { exports.getDocument = function (callback, ms) {
const emitter = new EventEmitter(); const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080");
emitter.setMaxListeners(100); jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
dom.window.name = "jsdom";
options.path = exports.getElectronPath(); dom.window.onload = function () {
if (process.env.CI) { global.document = dom.window.document;
options.startTimeout = 30000; setTimeout(() => {
} callback();
}, ms);
const app = new Application(options); };
return app.start().then(function () {
assert.strictEqual(app.isRunning(), true);
return app;
});
};
exports.stopApplication = function (app) {
if (!app || !app.isRunning()) {
return;
}
return app.stop().then(function () {
assert.strictEqual(app.isRunning(), false);
}); });
}; };

View File

@ -1,29 +1,13 @@
const helpers = require("./global-setup");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const helpers = require("./global-setup");
describe("ipWhitelist directive configuration", function () { describe("ipWhitelist directive configuration", 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("Set ipWhitelist without access", function () { describe("Set ipWhitelist without access", function () {
beforeAll(function () { beforeAll(function () {
// Set config sample for use in test helpers.startApplication("tests/configs/noIpWhiteList.js");
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js"; });
afterAll(function () {
helpers.stopApplication();
}); });
it("should return 403", function (done) { it("should return 403", function (done) {
@ -36,8 +20,10 @@ describe("ipWhitelist directive configuration", function () {
describe("Set ipWhitelist []", function () { describe("Set ipWhitelist []", function () {
beforeAll(function () { beforeAll(function () {
// Set config sample for use in test helpers.startApplication("tests/configs/empty_ipWhiteList.js");
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js"; });
afterAll(function () {
helpers.stopApplication();
}); });
it("should return 200", function (done) { it("should return 200", function (done) {

21
tests/e2e/mock-console.js Normal file
View File

@ -0,0 +1,21 @@
/**
* Suppresses errors concerning web server already shut down.
*
* @param {string} err The error message.
*/
function mockError(err) {
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) {
jest.fn();
} else {
console.dir(err);
}
}
global.console = {
log: jest.fn(),
dir: console.dir,
error: mockError,
warn: console.warn,
info: jest.fn(),
debug: console.debug
};

View File

@ -1,32 +1,17 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
describe("Alert module", function () { describe("Alert module", function () {
helpers.setupTimeout(this); beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/alert/default.js");
let app = null; helpers.getDocument(done, 1000);
});
beforeEach(function () { afterAll(function () {
return helpers helpers.stopApplication();
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
}); });
afterEach(function () { it("should show the welcome message", function () {
return helpers.stopApplication(app); const elem = document.querySelector(".ns-box .ns-box-inner .light.bright.small");
}); expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Welcome, start was successful!");
describe("Default configuration", function () {
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/alert/default.js";
});
it("should show the welcome message", function () {
return app.client.waitUntilTextExists(".ns-box .ns-box-inner .light.bright.small", "Welcome, start was successful!", 10000);
});
}); });
}); });

View File

@ -1,86 +1,71 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
describe("Clock set to spanish language module", function () { describe("Clock set to spanish language module", function () {
helpers.setupTimeout(this); afterAll(function () {
helpers.stopApplication();
});
let app = null; const testMatch = function (element, regex) {
const elem = document.querySelector(element);
const testMatch = async function (element, regex) { expect(elem).not.toBe(null);
await app.client.waitUntilWindowLoaded(); expect(elem.textContent).toMatch(regex);
const elem = await app.client.$(element);
const txt = await elem.getText(element);
return expect(txt).toMatch(regex);
}; };
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function () { describe("with default 24hr clock config", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js"; helpers.getDocument(done, 1000);
}); });
it("shows date with correct format", async function () { it("shows date with correct format", function () {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/; const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
return testMatch(".clock .date", dateRegex); testMatch(".clock .date", dateRegex);
}); });
it("shows time in 24hr format", async function () { it("shows time in 24hr format", function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with default 12hr clock config", function () { describe("with default 12hr clock config", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js"; helpers.getDocument(done, 1000);
}); });
it("shows date with correct format", async function () { it("shows date with correct format", function () {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/; const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
return testMatch(".clock .date", dateRegex); testMatch(".clock .date", dateRegex);
}); });
it("shows time in 12hr format", async function () { it("shows time in 12hr format", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with showPeriodUpper config enabled", function () { describe("with showPeriodUpper config enabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showPeriodUpper.js"; helpers.getDocument(done, 1000);
}); });
it("shows 12hr time with upper case AM/PM", async function () { it("shows 12hr time with upper case AM/PM", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/; const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with showWeek config enabled", function () { describe("with showWeek config enabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showWeek.js"; helpers.getDocument(done, 1000);
}); });
it("shows week with correct format", async function () { it("shows week with correct format", function () {
const weekRegex = /^Semana [0-9]{1,2}$/; const weekRegex = /^Semana [0-9]{1,2}$/;
return testMatch(".clock .week", weekRegex); testMatch(".clock .week", weekRegex);
}); });
}); });
}); });

View File

@ -2,133 +2,115 @@ const helpers = require("../global-setup");
const moment = require("moment"); const moment = require("moment");
describe("Clock module", function () { describe("Clock module", function () {
helpers.setupTimeout(this); afterAll(function () {
helpers.stopApplication();
});
let app = null; const testMatch = function (element, regex) {
const elem = document.querySelector(element);
const testMatch = async function (element, regex) { expect(elem).not.toBe(null);
await app.client.waitUntilWindowLoaded(); expect(elem.textContent).toMatch(regex);
const elem = await app.client.$(element);
const txt = await elem.getText(element);
return expect(txt).toMatch(regex);
}; };
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
describe("with default 24hr clock config", function () { describe("with default 24hr clock config", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js"; helpers.getDocument(done, 1000);
}); });
it("should show the date in the correct format", async function () { it("should show the date in the correct format", function () {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/; const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
return testMatch(".clock .date", dateRegex); testMatch(".clock .date", dateRegex);
}); });
it("should show the time in 24hr format", async function () { it("should show the time in 24hr format", function () {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with default 12hr clock config", function () { describe("with default 12hr clock config", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js"; helpers.getDocument(done, 1000);
}); });
it("should show the date in the correct format", async function () { it("should show the date in the correct format", function () {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/; const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
return testMatch(".clock .date", dateRegex); testMatch(".clock .date", dateRegex);
}); });
it("should show the time in 12hr format", async function () { it("should show the time in 12hr format", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with showPeriodUpper config enabled", function () { describe("with showPeriodUpper config enabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js"; helpers.getDocument(done, 1000);
}); });
it("should show 12hr time with upper case AM/PM", async function () { it("should show 12hr time with upper case AM/PM", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/; const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with displaySeconds config disabled", function () { describe("with displaySeconds config disabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js"; helpers.getDocument(done, 1000);
}); });
it("should show 12hr time without seconds am/pm", async function () { it("should show 12hr time without seconds am/pm", function () {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/; const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
return testMatch(".clock .time", timeRegex); testMatch(".clock .time", timeRegex);
}); });
}); });
describe("with showTime config disabled", function () { describe("with showTime config disabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showTime.js"; helpers.getDocument(done, 1000);
}); });
it("should show not show the time when digital clock is shown", async function () { it("should show not show the time when digital clock is shown", function () {
await app.client.waitUntilWindowLoaded(); const elem = document.querySelector(".clock .digital .time");
const time = await app.client.$$(".clock .digital .time"); expect(elem).toBe(null);
return expect(time.length).toBe(0);
}); });
}); });
describe("with showWeek config enabled", function () { describe("with showWeek config enabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js"; helpers.getDocument(done, 1000);
}); });
it("should show the week in the correct format", async function () { it("should show the week in the correct format", function () {
const weekRegex = /^Week [0-9]{1,2}$/; const weekRegex = /^Week [0-9]{1,2}$/;
return testMatch(".clock .week", weekRegex); testMatch(".clock .week", weekRegex);
}); });
it("should show the week with the correct number of week of year", async function () { it("should show the week with the correct number of week of year", function () {
const currentWeekNumber = moment().week(); const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber; const weekToShow = "Week " + currentWeekNumber;
await app.client.waitUntilWindowLoaded(); const elem = document.querySelector(".clock .week");
const elem = await app.client.$(".clock .week"); expect(elem).not.toBe(null);
const txt = await elem.getText(".clock .week"); expect(elem.textContent).toBe(weekToShow);
return expect(txt).toBe(weekToShow);
}); });
}); });
describe("with analog clock face enabled", function () { describe("with analog clock face enabled", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_analog.js"; helpers.getDocument(done, 1000);
}); });
it("should show the analog clock face", async () => { it("should show the analog clock face", () => {
await app.client.waitUntilWindowLoaded(); const elem = document.querySelector(".clockCircle");
const clock = await app.client.$$(".clockCircle"); expect(elem).not.toBe(null);
return expect(clock.length).toBe(1);
}); });
}); });
}); });

View File

@ -1,106 +1,87 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
/**
* move similar tests in function doTest
*
* @param {Array} complimentsArray The array of compliments.
*/
function doTest(complimentsArray) {
let elem = document.querySelector(".compliments");
expect(elem).not.toBe(null);
elem = document.querySelector(".module-content");
expect(elem).not.toBe(null);
expect(complimentsArray).toContain(elem.textContent);
}
describe("Compliments module", function () { describe("Compliments module", function () {
helpers.setupTimeout(this); afterAll(function () {
helpers.stopApplication();
let app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
}); });
describe("parts of days", function () { describe("parts of days", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js"; helpers.getDocument(done, 1000);
}); });
it("if Morning compliments for that part of day", async function () { it("if Morning compliments for that part of day", function () {
const hour = new Date().getHours(); const hour = new Date().getHours();
if (hour >= 3 && hour < 12) { if (hour >= 3 && hour < 12) {
// if morning check // if morning check
const elem = await app.client.$(".compliments"); doTest(["Hi", "Good Morning", "Morning test"]);
return elem.getText(".compliments").then(function (text) {
expect(["Hi", "Good Morning", "Morning test"]).toContain(text);
});
} }
}); });
it("if Afternoon show Compliments for that part of day", async function () { it("if Afternoon show Compliments for that part of day", function () {
const hour = new Date().getHours(); const hour = new Date().getHours();
if (hour >= 12 && hour < 17) { if (hour >= 12 && hour < 17) {
// if afternoon check // if afternoon check
const elem = await app.client.$(".compliments"); doTest(["Hello", "Good Afternoon", "Afternoon test"]);
return elem.getText(".compliments").then(function (text) {
expect(["Hello", "Good Afternoon", "Afternoon test"]).toContain(text);
});
} }
}); });
it("if Evening show Compliments for that part of day", async function () { it("if Evening show Compliments for that part of day", function () {
const hour = new Date().getHours(); const hour = new Date().getHours();
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) { if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
// if evening check // if evening check
const elem = await app.client.$(".compliments"); doTest(["Hello There", "Good Evening", "Evening test"]);
return elem.getText(".compliments").then(function (text) {
expect(["Hello There", "Good Evening", "Evening test"]).toContain(text);
});
} }
}); });
}); });
describe("Feature anytime in compliments module", function () { describe("Feature anytime in compliments module", function () {
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () { describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js"; helpers.getDocument(done, 1000);
}); });
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () { it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function () {
const elem = await app.client.$(".compliments"); doTest(["Anytime here"]);
return elem.getText(".compliments").then(function (text) {
expect(["Anytime here"]).toContain(text);
});
}); });
}); });
describe("Only anytime present in configuration compliments", function () { describe("Only anytime present in configuration compliments", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js"; helpers.getDocument(done, 1000);
}); });
it("Show anytime compliments", async function () { it("Show anytime compliments", function () {
const elem = await app.client.$(".compliments"); doTest(["Anytime here"]);
return elem.getText(".compliments").then(function (text) {
expect(["Anytime here"]).toContain(text);
});
}); });
}); });
}); });
describe("Feature date in compliments module", function () { describe("Feature date in compliments module", function () {
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () { describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js"; helpers.getDocument(done, 1000);
}); });
it("Show happy new year compliment on new years day", async function () { it("Show happy new year compliment on new years day", function () {
const elem = await app.client.$(".compliments"); doTest(["Happy new year!"]);
return elem.getText(".compliments").then(function (text) {
expect(["Happy new year!"]).toContain(text);
});
}); });
}); });
}); });

View File

@ -1,45 +1,33 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
describe("Test helloworld module", function () { describe("Test helloworld module", function () {
helpers.setupTimeout(this); afterAll(function () {
helpers.stopApplication();
let app = null;
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
}); });
describe("helloworld set config text", function () { describe("helloworld set config text", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/helloworld/helloworld.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js"; helpers.getDocument(done, 1000);
}); });
it("Test message helloworld module", async function () { it("Test message helloworld module", function () {
const elem = await app.client.$(".helloworld"); const elem = document.querySelector(".helloworld");
return expect(await elem.getText(".helloworld")).toBe("Test HelloWorld Module"); expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Test HelloWorld Module");
}); });
}); });
describe("helloworld default config text", function () { describe("helloworld default config text", function () {
beforeAll(function () { beforeAll(function (done) {
// Set config sample for use in test helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js");
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld_default.js"; helpers.getDocument(done, 1000);
}); });
it("Test message helloworld module", async function () { it("Test message helloworld module", function () {
const elem = await app.client.$(".helloworld"); const elem = document.querySelector(".helloworld");
return expect(await elem.getText(".helloworld")).toBe("Hello World!"); expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Hello World!");
}); });
}); });
}); });

View File

@ -1,67 +1,63 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
describe("Newsfeed module", function () { describe("Newsfeed module", function () {
helpers.setupTimeout(this); afterAll(function () {
helpers.stopApplication();
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 () { describe("Default configuration", function () {
beforeAll(function () { beforeAll(function (done) {
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js"; helpers.startApplication("tests/configs/modules/newsfeed/default.js");
helpers.getDocument(done, 3000);
}); });
it("should show the newsfeed title", function () { it("should show the newsfeed title", function () {
return app.client.waitUntilTextExists(".newsfeed .newsfeed-source", "Rodrigo Ramirez Blog", 10000); const elem = document.querySelector(".newsfeed .newsfeed-source");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
}); });
it("should show the newsfeed article", function () { it("should show the newsfeed article", function () {
return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); const elem = document.querySelector(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("QPanel");
}); });
it("should NOT show the newsfeed description", async () => { it("should NOT show the newsfeed description", () => {
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); const elem = document.querySelector(".newsfeed .newsfeed-desc");
const events = await app.client.$$(".newsfeed .newsfeed-desc"); expect(elem).toBe(null);
return expect(events.length).toBe(0);
}); });
}); });
describe("Custom configuration", function () { describe("Custom configuration", function () {
beforeAll(function () { beforeAll(function (done) {
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/prohibited_words.js"; helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
helpers.getDocument(done, 3000);
}); });
it("should not show articles with prohibited words", function () { it("should not show articles with prohibited words", function () {
return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); const elem = document.querySelector(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Problema VirtualBox");
}); });
it("should show the newsfeed description", async () => { it("should show the newsfeed description", () => {
await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); const elem = document.querySelector(".newsfeed .newsfeed-desc");
const events = await app.client.$$(".newsfeed .newsfeed-desc"); expect(elem).not.toBe(null);
return expect(events.length).toBe(1); expect(elem.textContent.length).not.toBe(0);
}); });
}); });
describe("Invalid configuration", function () { describe("Invalid configuration", function () {
beforeAll(function () { beforeAll(function (done) {
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/incorrect_url.js"; helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
helpers.getDocument(done, 3000);
}); });
it("should show malformed url warning", function () { it("should show malformed url warning", function () {
return app.client.waitUntilTextExists(".newsfeed .small", "Error in the Newsfeed module. Malformed url.", 10000); const elem = document.querySelector(".newsfeed .small");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
}); });
}); });
}); });

View File

@ -1,38 +1,24 @@
const helpers = require("./global-setup"); const helpers = require("./global-setup");
describe("Display of modules", function () { describe("Display of modules", function () {
helpers.setupTimeout(this); beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/display.js");
let app = null; helpers.getDocument(done);
});
beforeEach(function () { afterAll(function () {
return helpers helpers.stopApplication();
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
}); });
afterEach(function () { it("should show the test header", function () {
return helpers.stopApplication(app); const elem = document.querySelector("#module_0_helloworld .module-header");
expect(elem).not.toBe(null);
// textContent gibt hier lowercase zurück, das uppercase wird durch css realisiert, was daher nicht in textContent landet
expect(elem.textContent).toBe("test_header");
}); });
describe("Using helloworld", function () { it("should show no header if no header text is specified", function () {
beforeAll(function () { const elem = document.querySelector("#module_1_helloworld .module-header");
// Set config sample for use in test expect(elem).not.toBe(null);
process.env.MM_CONFIG_FILE = "tests/configs/modules/display.js"; expect(elem.textContent).toBe("undefined");
});
it("should show the test header", async () => {
const elem = await app.client.$("#module_0_helloworld .module-header", 10000);
return expect(await elem.getText("#module_0_helloworld .module-header")).toBe("TEST_HEADER");
});
it("should show no header if no header text is specified", async () => {
const elem = await app.client.$("#module_1_helloworld .module-header", 10000);
return expect(await elem.getText("#module_1_helloworld .module-header")).toBe("");
});
}); });
}); });

View File

@ -1,38 +1,22 @@
const helpers = require("./global-setup"); const helpers = require("./global-setup");
describe("Position of modules", function () { describe("Position of modules", function () {
helpers.setupTimeout(this); beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/positions.js");
let app = null; helpers.getDocument(done, 1000);
describe("Using helloworld", function () {
afterAll(function () {
return helpers.stopApplication(app);
});
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
for (const position of positions) {
const className = position.replace("_", ".");
it("should show text in " + position, function () {
return app.client.$("." + className).then((result) => {
return result.getText("." + className).then((text) => {
return expect(text).toContain("Text in " + position);
});
});
});
}
}); });
afterAll(function () {
helpers.stopApplication();
});
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
for (const position of positions) {
const className = position.replace("_", ".");
it("should show text in " + position, function () {
const elem = document.querySelector("." + className);
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Text in " + position);
});
}
}); });

View File

@ -1,29 +1,13 @@
const helpers = require("./global-setup");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const helpers = require("./global-setup");
describe("port directive configuration", function () { describe("port directive configuration", 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("Set port 8090", function () { describe("Set port 8090", function () {
beforeAll(function () { beforeAll(function () {
// Set config sample for use in this test helpers.startApplication("tests/configs/port_8090.js");
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js"; });
afterAll(function () {
helpers.stopApplication();
}); });
it("should return 200", function (done) { it("should return 200", function (done) {
@ -36,13 +20,10 @@ describe("port directive configuration", function () {
describe("Set port 8100 on environment variable MM_PORT", function () { describe("Set port 8100 on environment variable MM_PORT", function () {
beforeAll(function () { beforeAll(function () {
process.env.MM_PORT = 8100; helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100));
// Set config sample for use in this test
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
}); });
afterAll(function () { afterAll(function () {
delete process.env.MM_PORT; helpers.stopApplication();
}); });
it("should return 200", function (done) { it("should return 200", function (done) {

View File

@ -1,24 +1,12 @@
const helpers = require("./global-setup");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const helpers = require("./global-setup");
describe("Vendors", function () { describe("Vendors", function () {
helpers.setupTimeout(this);
let app = null;
beforeAll(function () { beforeAll(function () {
process.env.MM_CONFIG_FILE = "tests/configs/env.js"; helpers.startApplication("tests/configs/default.js");
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
}); });
afterAll(function () { afterAll(function () {
return helpers.stopApplication(app); helpers.stopApplication();
}); });
describe("Get list vendors", function () { describe("Get list vendors", function () {

View File

@ -1,36 +1,23 @@
const helpers = require("./global-setup"); const helpers = require("./global-setup");
describe("Check configuration without modules", function () { describe("Check configuration without modules", function () {
helpers.setupTimeout(this); beforeAll(function (done) {
helpers.startApplication("tests/configs/without_modules.js");
let app = null; helpers.getDocument(done, 1000);
});
beforeEach(function () { afterAll(function () {
return helpers helpers.stopApplication();
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
}); });
afterEach(function () { it("Show the message MagicMirror title", function () {
return helpers.stopApplication(app); const elem = document.querySelector("#module_1_helloworld .module-content");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Magic Mirror2");
}); });
beforeAll(function () { it("Show the text Michael's website", function () {
// Set config sample for use in test const elem = document.querySelector("#module_5_helloworld .module-content");
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js"; expect(elem).not.toBe(null);
}); expect(elem.textContent).toContain("www.michaelteeuw.nl");
it("Show the message MagicMirror title", async function () {
const elem = await app.client.$("#module_1_helloworld .module-content");
return expect(await elem.getText("#module_1_helloworld .module-content")).toBe("Magic Mirror2");
});
it("Show the text Michael's website", async function () {
const elem = await app.client.$("#module_5_helloworld .module-content");
return expect(await elem.getText("#module_5_helloworld .module-content")).toBe("www.michaelteeuw.nl");
}); });
}); });

View File

@ -0,0 +1,40 @@
const helpers = require("./global-setup");
describe("Electron app environment", function () {
helpers.setupTimeout(this);
let app = null;
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
});
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
});
afterEach(function () {
return helpers.stopApplication(app);
});
it("should open a browserwindow", async function () {
await app.client.waitUntilWindowLoaded();
app.browserWindow.focus();
expect(await app.client.getWindowCount()).toBe(1);
expect(await app.browserWindow.isMinimized()).toBe(false);
expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
expect(await app.browserWindow.isVisible()).toBe(true);
expect(await app.browserWindow.isFocused()).toBe(true);
const bounds = await app.browserWindow.getBounds();
expect(bounds.width).toBeGreaterThan(0);
expect(bounds.height).toBeGreaterThan(0);
expect(await app.browserWindow.getTitle()).toBe("MagicMirror²");
});
});

View File

@ -0,0 +1,53 @@
/*
* Magic Mirror Global Setup Test Suite
*
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
* MIT Licensed.
*/
const Application = require("spectron").Application;
const assert = require("assert");
const path = require("path");
const EventEmitter = require("events");
exports.getElectronPath = function () {
let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron");
if (process.platform === "win32") {
electronPath += ".cmd";
}
return electronPath;
};
// Set timeout - if this is run as CI Job, increase timeout
exports.setupTimeout = function (test) {
if (process.env.CI) {
jest.setTimeout(30000);
} else {
jest.setTimeout(10000);
}
};
exports.startApplication = function (options) {
const emitter = new EventEmitter();
emitter.setMaxListeners(100);
options.path = exports.getElectronPath();
if (process.env.CI) {
options.startTimeout = 30000;
}
const app = new Application(options);
return app.start().then(function () {
assert.strictEqual(app.isRunning(), true);
return app;
});
};
exports.stopApplication = function (app) {
if (!app || !app.isRunning()) {
return;
}
return app.stop().then(function () {
assert.strictEqual(app.isRunning(), false);
});
};

View File

@ -12,7 +12,7 @@ app.use(basicAuth);
// Set available directories // Set available directories
const directories = ["/tests/configs"]; const directories = ["/tests/configs"];
const rootPath = path.resolve(__dirname + "/../../"); const rootPath = path.resolve(__dirname + "/../../../");
for (let directory of directories) { for (let directory of directories) {
app.use(directory, express.static(path.resolve(rootPath + directory))); app.use(directory, express.static(path.resolve(rootPath + directory)));

View File

@ -1,5 +1,5 @@
const helpers = require("../global-setup"); const helpers = require("../global-setup");
const serverBasicAuth = require("../../servers/basic-auth.js"); const serverBasicAuth = require("./basic-auth.js");
describe("Calendar module", function () { describe("Calendar module", function () {
helpers.setupTimeout(this); helpers.setupTimeout(this);

304
vendor/package-lock.json generated vendored
View File

@ -1,154 +1,154 @@
{ {
"name": "magicmirror-vendors", "name": "magicmirror-vendors",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "magicmirror-vendors", "name": "magicmirror-vendors",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4", "@fortawesome/fontawesome-free": "^5.15.4",
"moment": "^2.29.1", "moment": "^2.29.1",
"moment-timezone": "^0.5.33", "moment-timezone": "^0.5.33",
"nunjucks": "^3.2.3", "nunjucks": "^3.2.3",
"suncalc": "^1.8.0", "suncalc": "^1.8.0",
"weathericons": "^2.1.0" "weathericons": "^2.1.0"
} }
}, },
"node_modules/@fortawesome/fontawesome-free": { "node_modules/@fortawesome/fontawesome-free": {
"version": "5.15.4", "version": "5.15.4",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz",
"integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==", "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==",
"hasInstallScript": true, "hasInstallScript": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/a-sync-waterfall": { "node_modules/a-sync-waterfall": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz", "resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz",
"integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==" "integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA=="
}, },
"node_modules/asap": { "node_modules/asap": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
}, },
"node_modules/commander": { "node_modules/commander": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
"engines": { "engines": {
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/moment": { "node_modules/moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": { "engines": {
"node": "*" "node": "*"
} }
}, },
"node_modules/moment-timezone": { "node_modules/moment-timezone": {
"version": "0.5.33", "version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz", "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==", "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"dependencies": { "dependencies": {
"moment": ">= 2.9.0" "moment": ">= 2.9.0"
}, },
"engines": { "engines": {
"node": "*" "node": "*"
} }
}, },
"node_modules/nunjucks": { "node_modules/nunjucks": {
"version": "3.2.3", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz", "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz",
"integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==", "integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==",
"dependencies": { "dependencies": {
"a-sync-waterfall": "^1.0.0", "a-sync-waterfall": "^1.0.0",
"asap": "^2.0.3", "asap": "^2.0.3",
"commander": "^5.1.0" "commander": "^5.1.0"
}, },
"bin": { "bin": {
"nunjucks-precompile": "bin/precompile" "nunjucks-precompile": "bin/precompile"
}, },
"engines": { "engines": {
"node": ">= 6.9.0" "node": ">= 6.9.0"
}, },
"peerDependencies": { "peerDependencies": {
"chokidar": "^3.3.0" "chokidar": "^3.3.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"chokidar": { "chokidar": {
"optional": true "optional": true
} }
} }
}, },
"node_modules/suncalc": { "node_modules/suncalc": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz", "resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz",
"integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U=" "integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U="
}, },
"node_modules/weathericons": { "node_modules/weathericons": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz", "resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz",
"integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q=" "integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q="
} }
}, },
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-free": { "@fortawesome/fontawesome-free": {
"version": "5.15.4", "version": "5.15.4",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz",
"integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==" "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg=="
}, },
"a-sync-waterfall": { "a-sync-waterfall": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz", "resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz",
"integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==" "integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA=="
}, },
"asap": { "asap": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
}, },
"commander": { "commander": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg=="
}, },
"moment": { "moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
}, },
"moment-timezone": { "moment-timezone": {
"version": "0.5.33", "version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz", "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==", "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"requires": { "requires": {
"moment": ">= 2.9.0" "moment": ">= 2.9.0"
} }
}, },
"nunjucks": { "nunjucks": {
"version": "3.2.3", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz", "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.2.3.tgz",
"integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==", "integrity": "sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==",
"requires": { "requires": {
"a-sync-waterfall": "^1.0.0", "a-sync-waterfall": "^1.0.0",
"asap": "^2.0.3", "asap": "^2.0.3",
"commander": "^5.1.0" "commander": "^5.1.0"
} }
}, },
"suncalc": { "suncalc": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz", "resolved": "https://registry.npmjs.org/suncalc/-/suncalc-1.8.0.tgz",
"integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U=" "integrity": "sha1-HZiYEJVjB4dQ9JlKlZ5lTYdqy/U="
}, },
"weathericons": { "weathericons": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz", "resolved": "https://registry.npmjs.org/weathericons/-/weathericons-2.1.0.tgz",
"integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q=" "integrity": "sha1-dFOho14gAkXjiftQd9Un7/MLc7Q="
} }
} }
} }