From b4350278a073c364bb6f1af2f35a06e2c740e4dd Mon Sep 17 00:00:00 2001 From: karsten13 Date: Tue, 21 Sep 2021 23:48:29 +0200 Subject: [PATCH 01/20] first tests --- js/logger.js | 4 ++-- package.json | 3 +++ tests/configs/modules/display.js | 14 ++++++------ tests/e2e/mock-console.js | 9 ++++++++ tests/e2e/modules.js | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/e2e/mock-console.js create mode 100644 tests/e2e/modules.js diff --git a/js/logger.js b/js/logger.js index d469e702..16e310e8 100644 --- a/js/logger.js +++ b/js/logger.js @@ -35,8 +35,8 @@ 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) + timeEnd: Function.prototype.bind.call(console.timeEnd, console) + // timeStamp: Function.prototype.bind.call(console.timeStamp, console) }; logLevel.setLogLevel = function (newLevel) { diff --git a/package.json b/package.json index 5d15a245..601fe53b 100644 --- a/package.json +++ b/package.json @@ -120,6 +120,9 @@ }, { "displayName": "e2e", + "setupFilesAfterEnv": [ + "/tests/e2e/mock-console.js" + ], "testMatch": [ "**/tests/e2e/**/*.[jt]s?(x)" ], diff --git a/tests/configs/modules/display.js b/tests/configs/modules/display.js index 070dc9e5..b9facce3 100644 --- a/tests/configs/modules/display.js +++ b/tests/configs/modules/display.js @@ -3,7 +3,13 @@ * By Rejas * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "helloworld", @@ -21,11 +27,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 ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js new file mode 100644 index 00000000..2d6751cd --- /dev/null +++ b/tests/e2e/mock-console.js @@ -0,0 +1,9 @@ +global.console = { + log: console.log, + dir: console.dir, + // error: jest.fn(), + error: console.error, + warn: console.warn, + info: console.info, + debug: console.debug +}; diff --git a/tests/e2e/modules.js b/tests/e2e/modules.js new file mode 100644 index 00000000..e4856a52 --- /dev/null +++ b/tests/e2e/modules.js @@ -0,0 +1,37 @@ +const jsdom = require("jsdom"); +const fetch = require("node-fetch"); +const helpers = require("./global-setup"); +let app = null; + +describe("test headers", function () { + beforeAll(function () { + // todo: require is not defined ... + // jest.mock("logger"); + app = helpers.startApplication("tests/configs/modules/display.js"); + // app = helpers.startApplication("config/config.js"); + }); + afterAll(function () { + helpers.stopApplication(app); + }); + + it("test", function (done) { + jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => { + // console.log(dom.serialize()); + dom.window.onload = function () { + const doc = dom.window.document; + console.log(doc.querySelector("title").textContent); + const children = doc.body.getElementsByTagName("*"); + for (var i = 0, length = children.length; i < length; i++) { + child = children[i]; + if (child.id !== "") console.dir(child.id); + } + console.log(doc.querySelector("#module_0_helloworld .module-header").textContent); + // result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom + // const elem = doc.getElementById("module_0_helloworld"); + // console.dir(elem); + done(); + }; + }); + // done(); + }); +}); From 60f8de282db9726f02105f0f3a99ec7a9592359b Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Thu, 23 Sep 2021 00:05:30 +0200 Subject: [PATCH 02/20] snapshot --- tests/e2e/mock-console.js | 21 +++++++----- tests/e2e/modules.js | 70 ++++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 39 deletions(-) diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js index 2d6751cd..8cc246f8 100644 --- a/tests/e2e/mock-console.js +++ b/tests/e2e/mock-console.js @@ -1,9 +1,14 @@ -global.console = { - log: console.log, - dir: console.dir, - // error: jest.fn(), - error: console.error, - warn: console.warn, - info: console.info, - debug: console.debug +function myError(err) { + //console.dir(err); + if (err.includes("ECONNREFUSED")) { jest.fn() } else { console.dir(err) }; +}; + +global.console = { + log: jest.fn(), + dir: console.dir, + error: myError, +// error: console.error, + warn: console.warn, + info: jest.fn(), + debug: console.debug }; diff --git a/tests/e2e/modules.js b/tests/e2e/modules.js index e4856a52..227fd98f 100644 --- a/tests/e2e/modules.js +++ b/tests/e2e/modules.js @@ -1,37 +1,45 @@ const jsdom = require("jsdom"); -const fetch = require("node-fetch"); +// const fetch = require("node-fetch"); const helpers = require("./global-setup"); let app = null; -describe("test headers", function () { - beforeAll(function () { - // todo: require is not defined ... - // jest.mock("logger"); - app = helpers.startApplication("tests/configs/modules/display.js"); - // app = helpers.startApplication("config/config.js"); - }); - afterAll(function () { - helpers.stopApplication(app); - }); +describe("Display of modules", function () { + beforeAll(function () { + // todo: require is not defined ... + // jest.mock("logger"); + app = helpers.startApplication("tests/configs/modules/display.js"); + // app = helpers.startApplication("config/config.js"); + }); + afterAll(function () { + helpers.stopApplication(app); + }); - it("test", function (done) { - jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => { - // console.log(dom.serialize()); - dom.window.onload = function () { - const doc = dom.window.document; - console.log(doc.querySelector("title").textContent); - const children = doc.body.getElementsByTagName("*"); - for (var i = 0, length = children.length; i < length; i++) { - child = children[i]; - if (child.id !== "") console.dir(child.id); - } - console.log(doc.querySelector("#module_0_helloworld .module-header").textContent); - // result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom - // const elem = doc.getElementById("module_0_helloworld"); - // console.dir(elem); - done(); - }; - }); - // done(); - }); + it("should show the test header", function (done) { + jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => { + // console.log(dom.serialize()); + dom.window.onload = function () { + const doc = dom.window.document; + let elem = doc.querySelector("title"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("MagicMirror²"); +/* + const children = doc.body.getElementsByTagName("*"); + for (var i = 0, length = children.length; i < length; i++) { + child = children[i]; + if (child.id !== "") console.dir(child.id); + } +*/ + elem = doc.querySelector("#module_0_helloworld .module-header"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("test_header"); + //result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom + elem = doc.querySelector("#module_1_helloworld .module-header"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("undefined"); + + //dom.window.close(); + done(); + }; + }); + }); }); From 54b04962a8e3c72d3b9ca2ef422e704a2cd04743 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Thu, 23 Sep 2021 22:52:32 +0200 Subject: [PATCH 03/20] snapshot --- .github/workflows/node-ci.js.yml | 1 + tests/e2e/global-setup.js | 11 ++++++++ tests/e2e/mock-console.js | 22 ++++++++------- tests/e2e/modules.js | 45 ------------------------------- tests/e2e/modules_display_spec.js | 25 +++++++++++++++++ 5 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 tests/e2e/modules.js create mode 100644 tests/e2e/modules_display_spec.js diff --git a/.github/workflows/node-ci.js.yml b/.github/workflows/node-ci.js.yml index 3a7391c2..258cf83d 100644 --- a/.github/workflows/node-ci.js.yml +++ b/.github/workflows/node-ci.js.yml @@ -26,6 +26,7 @@ jobs: Xvfb :99 -screen 0 1024x768x16 & export DISPLAY=:99 npm install + touch css/custom.css npm run test:prettier npm run test:js npm run test:css diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 1f9bce3b..a8b0278f 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -1,3 +1,5 @@ +const jsdom = require("jsdom"); + exports.startApplication = function (configFilename, exec) { jest.resetModules(); // Set config sample for use in test @@ -14,3 +16,12 @@ exports.stopApplication = function (app) { app.stop(); } }; + +exports.getDocument = function (url, callback) { + jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { + dom.window.onload = function () { + global.document = dom.window.document; + callback(); + }; + }); +}; diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js index 8cc246f8..a1ccfa55 100644 --- a/tests/e2e/mock-console.js +++ b/tests/e2e/mock-console.js @@ -1,14 +1,16 @@ function myError(err) { - //console.dir(err); - if (err.includes("ECONNREFUSED")) { jest.fn() } else { console.dir(err) }; -}; + if (err.includes("ECONNREFUSED")) { + jest.fn(); + } else { + console.dir(err); + } +} global.console = { - log: jest.fn(), - dir: console.dir, - error: myError, -// error: console.error, - warn: console.warn, - info: jest.fn(), - debug: console.debug + log: jest.fn(), + dir: console.dir, + error: myError, + warn: console.warn, + info: jest.fn(), + debug: console.debug }; diff --git a/tests/e2e/modules.js b/tests/e2e/modules.js deleted file mode 100644 index 227fd98f..00000000 --- a/tests/e2e/modules.js +++ /dev/null @@ -1,45 +0,0 @@ -const jsdom = require("jsdom"); -// const fetch = require("node-fetch"); -const helpers = require("./global-setup"); -let app = null; - -describe("Display of modules", function () { - beforeAll(function () { - // todo: require is not defined ... - // jest.mock("logger"); - app = helpers.startApplication("tests/configs/modules/display.js"); - // app = helpers.startApplication("config/config.js"); - }); - afterAll(function () { - helpers.stopApplication(app); - }); - - it("should show the test header", function (done) { - jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => { - // console.log(dom.serialize()); - dom.window.onload = function () { - const doc = dom.window.document; - let elem = doc.querySelector("title"); - expect(elem).not.toBe(null); - expect(elem.textContent).toBe("MagicMirror²"); -/* - const children = doc.body.getElementsByTagName("*"); - for (var i = 0, length = children.length; i < length; i++) { - child = children[i]; - if (child.id !== "") console.dir(child.id); - } -*/ - elem = doc.querySelector("#module_0_helloworld .module-header"); - expect(elem).not.toBe(null); - expect(elem.textContent).toBe("test_header"); - //result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom - elem = doc.querySelector("#module_1_helloworld .module-header"); - expect(elem).not.toBe(null); - expect(elem.textContent).toBe("undefined"); - - //dom.window.close(); - done(); - }; - }); - }); -}); diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js new file mode 100644 index 00000000..1264ad5a --- /dev/null +++ b/tests/e2e/modules_display_spec.js @@ -0,0 +1,25 @@ +const helpers = require("./global-setup"); +let app = null; + +describe("Display of modules", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/display.js"); + helpers.getDocument("http://localhost:8080", done); + }); + afterAll(function () { + helpers.stopApplication(app); + }); + + it("should show the test header", function () { + elem = document.querySelector("#module_0_helloworld .module-header"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("test_header"); + //result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom + }); + + it("should show no header if no header text is specified", function () { + elem = document.querySelector("#module_1_helloworld .module-header"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("undefined"); + }); +}); From 0ef6f89d441f65002dc592a6c9a97faeb3b9d743 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Fri, 24 Sep 2021 00:30:00 +0200 Subject: [PATCH 04/20] fix server.close() issue --- js/server.js | 11 +++++++++++ tests/e2e/modules_display_spec.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/server.js b/js/server.js index 35071091..92607d39 100644 --- a/js/server.js +++ b/js/server.js @@ -23,6 +23,7 @@ const Utils = require("./utils.js"); */ function Server(config, callback) { const port = process.env.MM_PORT || config.port; + const serverSockets = new Set(); let server = null; if (config.useHttps) { @@ -42,6 +43,13 @@ function Server(config, callback) { allowEIO3: true }); + server.on("connection", (socket) => { + serverSockets.add(socket); + socket.on("close", () => { + serverSockets.delete(socket); + }); + }); + Log.log(`Starting server on port ${port} ... `); server.listen(port, config.address || "localhost"); @@ -94,6 +102,9 @@ function Server(config, callback) { } this.close = function () { + for (const socket of serverSockets.values()) { + socket.destroy(); + } server.close(); }; } diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js index 1264ad5a..865748cd 100644 --- a/tests/e2e/modules_display_spec.js +++ b/tests/e2e/modules_display_spec.js @@ -13,8 +13,8 @@ describe("Display of modules", function () { it("should show the test header", function () { 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"); - //result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom }); it("should show no header if no header text is specified", function () { From a1c7f2099021fd3c587cff35dadeea23dc727a7e Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Fri, 24 Sep 2021 21:30:51 +0200 Subject: [PATCH 05/20] fix logger.js, move jsdom in startApplication --- js/logger.js | 15 ++++++++++++--- package.json | 3 ++- tests/e2e/global-setup.js | 22 ++++++++++++---------- tests/e2e/modules_display_spec.js | 3 +-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/js/logger.js b/js/logger.js index 16e310e8..7434ccd2 100644 --- a/js/logger.js +++ b/js/logger.js @@ -24,7 +24,16 @@ } })(this, function (config) { let logLevel; - if ((typeof exports === "object" && process.env.JEST_WORKER_ID === undefined) || typeof exports !== "object") { + let enableLog; + if (typeof exports === "object") { + // in nodejs and not running with jest + enableLog = (process.env.JEST_WORKER_ID === undefined); + } else { + // in browser and not running with jsdom + enableLog = (typeof window === 'object' && window.name === 'nodejs'); + }; + + if (enableLog) { logLevel = { debug: Function.prototype.bind.call(console.debug, console), log: Function.prototype.bind.call(console.log, console), @@ -35,8 +44,8 @@ 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) + timeEnd: Function.prototype.bind.call(console.timeEnd, console), + timeStamp: Function.prototype.bind.call(console.timeStamp, console) }; logLevel.setLogLevel = function (newLevel) { diff --git a/package.json b/package.json index 601fe53b..01d7ee42 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,8 @@ "/js/" ], "testPathIgnorePatterns": [ - "/tests/e2e/global-setup.js" + "/tests/e2e/global-setup.js", + "/tests/e2e/mock-console.js" ] } ] diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index a8b0278f..415e946d 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -1,6 +1,7 @@ const jsdom = require("jsdom"); +const config = require("../configs/empty_ipWhiteList"); -exports.startApplication = function (configFilename, exec) { +exports.startApplication = function (configFilename, exec, callback) { jest.resetModules(); // Set config sample for use in test process.env.MM_CONFIG_FILE = configFilename; @@ -8,6 +9,16 @@ exports.startApplication = function (configFilename, exec) { const app = require("app.js"); app.start(); + if (callback) { + const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080"); + jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { + dom.window.onload = function () { + global.document = dom.window.document; + callback(); + }; + }); + }; + return app; }; @@ -16,12 +27,3 @@ exports.stopApplication = function (app) { app.stop(); } }; - -exports.getDocument = function (url, callback) { - jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { - dom.window.onload = function () { - global.document = dom.window.document; - callback(); - }; - }); -}; diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js index 865748cd..5e07ae19 100644 --- a/tests/e2e/modules_display_spec.js +++ b/tests/e2e/modules_display_spec.js @@ -3,8 +3,7 @@ let app = null; describe("Display of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/display.js"); - helpers.getDocument("http://localhost:8080", done); + app = helpers.startApplication("tests/configs/modules/display.js", null, done); }); afterAll(function () { helpers.stopApplication(app); From c0ce52abe3de3686d448dbace9f0a73fae96cacc Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Fri, 24 Sep 2021 23:39:12 +0200 Subject: [PATCH 06/20] change getDocument, delay needed, now 2 tests moved --- js/logger.js | 6 ++-- tests/configs/modules/positions.js | 10 +++++-- tests/e2e/global-setup.js | 24 +++++++++------- tests/e2e/mock-console.js | 7 ++++- tests/e2e/modules_display_spec.js | 7 +++-- tests/e2e/modules_position_spec.js | 23 +++++++++++++++ tests/electron/modules_display_spec.js | 38 ------------------------- tests/electron/modules_position_spec.js | 38 ------------------------- 8 files changed, 57 insertions(+), 96 deletions(-) create mode 100644 tests/e2e/modules_position_spec.js delete mode 100644 tests/electron/modules_display_spec.js delete mode 100644 tests/electron/modules_position_spec.js diff --git a/js/logger.js b/js/logger.js index 7434ccd2..a42db925 100644 --- a/js/logger.js +++ b/js/logger.js @@ -27,11 +27,11 @@ let enableLog; if (typeof exports === "object") { // in nodejs and not running with jest - enableLog = (process.env.JEST_WORKER_ID === undefined); + enableLog = process.env.JEST_WORKER_ID === undefined; } else { // in browser and not running with jsdom - enableLog = (typeof window === 'object' && window.name === 'nodejs'); - }; + enableLog = typeof window === "object" && window.name === "nodejs"; + } if (enableLog) { logLevel = { diff --git a/tests/configs/modules/positions.js b/tests/configs/modules/positions.js index 479775c8..f4f5c453 100644 --- a/tests/configs/modules/positions.js +++ b/tests/configs/modules/positions.js @@ -3,7 +3,13 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: // Using exotic content. This is why don't accept go to JSON configuration file (function () { @@ -20,7 +26,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } return modules; })() -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 415e946d..72bee653 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -1,7 +1,7 @@ const jsdom = require("jsdom"); const config = require("../configs/empty_ipWhiteList"); -exports.startApplication = function (configFilename, exec, callback) { +exports.startApplication = function (configFilename, exec) { jest.resetModules(); // Set config sample for use in test process.env.MM_CONFIG_FILE = configFilename; @@ -9,16 +9,6 @@ exports.startApplication = function (configFilename, exec, callback) { const app = require("app.js"); app.start(); - if (callback) { - const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080"); - jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { - dom.window.onload = function () { - global.document = dom.window.document; - callback(); - }; - }); - }; - return app; }; @@ -27,3 +17,15 @@ exports.stopApplication = function (app) { app.stop(); } }; + +exports.getDocument = function (callback, ms) { + const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080"); + jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { + dom.window.onload = function () { + global.document = dom.window.document; + setTimeout(() => { + callback(); + }, ms); + }; + }); +}; diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js index a1ccfa55..745a8fbb 100644 --- a/tests/e2e/mock-console.js +++ b/tests/e2e/mock-console.js @@ -1,5 +1,10 @@ +/** + * Suppresses errors concerning web server already shut down. + * + * @param {string} err The error message. + */ function myError(err) { - if (err.includes("ECONNREFUSED")) { + if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up")) { jest.fn(); } else { console.dir(err); diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js index 5e07ae19..055ff8c1 100644 --- a/tests/e2e/modules_display_spec.js +++ b/tests/e2e/modules_display_spec.js @@ -3,21 +3,22 @@ let app = null; describe("Display of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/display.js", null, done); + app = helpers.startApplication("tests/configs/modules/display.js"); + helpers.getDocument(done); }); afterAll(function () { helpers.stopApplication(app); }); it("should show the test header", function () { - elem = document.querySelector("#module_0_helloworld .module-header"); + 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"); }); it("should show no header if no header text is specified", function () { - elem = document.querySelector("#module_1_helloworld .module-header"); + const elem = document.querySelector("#module_1_helloworld .module-header"); expect(elem).not.toBe(null); expect(elem.textContent).toBe("undefined"); }); diff --git a/tests/e2e/modules_position_spec.js b/tests/e2e/modules_position_spec.js new file mode 100644 index 00000000..c23933b0 --- /dev/null +++ b/tests/e2e/modules_position_spec.js @@ -0,0 +1,23 @@ +const helpers = require("./global-setup"); +let app = null; + +describe("Position of modules", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/positions.js"); + helpers.getDocument(done, 1000); + }); + afterAll(function () { + helpers.stopApplication(app); + }); + + 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); + }); + } +}); diff --git a/tests/electron/modules_display_spec.js b/tests/electron/modules_display_spec.js deleted file mode 100644 index 6132c62f..00000000 --- a/tests/electron/modules_display_spec.js +++ /dev/null @@ -1,38 +0,0 @@ -const helpers = require("./global-setup"); - -describe("Display of modules", 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("Using helloworld", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/display.js"; - }); - - 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(""); - }); - }); -}); diff --git a/tests/electron/modules_position_spec.js b/tests/electron/modules_position_spec.js deleted file mode 100644 index 7ac1cadd..00000000 --- a/tests/electron/modules_position_spec.js +++ /dev/null @@ -1,38 +0,0 @@ -const helpers = require("./global-setup"); - -describe("Position of modules", function () { - helpers.setupTimeout(this); - - let app = null; - - 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); - }); - }); - }); - } - }); -}); From 89e803ee426d386796990fb0db958fd5f16c292d Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sat, 25 Sep 2021 22:12:53 +0200 Subject: [PATCH 07/20] update without_modules.js and env_spec.js --- tests/configs/without_modules.js | 11 ++++++---- tests/e2e/env_spec.js | 11 ++++++++-- tests/e2e/vendor_spec.js | 2 +- tests/e2e/without_modules.js | 24 +++++++++++++++++++++ tests/electron/without_modules.js | 36 ------------------------------- 5 files changed, 41 insertions(+), 43 deletions(-) create mode 100644 tests/e2e/without_modules.js delete mode 100644 tests/electron/without_modules.js diff --git a/tests/configs/without_modules.js b/tests/configs/without_modules.js index 02b767c0..d84f63b7 100644 --- a/tests/configs/without_modules.js +++ b/tests/configs/without_modules.js @@ -3,10 +3,13 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"] -}); -delete config.modules; +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"], + language: "en", + timeFormat: 24, + units: "metric", +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/env_spec.js b/tests/e2e/env_spec.js index 825da0e6..65dce883 100644 --- a/tests/e2e/env_spec.js +++ b/tests/e2e/env_spec.js @@ -3,8 +3,9 @@ const helpers = require("./global-setup"); let app = null; describe("Electron app environment", function () { - beforeAll(function () { - app = helpers.startApplication("tests/configs/env.js"); + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/default.js"); + helpers.getDocument(done); }); afterAll(function () { helpers.stopApplication(app); @@ -23,4 +24,10 @@ describe("Electron app environment", function () { done(); }); }); + + it("should show the title MagicMirror²", function () { + const elem = document.querySelector("title"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe("MagicMirror²"); + }); }); diff --git a/tests/e2e/vendor_spec.js b/tests/e2e/vendor_spec.js index e8dcde11..e28f2d84 100644 --- a/tests/e2e/vendor_spec.js +++ b/tests/e2e/vendor_spec.js @@ -4,7 +4,7 @@ let app = null; describe("Vendors", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/env.js"); + app = helpers.startApplication("tests/configs/default.js"); }); afterAll(function () { helpers.stopApplication(app); diff --git a/tests/e2e/without_modules.js b/tests/e2e/without_modules.js new file mode 100644 index 00000000..dce6c0b2 --- /dev/null +++ b/tests/e2e/without_modules.js @@ -0,0 +1,24 @@ +const helpers = require("./global-setup"); +let app = null; + +describe("Check configuration without modules", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/without_modules.js"); + helpers.getDocument(done, 1000); + }); + afterAll(function () { + helpers.stopApplication(app); + }); + + it("Show the message MagicMirror title", function () { + const elem = document.querySelector("#module_1_helloworld .module-content"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Magic Mirror2"); + }); + + it("Show the text Michael's website", function () { + const elem = document.querySelector("#module_5_helloworld .module-content"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("www.michaelteeuw.nl"); + }); +}); diff --git a/tests/electron/without_modules.js b/tests/electron/without_modules.js deleted file mode 100644 index 0214aed7..00000000 --- a/tests/electron/without_modules.js +++ /dev/null @@ -1,36 +0,0 @@ -const helpers = require("./global-setup"); - -describe("Check configuration without modules", 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); - }); - - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js"; - }); - - 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"); - }); -}); From 0183d7a0809238d6ceafcb9b4dd577f74b8f1316 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sat, 25 Sep 2021 23:37:37 +0200 Subject: [PATCH 08/20] update modules alert and compliments --- tests/configs/modules/alert/default.js | 10 +- .../compliments/compliments_anytime.js | 8 +- .../modules/compliments/compliments_date.js | 8 +- .../compliments/compliments_only_anytime.js | 8 +- .../compliments/compliments_parts_day.js | 8 +- tests/e2e/compliments_spec.js | 84 ++++++++++++++ tests/e2e/global-setup.js | 8 +- tests/e2e/mock-console.js | 2 +- tests/e2e/modules/alert_spec.js | 18 +++ tests/electron/modules/alert_spec.js | 32 ------ tests/electron/modules/compliments_spec.js | 107 ------------------ 11 files changed, 141 insertions(+), 152 deletions(-) create mode 100644 tests/e2e/compliments_spec.js create mode 100644 tests/e2e/modules/alert_spec.js delete mode 100644 tests/electron/modules/alert_spec.js delete mode 100644 tests/electron/modules/compliments_spec.js diff --git a/tests/configs/modules/alert/default.js b/tests/configs/modules/alert/default.js index b75a41f8..d9c5c968 100644 --- a/tests/configs/modules/alert/default.js +++ b/tests/configs/modules/alert/default.js @@ -3,7 +3,13 @@ * By rejas * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "alert", @@ -13,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/compliments/compliments_anytime.js b/tests/configs/modules/compliments/compliments_anytime.js index f6731edf..813bd32c 100644 --- a/tests/configs/modules/compliments/compliments_anytime.js +++ b/tests/configs/modules/compliments/compliments_anytime.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -20,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/compliments/compliments_date.js b/tests/configs/modules/compliments/compliments_date.js index c9549816..bf0ae2da 100644 --- a/tests/configs/modules/compliments/compliments_date.js +++ b/tests/configs/modules/compliments/compliments_date.js @@ -3,8 +3,12 @@ * By Rejas * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -21,7 +25,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/compliments/compliments_only_anytime.js b/tests/configs/modules/compliments/compliments_only_anytime.js index d65bc67d..6e52f57e 100644 --- a/tests/configs/modules/compliments/compliments_only_anytime.js +++ b/tests/configs/modules/compliments/compliments_only_anytime.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -17,7 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/compliments/compliments_parts_day.js b/tests/configs/modules/compliments/compliments_parts_day.js index e490a710..89b06814 100644 --- a/tests/configs/modules/compliments/compliments_parts_day.js +++ b/tests/configs/modules/compliments/compliments_parts_day.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -19,7 +23,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/compliments_spec.js b/tests/e2e/compliments_spec.js new file mode 100644 index 00000000..aefb273e --- /dev/null +++ b/tests/e2e/compliments_spec.js @@ -0,0 +1,84 @@ +const helpers = require("../global-setup"); +let app = null; + +doTest = function (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 () { + afterAll(function () { + helpers.stopApplication(app); + }); + + describe("parts of days", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js"); + helpers.getDocument(done, 1000); + }); + + it("if Morning compliments for that part of day", function () { + const hour = new Date().getHours(); + if (hour >= 3 && hour < 12) { + // if morning check + doTest(["Hi", "Good Morning", "Morning test"]); + } + }); + + it("if Afternoon show Compliments for that part of day", function () { + const hour = new Date().getHours(); + if (hour >= 12 && hour < 17) { + // if afternoon check + doTest(["Hello", "Good Afternoon", "Afternoon test"]); + } + }); + + it("if Evening show Compliments for that part of day", function () { + const hour = new Date().getHours(); + if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) { + // if evening check + doTest(["Hello There", "Good Evening", "Evening test"]); + } + }); + }); + + describe("Feature anytime in compliments module", function () { + describe("Set anytime and empty compliments for morning, evening and afternoon ", function () { + beforeAll(function (done) { + app = helpers.startApplication("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 () { + doTest(["Anytime here"]); + }); + }); + + describe("Only anytime present in configuration compliments", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js"); + helpers.getDocument(done, 1000); + }); + + it("Show anytime compliments", async function () { + doTest(["Anytime here"]); + }); + }); + }); + + describe("Feature date in compliments module", function () { + describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/compliments/compliments_date.js"); + helpers.getDocument(done, 1000); + }); + + it("Show happy new year compliment on new years day", async function () { + doTest(["Happy new year!"]); + }); + }); + }); +}); diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 72bee653..918047fe 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -3,12 +3,16 @@ const config = require("../configs/empty_ipWhiteList"); exports.startApplication = function (configFilename, exec) { jest.resetModules(); + let app = global.app; + if (app) { + app.stop(); + } // Set config sample for use in test process.env.MM_CONFIG_FILE = configFilename; if (exec) exec; - const app = require("app.js"); + app = require("app.js"); app.start(); - + global.app = app; return app; }; diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js index 745a8fbb..03402a05 100644 --- a/tests/e2e/mock-console.js +++ b/tests/e2e/mock-console.js @@ -4,7 +4,7 @@ * @param {string} err The error message. */ function myError(err) { - if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up")) { + if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) { jest.fn(); } else { console.dir(err); diff --git a/tests/e2e/modules/alert_spec.js b/tests/e2e/modules/alert_spec.js new file mode 100644 index 00000000..19f657a2 --- /dev/null +++ b/tests/e2e/modules/alert_spec.js @@ -0,0 +1,18 @@ +const helpers = require("../global-setup"); +let app = null; + +describe("Alert module", function () { + beforeAll(function (done) { + app = helpers.startApplication("tests/configs/modules/alert/default.js"); + helpers.getDocument(done, 1000); + }); + afterAll(function () { + helpers.stopApplication(app); + }); + + it("should show the welcome message", function () { + 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!"); + }); +}); diff --git a/tests/electron/modules/alert_spec.js b/tests/electron/modules/alert_spec.js deleted file mode 100644 index 12e724f0..00000000 --- a/tests/electron/modules/alert_spec.js +++ /dev/null @@ -1,32 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Alert 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/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); - }); - }); -}); diff --git a/tests/electron/modules/compliments_spec.js b/tests/electron/modules/compliments_spec.js deleted file mode 100644 index 81c6e982..00000000 --- a/tests/electron/modules/compliments_spec.js +++ /dev/null @@ -1,107 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Compliments 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("parts of days", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js"; - }); - - it("if Morning compliments for that part of day", async function () { - const hour = new Date().getHours(); - if (hour >= 3 && hour < 12) { - // if morning check - const elem = await app.client.$(".compliments"); - 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 () { - const hour = new Date().getHours(); - if (hour >= 12 && hour < 17) { - // if afternoon check - const elem = await app.client.$(".compliments"); - 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 () { - const hour = new Date().getHours(); - if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) { - // if evening check - const elem = await app.client.$(".compliments"); - return elem.getText(".compliments").then(function (text) { - expect(["Hello There", "Good Evening", "Evening test"]).toContain(text); - }); - } - }); - }); - - describe("Feature anytime in compliments module", function () { - describe("Set anytime and empty compliments for morning, evening and afternoon ", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js"; - }); - - it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () { - const elem = await app.client.$(".compliments"); - return elem.getText(".compliments").then(function (text) { - expect(["Anytime here"]).toContain(text); - }); - }); - }); - - describe("Only anytime present in configuration compliments", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js"; - }); - - it("Show anytime compliments", async function () { - const elem = await app.client.$(".compliments"); - return elem.getText(".compliments").then(function (text) { - expect(["Anytime here"]).toContain(text); - }); - }); - }); - }); - - describe("Feature date in compliments module", function () { - describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js"; - }); - - it("Show happy new year compliment on new years day", async function () { - const elem = await app.client.$(".compliments"); - return elem.getText(".compliments").then(function (text) { - expect(["Happy new year!"]).toContain(text); - }); - }); - }); - }); -}); From 6595b6a44f92ed7c2bc26dcd423869c4f6115119 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sat, 25 Sep 2021 23:45:34 +0200 Subject: [PATCH 09/20] refactor global-setup.js --- tests/e2e/env_spec.js | 5 ++--- tests/e2e/fonts.js | 5 ++--- tests/e2e/global-setup.js | 17 +++++++---------- tests/e2e/ipWhitelist_spec.js | 9 ++++----- tests/e2e/modules/alert_spec.js | 5 ++--- tests/e2e/{ => modules}/compliments_spec.js | 11 +++++------ tests/e2e/modules_display_spec.js | 5 ++--- tests/e2e/modules_position_spec.js | 5 ++--- tests/e2e/port_config.js | 9 ++++----- tests/e2e/vendor_spec.js | 5 ++--- tests/e2e/without_modules.js | 5 ++--- 11 files changed, 34 insertions(+), 47 deletions(-) rename tests/e2e/{ => modules}/compliments_spec.js (83%) diff --git a/tests/e2e/env_spec.js b/tests/e2e/env_spec.js index 65dce883..b2a7238a 100644 --- a/tests/e2e/env_spec.js +++ b/tests/e2e/env_spec.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("Electron app environment", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/default.js"); + helpers.startApplication("tests/configs/default.js"); helpers.getDocument(done); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("get request from http://localhost:8080 should return 200", function (done) { diff --git a/tests/e2e/fonts.js b/tests/e2e/fonts.js index 105b9977..54cd2d87 100644 --- a/tests/e2e/fonts.js +++ b/tests/e2e/fonts.js @@ -1,6 +1,5 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("All font files from roboto.css should be downloadable", function () { const fontFiles = []; @@ -16,10 +15,10 @@ describe("All font files from roboto.css should be downloadable", function () { } beforeAll(function () { - app = helpers.startApplication("tests/configs/without_modules.js"); + helpers.startApplication("tests/configs/without_modules.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => { diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 918047fe..e524d47c 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -3,22 +3,19 @@ const config = require("../configs/empty_ipWhiteList"); exports.startApplication = function (configFilename, exec) { jest.resetModules(); - let app = global.app; - if (app) { - app.stop(); + if (global.app) { + global.app.stop(); } // Set config sample for use in test process.env.MM_CONFIG_FILE = configFilename; if (exec) exec; - app = require("app.js"); - app.start(); - global.app = app; - return app; + global.app = require("app.js"); + global.app.start(); }; -exports.stopApplication = function (app) { - if (app) { - app.stop(); +exports.stopApplication = function () { + if (global.app) { + global.app.stop(); } }; diff --git a/tests/e2e/ipWhitelist_spec.js b/tests/e2e/ipWhitelist_spec.js index eba92a3e..b518cfff 100644 --- a/tests/e2e/ipWhitelist_spec.js +++ b/tests/e2e/ipWhitelist_spec.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("ipWhitelist directive configuration", function () { describe("Set ipWhitelist without access", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/noIpWhiteList.js"); + helpers.startApplication("tests/configs/noIpWhiteList.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 403", function (done) { @@ -21,10 +20,10 @@ describe("ipWhitelist directive configuration", function () { describe("Set ipWhitelist []", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/empty_ipWhiteList.js"); + helpers.startApplication("tests/configs/empty_ipWhiteList.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { diff --git a/tests/e2e/modules/alert_spec.js b/tests/e2e/modules/alert_spec.js index 19f657a2..a557acc5 100644 --- a/tests/e2e/modules/alert_spec.js +++ b/tests/e2e/modules/alert_spec.js @@ -1,13 +1,12 @@ const helpers = require("../global-setup"); -let app = null; describe("Alert module", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/alert/default.js"); + helpers.startApplication("tests/configs/modules/alert/default.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should show the welcome message", function () { diff --git a/tests/e2e/compliments_spec.js b/tests/e2e/modules/compliments_spec.js similarity index 83% rename from tests/e2e/compliments_spec.js rename to tests/e2e/modules/compliments_spec.js index aefb273e..6c0a2211 100644 --- a/tests/e2e/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -1,5 +1,4 @@ const helpers = require("../global-setup"); -let app = null; doTest = function (complimentsArray) { let elem = document.querySelector(".compliments"); @@ -11,12 +10,12 @@ doTest = function (complimentsArray) { describe("Compliments module", function () { afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); describe("parts of days", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js"); helpers.getDocument(done, 1000); }); @@ -48,7 +47,7 @@ describe("Compliments module", function () { describe("Feature anytime in compliments module", function () { describe("Set anytime and empty compliments for morning, evening and afternoon ", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js"); helpers.getDocument(done, 1000); }); @@ -59,7 +58,7 @@ describe("Compliments module", function () { describe("Only anytime present in configuration compliments", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js"); helpers.getDocument(done, 1000); }); @@ -72,7 +71,7 @@ describe("Compliments module", function () { describe("Feature date in compliments module", function () { describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_date.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_date.js"); helpers.getDocument(done, 1000); }); diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js index 055ff8c1..4042e810 100644 --- a/tests/e2e/modules_display_spec.js +++ b/tests/e2e/modules_display_spec.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Display of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/display.js"); + helpers.startApplication("tests/configs/modules/display.js"); helpers.getDocument(done); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should show the test header", function () { diff --git a/tests/e2e/modules_position_spec.js b/tests/e2e/modules_position_spec.js index c23933b0..79b9b96f 100644 --- a/tests/e2e/modules_position_spec.js +++ b/tests/e2e/modules_position_spec.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Position of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/positions.js"); + helpers.startApplication("tests/configs/modules/positions.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + 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"]; diff --git a/tests/e2e/port_config.js b/tests/e2e/port_config.js index 6f6756a4..329acab6 100644 --- a/tests/e2e/port_config.js +++ b/tests/e2e/port_config.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("port directive configuration", function () { describe("Set port 8090", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/port_8090.js"); + helpers.startApplication("tests/configs/port_8090.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { @@ -21,10 +20,10 @@ describe("port directive configuration", function () { describe("Set port 8100 on environment variable MM_PORT", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100)); + helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100)); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { diff --git a/tests/e2e/vendor_spec.js b/tests/e2e/vendor_spec.js index e28f2d84..f6917c0d 100644 --- a/tests/e2e/vendor_spec.js +++ b/tests/e2e/vendor_spec.js @@ -1,13 +1,12 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("Vendors", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/default.js"); + helpers.startApplication("tests/configs/default.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); describe("Get list vendors", function () { diff --git a/tests/e2e/without_modules.js b/tests/e2e/without_modules.js index dce6c0b2..8aeeee28 100644 --- a/tests/e2e/without_modules.js +++ b/tests/e2e/without_modules.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Check configuration without modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/without_modules.js"); + helpers.startApplication("tests/configs/without_modules.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("Show the message MagicMirror title", function () { From e0906f3462b34e70fc3ae6d7f763e387484ac3d9 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sat, 25 Sep 2021 23:51:32 +0200 Subject: [PATCH 10/20] update module helloworld --- .../configs/modules/helloworld/helloworld.js | 10 ++++- .../modules/helloworld/helloworld_default.js | 10 ++++- tests/e2e/modules/helloworld_spec.js | 33 ++++++++++++++ tests/electron/modules/helloworld_spec.js | 45 ------------------- 4 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 tests/e2e/modules/helloworld_spec.js delete mode 100644 tests/electron/modules/helloworld_spec.js diff --git a/tests/configs/modules/helloworld/helloworld.js b/tests/configs/modules/helloworld/helloworld.js index 9845e4b8..a1d48278 100644 --- a/tests/configs/modules/helloworld/helloworld.js +++ b/tests/configs/modules/helloworld/helloworld.js @@ -3,7 +3,13 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "helloworld", @@ -13,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/helloworld/helloworld_default.js b/tests/configs/modules/helloworld/helloworld_default.js index 6400c9f7..5678488d 100644 --- a/tests/configs/modules/helloworld/helloworld_default.js +++ b/tests/configs/modules/helloworld/helloworld_default.js @@ -3,14 +3,20 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "helloworld", position: "bottom_bar" } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/modules/helloworld_spec.js b/tests/e2e/modules/helloworld_spec.js new file mode 100644 index 00000000..8c11575a --- /dev/null +++ b/tests/e2e/modules/helloworld_spec.js @@ -0,0 +1,33 @@ +const helpers = require("../global-setup"); + +describe("Test helloworld module", function () { + afterAll(function () { + helpers.stopApplication(); + }); + + describe("helloworld set config text", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/helloworld/helloworld.js"); + helpers.getDocument(done, 1000); + }); + + it("Test message helloworld module", async function () { + const elem = document.querySelector(".helloworld"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Test HelloWorld Module"); + }); + }); + + describe("helloworld default config text", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js"); + helpers.getDocument(done, 1000); + }); + + it("Test message helloworld module", async function () { + const elem = document.querySelector(".helloworld"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Hello World!"); + }); + }); +}); diff --git a/tests/electron/modules/helloworld_spec.js b/tests/electron/modules/helloworld_spec.js deleted file mode 100644 index 95ee1a2d..00000000 --- a/tests/electron/modules/helloworld_spec.js +++ /dev/null @@ -1,45 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Test helloworld 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("helloworld set config text", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js"; - }); - - it("Test message helloworld module", async function () { - const elem = await app.client.$(".helloworld"); - return expect(await elem.getText(".helloworld")).toBe("Test HelloWorld Module"); - }); - }); - - describe("helloworld default config text", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld_default.js"; - }); - - it("Test message helloworld module", async function () { - const elem = await app.client.$(".helloworld"); - return expect(await elem.getText(".helloworld")).toBe("Hello World!"); - }); - }); -}); From d831315e20262334af3dc145a954c0fb6bc46e12 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sun, 26 Sep 2021 00:06:06 +0200 Subject: [PATCH 11/20] update module newsfeed --- tests/configs/modules/newsfeed/default.js | 8 ++- .../configs/modules/newsfeed/incorrect_url.js | 8 ++- .../modules/newsfeed/prohibited_words.js | 8 ++- tests/e2e/modules/newsfeed_spec.js | 63 +++++++++++++++++ tests/electron/modules/newsfeed_spec.js | 67 ------------------- 5 files changed, 81 insertions(+), 73 deletions(-) create mode 100644 tests/e2e/modules/newsfeed_spec.js delete mode 100644 tests/electron/modules/newsfeed_spec.js diff --git a/tests/configs/modules/newsfeed/default.js b/tests/configs/modules/newsfeed/default.js index 1a112566..160212f1 100644 --- a/tests/configs/modules/newsfeed/default.js +++ b/tests/configs/modules/newsfeed/default.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -20,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/newsfeed/incorrect_url.js b/tests/configs/modules/newsfeed/incorrect_url.js index ab126aa4..bdaa0341 100644 --- a/tests/configs/modules/newsfeed/incorrect_url.js +++ b/tests/configs/modules/newsfeed/incorrect_url.js @@ -2,8 +2,12 @@ * * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -19,7 +23,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/newsfeed/prohibited_words.js b/tests/configs/modules/newsfeed/prohibited_words.js index f4040557..55c71e29 100644 --- a/tests/configs/modules/newsfeed/prohibited_words.js +++ b/tests/configs/modules/newsfeed/prohibited_words.js @@ -2,8 +2,12 @@ * * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -21,7 +25,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/modules/newsfeed_spec.js b/tests/e2e/modules/newsfeed_spec.js new file mode 100644 index 00000000..0b2869e2 --- /dev/null +++ b/tests/e2e/modules/newsfeed_spec.js @@ -0,0 +1,63 @@ +const helpers = require("../global-setup"); + +describe("Newsfeed module", function () { + afterAll(function () { + helpers.stopApplication(); + }); + + describe("Default configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/default.js"); + helpers.getDocument(done, 3000); + }); + + it("should show the newsfeed title", function () { + 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 () { + 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 () => { + const elem = document.querySelector(".newsfeed .newsfeed-desc"); + expect(elem).toBe(null); + }); + }); + + describe("Custom configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js"); + helpers.getDocument(done, 3000); + }); + + it("should not show articles with prohibited words", function () { + 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 () => { + const elem = document.querySelector(".newsfeed .newsfeed-desc"); + expect(elem).not.toBe(null); + expect(elem.textContent.length).not.toBe(0); + }); + }); + + describe("Invalid configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js"); + helpers.getDocument(done, 3000); + }); + + it("should show malformed url warning", function () { + const elem = document.querySelector(".newsfeed .small"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url."); + }); + }); +}); diff --git a/tests/electron/modules/newsfeed_spec.js b/tests/electron/modules/newsfeed_spec.js deleted file mode 100644 index fe544a0b..00000000 --- a/tests/electron/modules/newsfeed_spec.js +++ /dev/null @@ -1,67 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Newsfeed 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 () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js"; - }); - - it("should show the newsfeed title", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-source", "Rodrigo Ramirez Blog", 10000); - }); - - it("should show the newsfeed article", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); - }); - - it("should NOT show the newsfeed description", async () => { - await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); - const events = await app.client.$$(".newsfeed .newsfeed-desc"); - return expect(events.length).toBe(0); - }); - }); - - describe("Custom configuration", function () { - beforeAll(function () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/prohibited_words.js"; - }); - - it("should not show articles with prohibited words", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); - }); - - it("should show the newsfeed description", async () => { - await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); - const events = await app.client.$$(".newsfeed .newsfeed-desc"); - return expect(events.length).toBe(1); - }); - }); - - describe("Invalid configuration", function () { - beforeAll(function () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/incorrect_url.js"; - }); - - it("should show malformed url warning", function () { - return app.client.waitUntilTextExists(".newsfeed .small", "Error in the Newsfeed module. Malformed url.", 10000); - }); - }); -}); From 385e5aabaaf59ff9750eb938bf68ef6bbb709427 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sun, 26 Sep 2021 00:29:03 +0200 Subject: [PATCH 12/20] prettier --- tests/configs/without_modules.js | 2 +- tests/e2e/modules/compliments_spec.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/configs/without_modules.js b/tests/configs/without_modules.js index d84f63b7..9cc097ae 100644 --- a/tests/configs/without_modules.js +++ b/tests/configs/without_modules.js @@ -8,7 +8,7 @@ let config = { ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"], language: "en", timeFormat: 24, - units: "metric", + units: "metric" }; /*************** DO NOT EDIT THE LINE BELOW ***************/ diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js index 6c0a2211..0f3b74e8 100644 --- a/tests/e2e/modules/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -1,12 +1,17 @@ const helpers = require("../global-setup"); -doTest = function (complimentsArray) { +/** + * 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 () { afterAll(function () { From a4a8504558132259c886d641cbd202203da22863 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sun, 26 Sep 2021 21:58:59 +0200 Subject: [PATCH 13/20] update module clock --- tests/configs/modules/clock/clock_12hr.js | 8 +- tests/configs/modules/clock/clock_24hr.js | 10 +- tests/configs/modules/clock/clock_analog.js | 10 +- .../clock/clock_displaySeconds_false.js | 8 +- .../modules/clock/clock_showPeriodUpper.js | 8 +- tests/configs/modules/clock/clock_showTime.js | 8 +- tests/configs/modules/clock/clock_showWeek.js | 8 +- tests/e2e/modules/clock_spec.js | 116 +++++++++++++++ tests/e2e/modules/compliments_spec.js | 6 +- tests/e2e/modules/helloworld_spec.js | 4 +- tests/e2e/modules/newsfeed_spec.js | 4 +- tests/electron/modules/clock_spec.js | 134 ------------------ 12 files changed, 169 insertions(+), 155 deletions(-) create mode 100644 tests/e2e/modules/clock_spec.js delete mode 100644 tests/electron/modules/clock_spec.js diff --git a/tests/configs/modules/clock/clock_12hr.js b/tests/configs/modules/clock/clock_12hr.js index 35b45914..cb3563c7 100644 --- a/tests/configs/modules/clock/clock_12hr.js +++ b/tests/configs/modules/clock/clock_12hr.js @@ -3,8 +3,12 @@ * By Sergey Morozov * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -12,7 +16,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( position: "middle_center" } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_24hr.js b/tests/configs/modules/clock/clock_24hr.js index 01b2a36b..f77a600d 100644 --- a/tests/configs/modules/clock/clock_24hr.js +++ b/tests/configs/modules/clock/clock_24hr.js @@ -3,14 +3,20 @@ * By Sergey Morozov * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "clock", position: "middle_center" } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_analog.js b/tests/configs/modules/clock/clock_analog.js index b33bd051..7f1353c6 100644 --- a/tests/configs/modules/clock/clock_analog.js +++ b/tests/configs/modules/clock/clock_analog.js @@ -2,7 +2,13 @@ * * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", + timeFormat: 24, + units: "metric", + modules: [ { module: "clock", @@ -13,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_displaySeconds_false.js b/tests/configs/modules/clock/clock_displaySeconds_false.js index 1caef7e3..4e872377 100644 --- a/tests/configs/modules/clock/clock_displaySeconds_false.js +++ b/tests/configs/modules/clock/clock_displaySeconds_false.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_showPeriodUpper.js b/tests/configs/modules/clock/clock_showPeriodUpper.js index b069c438..7ff7f20a 100644 --- a/tests/configs/modules/clock/clock_showPeriodUpper.js +++ b/tests/configs/modules/clock/clock_showPeriodUpper.js @@ -3,8 +3,12 @@ * By Sergey Morozov * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_showTime.js b/tests/configs/modules/clock/clock_showTime.js index 93dd83de..2c130fb2 100644 --- a/tests/configs/modules/clock/clock_showTime.js +++ b/tests/configs/modules/clock/clock_showTime.js @@ -3,8 +3,12 @@ * By Johan Hammar * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/clock_showWeek.js b/tests/configs/modules/clock/clock_showWeek.js index b595ba70..1db31cb6 100644 --- a/tests/configs/modules/clock/clock_showWeek.js +++ b/tests/configs/modules/clock/clock_showWeek.js @@ -3,8 +3,12 @@ * By Johan Hammar * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -15,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js new file mode 100644 index 00000000..79e26f47 --- /dev/null +++ b/tests/e2e/modules/clock_spec.js @@ -0,0 +1,116 @@ +const helpers = require("../global-setup"); +const moment = require("moment"); + +describe("Clock module", function () { + afterAll(function () { + helpers.stopApplication(); + }); + + const testMatch = function (element, regex) { + const elem = document.querySelector(element); + expect(elem).not.toBe(null); + expect(elem.textContent).toMatch(regex); + }; + + describe("with default 24hr clock config", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_24hr.js"); + helpers.getDocument(done, 1000); + }); + + 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}$/; + testMatch(".clock .date", dateRegex); + }); + + it("should show the time in 24hr format", function () { + const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with default 12hr clock config", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_12hr.js"); + helpers.getDocument(done, 1000); + }); + + 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}$/; + testMatch(".clock .date", dateRegex); + }); + + it("should show the time in 12hr format", function () { + const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with showPeriodUpper config enabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js"); + helpers.getDocument(done, 1000); + }); + + 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$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with displaySeconds config disabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js"); + helpers.getDocument(done, 1000); + }); + + it("should show 12hr time without seconds am/pm", function () { + const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with showTime config disabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_showTime.js"); + helpers.getDocument(done, 1000); + }); + + it("should show not show the time when digital clock is shown", function () { + const elem = document.querySelector(".clock .digital .time"); + expect(elem).toBe(null); + }); + }); + + describe("with showWeek config enabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js"); + helpers.getDocument(done, 1000); + }); + + it("should show the week in the correct format", function () { + const weekRegex = /^Week [0-9]{1,2}$/; + testMatch(".clock .week", weekRegex); + }); + + it("should show the week with the correct number of week of year", function () { + const currentWeekNumber = moment().week(); + const weekToShow = "Week " + currentWeekNumber; + const elem = document.querySelector(".clock .week"); + expect(elem).not.toBe(null); + expect(elem.textContent).toBe(weekToShow); + }); + }); + + describe("with analog clock face enabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/clock_analog.js"); + helpers.getDocument(done, 1000); + }); + + it("should show the analog clock face", () => { + const elem = document.querySelector(".clockCircle"); + expect(elem).not.toBe(null); + }); + }); +}); diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js index 0f3b74e8..73f851c5 100644 --- a/tests/e2e/modules/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -56,7 +56,7 @@ describe("Compliments module", function () { 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 () { doTest(["Anytime here"]); }); }); @@ -67,7 +67,7 @@ describe("Compliments module", function () { helpers.getDocument(done, 1000); }); - it("Show anytime compliments", async function () { + it("Show anytime compliments", function () { doTest(["Anytime here"]); }); }); @@ -80,7 +80,7 @@ describe("Compliments module", function () { 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 () { doTest(["Happy new year!"]); }); }); diff --git a/tests/e2e/modules/helloworld_spec.js b/tests/e2e/modules/helloworld_spec.js index 8c11575a..d8f1a3c6 100644 --- a/tests/e2e/modules/helloworld_spec.js +++ b/tests/e2e/modules/helloworld_spec.js @@ -11,7 +11,7 @@ describe("Test helloworld module", function () { helpers.getDocument(done, 1000); }); - it("Test message helloworld module", async function () { + it("Test message helloworld module", function () { const elem = document.querySelector(".helloworld"); expect(elem).not.toBe(null); expect(elem.textContent).toContain("Test HelloWorld Module"); @@ -24,7 +24,7 @@ describe("Test helloworld module", function () { helpers.getDocument(done, 1000); }); - it("Test message helloworld module", async function () { + it("Test message helloworld module", function () { const elem = document.querySelector(".helloworld"); expect(elem).not.toBe(null); expect(elem.textContent).toContain("Hello World!"); diff --git a/tests/e2e/modules/newsfeed_spec.js b/tests/e2e/modules/newsfeed_spec.js index 0b2869e2..d7a3b9fe 100644 --- a/tests/e2e/modules/newsfeed_spec.js +++ b/tests/e2e/modules/newsfeed_spec.js @@ -23,7 +23,7 @@ describe("Newsfeed module", function () { expect(elem.textContent).toContain("QPanel"); }); - it("should NOT show the newsfeed description", async () => { + it("should NOT show the newsfeed description", () => { const elem = document.querySelector(".newsfeed .newsfeed-desc"); expect(elem).toBe(null); }); @@ -41,7 +41,7 @@ describe("Newsfeed module", function () { expect(elem.textContent).toContain("Problema VirtualBox"); }); - it("should show the newsfeed description", async () => { + it("should show the newsfeed description", () => { const elem = document.querySelector(".newsfeed .newsfeed-desc"); expect(elem).not.toBe(null); expect(elem.textContent.length).not.toBe(0); diff --git a/tests/electron/modules/clock_spec.js b/tests/electron/modules/clock_spec.js deleted file mode 100644 index c2e03fc9..00000000 --- a/tests/electron/modules/clock_spec.js +++ /dev/null @@ -1,134 +0,0 @@ -const helpers = require("../global-setup"); -const moment = require("moment"); - -describe("Clock module", function () { - helpers.setupTimeout(this); - - let app = null; - - const testMatch = async function (element, regex) { - await app.client.waitUntilWindowLoaded(); - 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 () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js"; - }); - - it("should show the date in the correct format", async 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}$/; - return testMatch(".clock .date", dateRegex); - }); - - it("should show the time in 24hr format", async function () { - const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with default 12hr clock config", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js"; - }); - - it("should show the date in the correct format", async 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}$/; - return testMatch(".clock .date", dateRegex); - }); - - it("should show the time in 12hr format", async function () { - const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with showPeriodUpper config enabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js"; - }); - - it("should show 12hr time with upper case AM/PM", async function () { - const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with displaySeconds config disabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js"; - }); - - it("should show 12hr time without seconds am/pm", async function () { - const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with showTime config disabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showTime.js"; - }); - - it("should show not show the time when digital clock is shown", async function () { - await app.client.waitUntilWindowLoaded(); - const time = await app.client.$$(".clock .digital .time"); - return expect(time.length).toBe(0); - }); - }); - - describe("with showWeek config enabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js"; - }); - - it("should show the week in the correct format", async function () { - const weekRegex = /^Week [0-9]{1,2}$/; - return testMatch(".clock .week", weekRegex); - }); - - it("should show the week with the correct number of week of year", async function () { - const currentWeekNumber = moment().week(); - const weekToShow = "Week " + currentWeekNumber; - await app.client.waitUntilWindowLoaded(); - const elem = await app.client.$(".clock .week"); - const txt = await elem.getText(".clock .week"); - return expect(txt).toBe(weekToShow); - }); - }); - - describe("with analog clock face enabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_analog.js"; - }); - - it("should show the analog clock face", async () => { - await app.client.waitUntilWindowLoaded(); - const clock = await app.client.$$(".clockCircle"); - return expect(clock.length).toBe(1); - }); - }); -}); From f750436b64c54a090767d2c88a36e87da3138356 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sun, 26 Sep 2021 22:09:41 +0200 Subject: [PATCH 14/20] update module clock_es --- tests/configs/modules/clock/es/clock_12hr.js | 7 +- tests/configs/modules/clock/es/clock_24hr.js | 8 +- .../modules/clock/es/clock_showPeriodUpper.js | 7 +- .../modules/clock/es/clock_showWeek.js | 7 +- tests/e2e/modules/clock_es_spec.js | 71 +++++++++++++++ tests/electron/modules/clock_es_spec.js | 86 ------------------- 6 files changed, 92 insertions(+), 94 deletions(-) create mode 100644 tests/e2e/modules/clock_es_spec.js delete mode 100644 tests/electron/modules/clock_es_spec.js diff --git a/tests/configs/modules/clock/es/clock_12hr.js b/tests/configs/modules/clock/es/clock_12hr.js index addbeb9f..57d1c7a9 100644 --- a/tests/configs/modules/clock/es/clock_12hr.js +++ b/tests/configs/modules/clock/es/clock_12hr.js @@ -3,9 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, + units: "metric", modules: [ { @@ -13,7 +16,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( position: "middle_center" } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/es/clock_24hr.js b/tests/configs/modules/clock/es/clock_24hr.js index a5fe49ca..60cfa109 100644 --- a/tests/configs/modules/clock/es/clock_24hr.js +++ b/tests/configs/modules/clock/es/clock_24hr.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", + timeFormat: 24, + units: "metric", modules: [ { @@ -12,7 +16,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( position: "middle_center" } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/es/clock_showPeriodUpper.js b/tests/configs/modules/clock/es/clock_showPeriodUpper.js index 4a5ab636..5d0c28bb 100644 --- a/tests/configs/modules/clock/es/clock_showPeriodUpper.js +++ b/tests/configs/modules/clock/es/clock_showPeriodUpper.js @@ -3,9 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, + units: "metric", modules: [ { @@ -16,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/clock/es/clock_showWeek.js b/tests/configs/modules/clock/es/clock_showWeek.js index b4a436a6..f8f71982 100644 --- a/tests/configs/modules/clock/es/clock_showWeek.js +++ b/tests/configs/modules/clock/es/clock_showWeek.js @@ -4,9 +4,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, + units: "metric", modules: [ { @@ -17,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/modules/clock_es_spec.js b/tests/e2e/modules/clock_es_spec.js new file mode 100644 index 00000000..78818014 --- /dev/null +++ b/tests/e2e/modules/clock_es_spec.js @@ -0,0 +1,71 @@ +const helpers = require("../global-setup"); + +describe("Clock set to spanish language module", function () { + afterAll(function () { + helpers.stopApplication(); + }); + + const testMatch = function (element, regex) { + const elem = document.querySelector(element); + expect(elem).not.toBe(null); + expect(elem.textContent).toMatch(regex); + }; + + describe("with default 24hr clock config", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js"); + helpers.getDocument(done, 1000); + }); + + 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}$/; + testMatch(".clock .date", dateRegex); + }); + + it("shows time in 24hr format", function () { + const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with default 12hr clock config", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js"); + helpers.getDocument(done, 1000); + }); + + 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}$/; + testMatch(".clock .date", dateRegex); + }); + + it("shows time in 12hr format", function () { + const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with showPeriodUpper config enabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js"); + helpers.getDocument(done, 1000); + }); + + 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$/; + testMatch(".clock .time", timeRegex); + }); + }); + + describe("with showWeek config enabled", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js"); + helpers.getDocument(done, 1000); + }); + + it("shows week with correct format", function () { + const weekRegex = /^Semana [0-9]{1,2}$/; + testMatch(".clock .week", weekRegex); + }); + }); +}); diff --git a/tests/electron/modules/clock_es_spec.js b/tests/electron/modules/clock_es_spec.js deleted file mode 100644 index 4c39a241..00000000 --- a/tests/electron/modules/clock_es_spec.js +++ /dev/null @@ -1,86 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Clock set to spanish language module", function () { - helpers.setupTimeout(this); - - let app = null; - - const testMatch = async function (element, regex) { - await app.client.waitUntilWindowLoaded(); - 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 () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js"; - }); - - it("shows date with correct format", async 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}$/; - return testMatch(".clock .date", dateRegex); - }); - - it("shows time in 24hr format", async function () { - const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with default 12hr clock config", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js"; - }); - - it("shows date with correct format", async 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}$/; - return testMatch(".clock .date", dateRegex); - }); - - it("shows time in 12hr format", async function () { - const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with showPeriodUpper config enabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showPeriodUpper.js"; - }); - - it("shows 12hr time with upper case AM/PM", async function () { - const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/; - return testMatch(".clock .time", timeRegex); - }); - }); - - describe("with showWeek config enabled", function () { - beforeAll(function () { - // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showWeek.js"; - }); - - it("shows week with correct format", async function () { - const weekRegex = /^Semana [0-9]{1,2}$/; - return testMatch(".clock .week", weekRegex); - }); - }); -}); From 1034171e91e4f650c3a38469ad40fba5dfd9edc4 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Tue, 28 Sep 2021 21:10:24 +0200 Subject: [PATCH 15/20] add CHANGELOG --- CHANGELOG.md | 2 +- tests/e2e/mock-console.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8961cfd..7530e579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ _This release is scheduled to be released on 2021-10-01._ - Refactored methods from weatherproviders into weatherobject (isDaytime, updateSunTime). - Use of `logger.js` in jest tests. - Run prettier over all relevant files. -- Move test needing electron in new category `electron`, use `server only` mode in `e2e` tests. +- Move tests needing electron in new category `electron`, use `server only` mode in `e2e` tests. ### Fixed diff --git a/tests/e2e/mock-console.js b/tests/e2e/mock-console.js index 03402a05..90b70f12 100644 --- a/tests/e2e/mock-console.js +++ b/tests/e2e/mock-console.js @@ -3,7 +3,7 @@ * * @param {string} err The error message. */ -function myError(err) { +function mockError(err) { if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) { jest.fn(); } else { @@ -14,7 +14,7 @@ function myError(err) { global.console = { log: jest.fn(), dir: console.dir, - error: myError, + error: mockError, warn: console.warn, info: jest.fn(), debug: console.debug From abcee8aa5600fe2dc1c27d799107a5ab3e510ce6 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Tue, 28 Sep 2021 21:23:59 +0200 Subject: [PATCH 16/20] fix global-setup.js --- tests/e2e/global-setup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index e524d47c..8e940d9b 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -1,5 +1,4 @@ const jsdom = require("jsdom"); -const config = require("../configs/empty_ipWhiteList"); exports.startApplication = function (configFilename, exec) { jest.resetModules(); From 8224a6ac35dfffdfc9a7e859de4b12502c30a887 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Tue, 28 Sep 2021 21:38:30 +0200 Subject: [PATCH 17/20] add custom.css before testing --- .github/workflows/codecov-test-suites.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codecov-test-suites.yml b/.github/workflows/codecov-test-suites.yml index f2d210eb..8c2be8da 100644 --- a/.github/workflows/codecov-test-suites.yml +++ b/.github/workflows/codecov-test-suites.yml @@ -20,6 +20,7 @@ jobs: Xvfb :99 -screen 0 1024x768x16 & export DISPLAY=:99 npm ci + touch css/custom.css npm run test:coverage - name: Upload coverage results to codecov uses: codecov/codecov-action@v1 From c67320f1852a1fbd8f4b95120b3cebb72891047f Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Tue, 28 Sep 2021 22:08:21 +0200 Subject: [PATCH 18/20] fix logger.js --- js/logger.js | 2 +- tests/e2e/global-setup.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/js/logger.js b/js/logger.js index a42db925..0ea523d7 100644 --- a/js/logger.js +++ b/js/logger.js @@ -30,7 +30,7 @@ enableLog = process.env.JEST_WORKER_ID === undefined; } else { // in browser and not running with jsdom - enableLog = typeof window === "object" && window.name === "nodejs"; + enableLog = typeof window === "object" && window.name !== "jsdom"; } if (enableLog) { diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 8e940d9b..45726493 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -21,6 +21,7 @@ exports.stopApplication = function () { exports.getDocument = function (callback, ms) { const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080"); jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => { + dom.window.name = "jsdom"; dom.window.onload = function () { global.document = dom.window.document; setTimeout(() => { From 997aec8cc22b5af4a4559feb2a095d04b48104b9 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Wed, 29 Sep 2021 21:02:52 +0200 Subject: [PATCH 19/20] remove default values from test configs --- tests/configs/default.js | 6 ------ tests/configs/modules/alert/default.js | 6 ------ tests/configs/modules/clock/clock_12hr.js | 4 ---- tests/configs/modules/clock/clock_24hr.js | 6 ------ tests/configs/modules/clock/clock_analog.js | 6 ------ tests/configs/modules/clock/clock_displaySeconds_false.js | 4 ---- tests/configs/modules/clock/clock_showPeriodUpper.js | 4 ---- tests/configs/modules/clock/clock_showTime.js | 4 ---- tests/configs/modules/clock/clock_showWeek.js | 4 ---- tests/configs/modules/clock/es/clock_12hr.js | 3 --- tests/configs/modules/clock/es/clock_24hr.js | 4 ---- tests/configs/modules/clock/es/clock_showPeriodUpper.js | 3 --- tests/configs/modules/clock/es/clock_showWeek.js | 3 --- tests/configs/modules/compliments/compliments_anytime.js | 4 ---- tests/configs/modules/compliments/compliments_date.js | 4 ---- .../configs/modules/compliments/compliments_only_anytime.js | 4 ---- tests/configs/modules/compliments/compliments_parts_day.js | 4 ---- tests/configs/modules/display.js | 6 ------ tests/configs/modules/helloworld/helloworld.js | 6 ------ tests/configs/modules/helloworld/helloworld_default.js | 6 ------ tests/configs/modules/newsfeed/default.js | 4 ---- tests/configs/modules/newsfeed/incorrect_url.js | 4 ---- tests/configs/modules/newsfeed/prohibited_words.js | 4 ---- tests/configs/modules/positions.js | 6 ------ tests/configs/without_modules.js | 4 +--- 25 files changed, 1 insertion(+), 112 deletions(-) diff --git a/tests/configs/default.js b/tests/configs/default.js index e3236318..5568e5e0 100644 --- a/tests/configs/default.js +++ b/tests/configs/default.js @@ -6,12 +6,6 @@ exports.configFactory = function (options) { return Object.assign( { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - - language: "en", - timeFormat: 24, - units: "metric", electronOptions: { webPreferences: { nodeIntegration: true, diff --git a/tests/configs/modules/alert/default.js b/tests/configs/modules/alert/default.js index d9c5c968..423260c7 100644 --- a/tests/configs/modules/alert/default.js +++ b/tests/configs/modules/alert/default.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "alert", diff --git a/tests/configs/modules/clock/clock_12hr.js b/tests/configs/modules/clock/clock_12hr.js index cb3563c7..6b8917bd 100644 --- a/tests/configs/modules/clock/clock_12hr.js +++ b/tests/configs/modules/clock/clock_12hr.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/clock_24hr.js b/tests/configs/modules/clock/clock_24hr.js index f77a600d..27f89d0c 100644 --- a/tests/configs/modules/clock/clock_24hr.js +++ b/tests/configs/modules/clock/clock_24hr.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "clock", diff --git a/tests/configs/modules/clock/clock_analog.js b/tests/configs/modules/clock/clock_analog.js index 7f1353c6..cbe3fecc 100644 --- a/tests/configs/modules/clock/clock_analog.js +++ b/tests/configs/modules/clock/clock_analog.js @@ -3,12 +3,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "clock", diff --git a/tests/configs/modules/clock/clock_displaySeconds_false.js b/tests/configs/modules/clock/clock_displaySeconds_false.js index 4e872377..57bf006a 100644 --- a/tests/configs/modules/clock/clock_displaySeconds_false.js +++ b/tests/configs/modules/clock/clock_displaySeconds_false.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/clock_showPeriodUpper.js b/tests/configs/modules/clock/clock_showPeriodUpper.js index 7ff7f20a..1e01644f 100644 --- a/tests/configs/modules/clock/clock_showPeriodUpper.js +++ b/tests/configs/modules/clock/clock_showPeriodUpper.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/clock_showTime.js b/tests/configs/modules/clock/clock_showTime.js index 2c130fb2..37bdc5cc 100644 --- a/tests/configs/modules/clock/clock_showTime.js +++ b/tests/configs/modules/clock/clock_showTime.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/clock_showWeek.js b/tests/configs/modules/clock/clock_showWeek.js index 1db31cb6..2c421e85 100644 --- a/tests/configs/modules/clock/clock_showWeek.js +++ b/tests/configs/modules/clock/clock_showWeek.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/es/clock_12hr.js b/tests/configs/modules/clock/es/clock_12hr.js index 57d1c7a9..07e5206a 100644 --- a/tests/configs/modules/clock/es/clock_12hr.js +++ b/tests/configs/modules/clock/es/clock_12hr.js @@ -4,11 +4,8 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/es/clock_24hr.js b/tests/configs/modules/clock/es/clock_24hr.js index 60cfa109..469f4e3b 100644 --- a/tests/configs/modules/clock/es/clock_24hr.js +++ b/tests/configs/modules/clock/es/clock_24hr.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", - timeFormat: 24, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/es/clock_showPeriodUpper.js b/tests/configs/modules/clock/es/clock_showPeriodUpper.js index 5d0c28bb..0253c28c 100644 --- a/tests/configs/modules/clock/es/clock_showPeriodUpper.js +++ b/tests/configs/modules/clock/es/clock_showPeriodUpper.js @@ -4,11 +4,8 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/clock/es/clock_showWeek.js b/tests/configs/modules/clock/es/clock_showWeek.js index f8f71982..dd8f6cd2 100644 --- a/tests/configs/modules/clock/es/clock_showWeek.js +++ b/tests/configs/modules/clock/es/clock_showWeek.js @@ -5,11 +5,8 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "es", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/compliments/compliments_anytime.js b/tests/configs/modules/compliments/compliments_anytime.js index 813bd32c..2034b379 100644 --- a/tests/configs/modules/compliments/compliments_anytime.js +++ b/tests/configs/modules/compliments/compliments_anytime.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/compliments/compliments_date.js b/tests/configs/modules/compliments/compliments_date.js index bf0ae2da..a89dd7de 100644 --- a/tests/configs/modules/compliments/compliments_date.js +++ b/tests/configs/modules/compliments/compliments_date.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/compliments/compliments_only_anytime.js b/tests/configs/modules/compliments/compliments_only_anytime.js index 6e52f57e..5261e58b 100644 --- a/tests/configs/modules/compliments/compliments_only_anytime.js +++ b/tests/configs/modules/compliments/compliments_only_anytime.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/compliments/compliments_parts_day.js b/tests/configs/modules/compliments/compliments_parts_day.js index 89b06814..08c9d94e 100644 --- a/tests/configs/modules/compliments/compliments_parts_day.js +++ b/tests/configs/modules/compliments/compliments_parts_day.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/display.js b/tests/configs/modules/display.js index b9facce3..03aa4f19 100644 --- a/tests/configs/modules/display.js +++ b/tests/configs/modules/display.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "helloworld", diff --git a/tests/configs/modules/helloworld/helloworld.js b/tests/configs/modules/helloworld/helloworld.js index a1d48278..39480bc1 100644 --- a/tests/configs/modules/helloworld/helloworld.js +++ b/tests/configs/modules/helloworld/helloworld.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "helloworld", diff --git a/tests/configs/modules/helloworld/helloworld_default.js b/tests/configs/modules/helloworld/helloworld_default.js index 5678488d..ea95ad83 100644 --- a/tests/configs/modules/helloworld/helloworld_default.js +++ b/tests/configs/modules/helloworld/helloworld_default.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: [ { module: "helloworld", diff --git a/tests/configs/modules/newsfeed/default.js b/tests/configs/modules/newsfeed/default.js index 160212f1..7758da0c 100644 --- a/tests/configs/modules/newsfeed/default.js +++ b/tests/configs/modules/newsfeed/default.js @@ -4,11 +4,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/newsfeed/incorrect_url.js b/tests/configs/modules/newsfeed/incorrect_url.js index bdaa0341..522fa2d1 100644 --- a/tests/configs/modules/newsfeed/incorrect_url.js +++ b/tests/configs/modules/newsfeed/incorrect_url.js @@ -3,11 +3,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/newsfeed/prohibited_words.js b/tests/configs/modules/newsfeed/prohibited_words.js index 55c71e29..68d22f54 100644 --- a/tests/configs/modules/newsfeed/prohibited_words.js +++ b/tests/configs/modules/newsfeed/prohibited_words.js @@ -3,11 +3,7 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", timeFormat: 12, - units: "metric", modules: [ { diff --git a/tests/configs/modules/positions.js b/tests/configs/modules/positions.js index f4f5c453..186c25f9 100644 --- a/tests/configs/modules/positions.js +++ b/tests/configs/modules/positions.js @@ -4,12 +4,6 @@ * MIT Licensed. */ let config = { - port: 8080, - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], - language: "en", - timeFormat: 24, - units: "metric", - modules: // Using exotic content. This is why don't accept go to JSON configuration file (function () { diff --git a/tests/configs/without_modules.js b/tests/configs/without_modules.js index 9cc097ae..a90115d4 100644 --- a/tests/configs/without_modules.js +++ b/tests/configs/without_modules.js @@ -4,10 +4,8 @@ * MIT Licensed. */ let config = { - port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"], - language: "en", - timeFormat: 24, + units: "metric" }; From b3bddb2c990cc0adfd64851428781ba3f4691daa Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Wed, 29 Sep 2021 21:59:22 +0200 Subject: [PATCH 20/20] fix without_modules.js --- tests/configs/without_modules.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/configs/without_modules.js b/tests/configs/without_modules.js index a90115d4..50ff521e 100644 --- a/tests/configs/without_modules.js +++ b/tests/configs/without_modules.js @@ -4,9 +4,7 @@ * MIT Licensed. */ let config = { - ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"], - - units: "metric" + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"] }; /*************** DO NOT EDIT THE LINE BELOW ***************/