mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Merge pull request #2670 from khassel/new-e2e
This commit is contained in:
1
.github/workflows/automated-tests.yml
vendored
1
.github/workflows/automated-tests.yml
vendored
@@ -28,6 +28,7 @@ jobs:
|
|||||||
Xvfb :99 -screen 0 1024x768x16 &
|
Xvfb :99 -screen 0 1024x768x16 &
|
||||||
export DISPLAY=:99
|
export DISPLAY=:99
|
||||||
npm install
|
npm install
|
||||||
|
touch css/custom.css
|
||||||
npm run test:prettier
|
npm run test:prettier
|
||||||
npm run test:js
|
npm run test:js
|
||||||
npm run test:css
|
npm run test:css
|
||||||
|
1
.github/workflows/codecov-test-suites.yml
vendored
1
.github/workflows/codecov-test-suites.yml
vendored
@@ -20,6 +20,7 @@ jobs:
|
|||||||
Xvfb :99 -screen 0 1024x768x16 &
|
Xvfb :99 -screen 0 1024x768x16 &
|
||||||
export DISPLAY=:99
|
export DISPLAY=:99
|
||||||
npm ci
|
npm ci
|
||||||
|
touch css/custom.css
|
||||||
npm run test:coverage
|
npm run test:coverage
|
||||||
- name: Upload coverage results to codecov
|
- name: Upload coverage results to codecov
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
|
@@ -27,7 +27,7 @@ _This release is scheduled to be released on 2021-10-01._
|
|||||||
- Refactored methods from weatherproviders into weatherobject (isDaytime, updateSunTime).
|
- Refactored methods from weatherproviders into weatherobject (isDaytime, updateSunTime).
|
||||||
- Use of `logger.js` in jest tests.
|
- Use of `logger.js` in jest tests.
|
||||||
- Run prettier over all relevant files.
|
- Run prettier over all relevant files.
|
||||||
- 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.
|
||||||
- Update dependencies in package.json.
|
- Update dependencies in package.json.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
11
js/logger.js
11
js/logger.js
@@ -24,7 +24,16 @@
|
|||||||
}
|
}
|
||||||
})(this, function (config) {
|
})(this, function (config) {
|
||||||
let logLevel;
|
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 !== "jsdom";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableLog) {
|
||||||
logLevel = {
|
logLevel = {
|
||||||
debug: Function.prototype.bind.call(console.debug, console),
|
debug: Function.prototype.bind.call(console.debug, console),
|
||||||
log: Function.prototype.bind.call(console.log, console),
|
log: Function.prototype.bind.call(console.log, console),
|
||||||
|
11
js/server.js
11
js/server.js
@@ -23,6 +23,7 @@ const Utils = require("./utils.js");
|
|||||||
*/
|
*/
|
||||||
function Server(config, callback) {
|
function Server(config, callback) {
|
||||||
const port = process.env.MM_PORT || config.port;
|
const port = process.env.MM_PORT || config.port;
|
||||||
|
const serverSockets = new Set();
|
||||||
|
|
||||||
let server = null;
|
let server = null;
|
||||||
if (config.useHttps) {
|
if (config.useHttps) {
|
||||||
@@ -42,6 +43,13 @@ function Server(config, callback) {
|
|||||||
allowEIO3: true
|
allowEIO3: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("connection", (socket) => {
|
||||||
|
serverSockets.add(socket);
|
||||||
|
socket.on("close", () => {
|
||||||
|
serverSockets.delete(socket);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Log.log(`Starting server on port ${port} ... `);
|
Log.log(`Starting server on port ${port} ... `);
|
||||||
|
|
||||||
server.listen(port, config.address || "localhost");
|
server.listen(port, config.address || "localhost");
|
||||||
@@ -94,6 +102,9 @@ function Server(config, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.close = function () {
|
this.close = function () {
|
||||||
|
for (const socket of serverSockets.values()) {
|
||||||
|
socket.destroy();
|
||||||
|
}
|
||||||
server.close();
|
server.close();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -120,6 +120,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "e2e",
|
"displayName": "e2e",
|
||||||
|
"setupFilesAfterEnv": [
|
||||||
|
"<rootDir>/tests/e2e/mock-console.js"
|
||||||
|
],
|
||||||
"testMatch": [
|
"testMatch": [
|
||||||
"**/tests/e2e/**/*.[jt]s?(x)"
|
"**/tests/e2e/**/*.[jt]s?(x)"
|
||||||
],
|
],
|
||||||
@@ -127,7 +130,8 @@
|
|||||||
"<rootDir>/js/"
|
"<rootDir>/js/"
|
||||||
],
|
],
|
||||||
"testPathIgnorePatterns": [
|
"testPathIgnorePatterns": [
|
||||||
"<rootDir>/tests/e2e/global-setup.js"
|
"<rootDir>/tests/e2e/global-setup.js",
|
||||||
|
"<rootDir>/tests/e2e/mock-console.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -6,12 +6,6 @@
|
|||||||
exports.configFactory = function (options) {
|
exports.configFactory = function (options) {
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{
|
{
|
||||||
port: 8080,
|
|
||||||
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
|
||||||
|
|
||||||
language: "en",
|
|
||||||
timeFormat: 24,
|
|
||||||
units: "metric",
|
|
||||||
electronOptions: {
|
electronOptions: {
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By rejas
|
* By rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "alert",
|
module: "alert",
|
||||||
@@ -13,7 +13,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Sergey Morozov
|
* By Sergey Morozov
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -12,7 +12,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
position: "middle_center"
|
position: "middle_center"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
* By Sergey Morozov
|
* By Sergey Morozov
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "clock",
|
module: "clock",
|
||||||
position: "middle_center"
|
position: "middle_center"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "clock",
|
module: "clock",
|
||||||
@@ -13,7 +13,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -15,7 +15,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Sergey Morozov
|
* By Sergey Morozov
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -15,7 +15,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Johan Hammar
|
* By Johan Hammar
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -15,7 +15,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Johan Hammar
|
* By Johan Hammar
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -15,7 +15,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
language: "es",
|
language: "es",
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
position: "middle_center"
|
position: "middle_center"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
language: "es",
|
language: "es",
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -12,7 +12,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
position: "middle_center"
|
position: "middle_center"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
language: "es",
|
language: "es",
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
language: "es",
|
language: "es",
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rejas
|
* By Rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -21,7 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -17,7 +17,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -19,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rejas
|
* By Rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "helloworld",
|
module: "helloworld",
|
||||||
@@ -21,11 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
config.electronOptions.fullscreen = false;
|
|
||||||
config.electronOptions.width = 800;
|
|
||||||
config.electronOptions.height = 600;
|
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "helloworld",
|
module: "helloworld",
|
||||||
@@ -13,7 +13,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "helloworld",
|
module: "helloworld",
|
||||||
position: "bottom_bar"
|
position: "bottom_bar"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -19,7 +19,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
timeFormat: 12,
|
timeFormat: 12,
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
@@ -21,7 +21,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
modules:
|
modules:
|
||||||
// Using exotic content. This is why don't accept go to JSON configuration file
|
// Using exotic content. This is why don't accept go to JSON configuration file
|
||||||
(function () {
|
(function () {
|
||||||
@@ -20,7 +20,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
return modules;
|
return modules;
|
||||||
})()
|
})()
|
||||||
});
|
};
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -3,10 +3,9 @@
|
|||||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"]
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.10.1"]
|
||||||
});
|
};
|
||||||
delete config.modules;
|
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("Electron app environment", function () {
|
describe("Electron app environment", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function (done) {
|
||||||
app = helpers.startApplication("tests/configs/env.js");
|
helpers.startApplication("tests/configs/default.js");
|
||||||
|
helpers.getDocument(done);
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||||
@@ -23,4 +23,10 @@ describe("Electron app environment", function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should show the title MagicMirror²", function () {
|
||||||
|
const elem = document.querySelector("title");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toBe("MagicMirror²");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("All font files from roboto.css should be downloadable", function () {
|
describe("All font files from roboto.css should be downloadable", function () {
|
||||||
const fontFiles = [];
|
const fontFiles = [];
|
||||||
@@ -16,10 +15,10 @@ describe("All font files from roboto.css should be downloadable", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
app = helpers.startApplication("tests/configs/without_modules.js");
|
helpers.startApplication("tests/configs/without_modules.js");
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||||
|
@@ -1,16 +1,32 @@
|
|||||||
|
const jsdom = require("jsdom");
|
||||||
|
|
||||||
exports.startApplication = function (configFilename, exec) {
|
exports.startApplication = function (configFilename, exec) {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
if (global.app) {
|
||||||
|
global.app.stop();
|
||||||
|
}
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = configFilename;
|
process.env.MM_CONFIG_FILE = configFilename;
|
||||||
if (exec) exec;
|
if (exec) exec;
|
||||||
const app = require("app.js");
|
global.app = require("app.js");
|
||||||
app.start();
|
global.app.start();
|
||||||
|
|
||||||
return app;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.stopApplication = function (app) {
|
exports.stopApplication = function () {
|
||||||
if (app) {
|
if (global.app) {
|
||||||
app.stop();
|
global.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.name = "jsdom";
|
||||||
|
dom.window.onload = function () {
|
||||||
|
global.document = dom.window.document;
|
||||||
|
setTimeout(() => {
|
||||||
|
callback();
|
||||||
|
}, ms);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("ipWhitelist directive configuration", function () {
|
describe("ipWhitelist directive configuration", function () {
|
||||||
describe("Set ipWhitelist without access", function () {
|
describe("Set ipWhitelist without access", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
app = helpers.startApplication("tests/configs/noIpWhiteList.js");
|
helpers.startApplication("tests/configs/noIpWhiteList.js");
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 403", function (done) {
|
it("should return 403", function (done) {
|
||||||
@@ -21,10 +20,10 @@ describe("ipWhitelist directive configuration", function () {
|
|||||||
|
|
||||||
describe("Set ipWhitelist []", function () {
|
describe("Set ipWhitelist []", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
app = helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
|
21
tests/e2e/mock-console.js
Normal file
21
tests/e2e/mock-console.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Suppresses errors concerning web server already shut down.
|
||||||
|
*
|
||||||
|
* @param {string} err The error message.
|
||||||
|
*/
|
||||||
|
function mockError(err) {
|
||||||
|
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) {
|
||||||
|
jest.fn();
|
||||||
|
} else {
|
||||||
|
console.dir(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global.console = {
|
||||||
|
log: jest.fn(),
|
||||||
|
dir: console.dir,
|
||||||
|
error: mockError,
|
||||||
|
warn: console.warn,
|
||||||
|
info: jest.fn(),
|
||||||
|
debug: console.debug
|
||||||
|
};
|
17
tests/e2e/modules/alert_spec.js
Normal file
17
tests/e2e/modules/alert_spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
|
describe("Alert module", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/alert/default.js");
|
||||||
|
helpers.getDocument(done, 1000);
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
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!");
|
||||||
|
});
|
||||||
|
});
|
71
tests/e2e/modules/clock_es_spec.js
Normal file
71
tests/e2e/modules/clock_es_spec.js
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
116
tests/e2e/modules/clock_spec.js
Normal file
116
tests/e2e/modules/clock_spec.js
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
88
tests/e2e/modules/compliments_spec.js
Normal file
88
tests/e2e/modules/compliments_spec.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
const helpers = require("../global-setup");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* move similar tests in function doTest
|
||||||
|
*
|
||||||
|
* @param {Array} complimentsArray The array of compliments.
|
||||||
|
*/
|
||||||
|
function doTest(complimentsArray) {
|
||||||
|
let elem = document.querySelector(".compliments");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
elem = document.querySelector(".module-content");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(complimentsArray).toContain(elem.textContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("Compliments module", function () {
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("parts of days", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
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) {
|
||||||
|
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", function () {
|
||||||
|
doTest(["Anytime here"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Only anytime present in configuration compliments", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
|
||||||
|
helpers.getDocument(done, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Show anytime compliments", 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) {
|
||||||
|
helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
|
||||||
|
helpers.getDocument(done, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Show happy new year compliment on new years day", function () {
|
||||||
|
doTest(["Happy new year!"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
33
tests/e2e/modules/helloworld_spec.js
Normal file
33
tests/e2e/modules/helloworld_spec.js
Normal file
@@ -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", 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", function () {
|
||||||
|
const elem = document.querySelector(".helloworld");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toContain("Hello World!");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
63
tests/e2e/modules/newsfeed_spec.js
Normal file
63
tests/e2e/modules/newsfeed_spec.js
Normal file
@@ -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", () => {
|
||||||
|
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", () => {
|
||||||
|
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.");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
24
tests/e2e/modules_display_spec.js
Normal file
24
tests/e2e/modules_display_spec.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
|
describe("Display of modules", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/display.js");
|
||||||
|
helpers.getDocument(done);
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show the test header", function () {
|
||||||
|
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 () {
|
||||||
|
const elem = document.querySelector("#module_1_helloworld .module-header");
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toBe("undefined");
|
||||||
|
});
|
||||||
|
});
|
22
tests/e2e/modules_position_spec.js
Normal file
22
tests/e2e/modules_position_spec.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
|
describe("Position of modules", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/modules/positions.js");
|
||||||
|
helpers.getDocument(done, 1000);
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
|
||||||
|
|
||||||
|
for (const position of positions) {
|
||||||
|
const className = position.replace("_", ".");
|
||||||
|
it("should show text in " + position, function () {
|
||||||
|
const elem = document.querySelector("." + className);
|
||||||
|
expect(elem).not.toBe(null);
|
||||||
|
expect(elem.textContent).toContain("Text in " + position);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@@ -1,14 +1,13 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("port directive configuration", function () {
|
describe("port directive configuration", function () {
|
||||||
describe("Set port 8090", function () {
|
describe("Set port 8090", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
app = helpers.startApplication("tests/configs/port_8090.js");
|
helpers.startApplication("tests/configs/port_8090.js");
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
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 () {
|
describe("Set port 8100 on environment variable MM_PORT", function () {
|
||||||
beforeAll(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 () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
let app = null;
|
|
||||||
|
|
||||||
describe("Vendors", function () {
|
describe("Vendors", function () {
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
app = helpers.startApplication("tests/configs/env.js");
|
helpers.startApplication("tests/configs/default.js");
|
||||||
});
|
});
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
helpers.stopApplication(app);
|
helpers.stopApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get list vendors", function () {
|
describe("Get list vendors", function () {
|
||||||
|
23
tests/e2e/without_modules.js
Normal file
23
tests/e2e/without_modules.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const helpers = require("./global-setup");
|
||||||
|
|
||||||
|
describe("Check configuration without modules", function () {
|
||||||
|
beforeAll(function (done) {
|
||||||
|
helpers.startApplication("tests/configs/without_modules.js");
|
||||||
|
helpers.getDocument(done, 1000);
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
});
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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!");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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("");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@@ -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");
|
|
||||||
});
|
|
||||||
});
|
|
Reference in New Issue
Block a user