mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Merge pull request #674 from morozgrafix/test_branch
Restructured Test Suite
This commit is contained in:
commit
b02920c43c
@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Show the splash screen image even when is reboot or halted.
|
- Show the splash screen image even when is reboot or halted.
|
||||||
- Added some missing translaton strings in the sv.json file.
|
- Added some missing translaton strings in the sv.json file.
|
||||||
- Run task jsonlint to check translation files.
|
- Run task jsonlint to check translation files.
|
||||||
|
- Restructured Test Suite
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added Docker support (Pull Request [#673](https://github.com/MichMich/MagicMirror/pull/673))
|
- Added Docker support (Pull Request [#673](https://github.com/MichMich/MagicMirror/pull/673))
|
||||||
@ -39,6 +40,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Add test e2e helloworld
|
- Add test e2e helloworld
|
||||||
- Add test e2e enviroment
|
- Add test e2e enviroment
|
||||||
- Add `chai-as-promised` npm module to devDependencies
|
- Add `chai-as-promised` npm module to devDependencies
|
||||||
|
- Basic set of tests for clock module
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Update .gitignore to not ignore default modules folder.
|
- Update .gitignore to not ignore default modules folder.
|
||||||
|
@ -37,7 +37,7 @@ var Server = function(config, callback) {
|
|||||||
app.use("/modules", express.static(path.resolve(global.root_path + "/modules")));
|
app.use("/modules", express.static(path.resolve(global.root_path + "/modules")));
|
||||||
app.use("/vendor", express.static(path.resolve(global.root_path + "/vendor")));
|
app.use("/vendor", express.static(path.resolve(global.root_path + "/vendor")));
|
||||||
app.use("/translations", express.static(path.resolve(global.root_path + "/translations")));
|
app.use("/translations", express.static(path.resolve(global.root_path + "/translations")));
|
||||||
app.use("/tests/confs", express.static(path.resolve(global.root_path + "/tests/confs")));
|
app.use("/tests/configs", express.static(path.resolve(global.root_path + "/tests/configs")));
|
||||||
|
|
||||||
app.get("/version", function(req,res) {
|
app.get("/version", function(req,res) {
|
||||||
res.send(global.version);
|
res.send(global.version);
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "sh run-start.sh",
|
"start": "sh run-start.sh",
|
||||||
"postinstall": "sh installers/postinstall/postinstall.sh",
|
"postinstall": "sh installers/postinstall/postinstall.sh",
|
||||||
"test": "./node_modules/mocha/bin/mocha $(find tests -path '*js*' ! -ipath '*e2e*')",
|
"test": "./node_modules/mocha/bin/mocha tests/unit --recursive",
|
||||||
|
"test:unit": "./node_modules/mocha/bin/mocha tests/unit --recursive",
|
||||||
"test:e2e": "./node_modules/mocha/bin/mocha tests/e2e --recursive"
|
"test:e2e": "./node_modules/mocha/bin/mocha tests/e2e --recursive"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
29
tests/configs/modules/clock/clock_12hr.js
Normal file
29
tests/configs/modules/clock/clock_12hr.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* Magic Mirror Test config for default clock module
|
||||||
|
*
|
||||||
|
* By Sergey Morozov
|
||||||
|
* MIT Licensed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||||
|
|
||||||
|
language: "en",
|
||||||
|
timeFormat: 12,
|
||||||
|
units: "metric",
|
||||||
|
electronOptions: {
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "clock",
|
||||||
|
position: "middle_center"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {module.exports = config;}
|
29
tests/configs/modules/clock/clock_24hr.js
Normal file
29
tests/configs/modules/clock/clock_24hr.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* Magic Mirror Test config for default clock module
|
||||||
|
*
|
||||||
|
* By Sergey Morozov
|
||||||
|
* MIT Licensed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||||
|
|
||||||
|
language: "en",
|
||||||
|
timeFormat: 24,
|
||||||
|
units: "metric",
|
||||||
|
electronOptions: {
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "clock",
|
||||||
|
position: "middle_center"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {module.exports = config;}
|
32
tests/configs/modules/clock/clock_showPeriodUpper.js
Normal file
32
tests/configs/modules/clock/clock_showPeriodUpper.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* Magic Mirror Test config for default clock module
|
||||||
|
*
|
||||||
|
* By Sergey Morozov
|
||||||
|
* MIT Licensed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||||
|
|
||||||
|
language: "en",
|
||||||
|
timeFormat: 12,
|
||||||
|
units: "metric",
|
||||||
|
electronOptions: {
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
module: "clock",
|
||||||
|
position: "middle_center",
|
||||||
|
config: {
|
||||||
|
showPeriodUpper: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
|
if (typeof module !== "undefined") {module.exports = config;}
|
@ -3,9 +3,6 @@ const path = require("path");
|
|||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
const chaiAsPromised = require("chai-as-promised");
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/confs/env.js";
|
|
||||||
|
|
||||||
var electronPath = path.join(__dirname, "../../", "node_modules", ".bin", "electron");
|
var electronPath = path.join(__dirname, "../../", "node_modules", ".bin", "electron");
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@ -24,9 +21,14 @@ global.before(function () {
|
|||||||
chai.use(chaiAsPromised);
|
chai.use(chaiAsPromised);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Test enviroment app electron", function () {
|
describe("Electron app environment", function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
app.start().then(function() { done(); } );
|
app.start().then(function() { done(); } );
|
||||||
});
|
});
|
||||||
@ -36,12 +38,12 @@ describe("Test enviroment app electron", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("open a window app and test if is open", function () {
|
it("is set to open new app window", function () {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded()
|
||||||
.getWindowCount().should.eventually.equal(1);
|
.getWindowCount().should.eventually.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("tests the title", function () {
|
it("sets correct window title", function () {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded()
|
||||||
.getTitle().should.eventually.equal("Magic Mirror");
|
.getTitle().should.eventually.equal("Magic Mirror");
|
||||||
});
|
});
|
103
tests/e2e/modules/clock_spec.js
Normal file
103
tests/e2e/modules/clock_spec.js
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
const Application = require("spectron").Application;
|
||||||
|
const path = require("path");
|
||||||
|
const chai = require("chai");
|
||||||
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var electronPath = path.join(__dirname, "../../../", "node_modules", ".bin", "electron");
|
||||||
|
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
electronPath += ".cmd";
|
||||||
|
}
|
||||||
|
|
||||||
|
var appPath = path.join(__dirname, "../../../js/electron.js");
|
||||||
|
|
||||||
|
var app = new Application({
|
||||||
|
path: electronPath,
|
||||||
|
args: [appPath]
|
||||||
|
});
|
||||||
|
|
||||||
|
global.before(function () {
|
||||||
|
chai.should();
|
||||||
|
chai.use(chaiAsPromised);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Clock module", function () {
|
||||||
|
this.timeout(10000);
|
||||||
|
|
||||||
|
describe("with default 24hr clock config", function() {
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function (done) {
|
||||||
|
app.start().then(function() { done(); } );
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
app.stop().then(function() { done(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows date with 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}$/;
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows time in 24hr format", function() {
|
||||||
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("with default 12hr clock config", function() {
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function (done) {
|
||||||
|
app.start().then(function() { done(); } );
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
app.stop().then(function() { done(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows date with 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}$/;
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows time in 12hr format", function() {
|
||||||
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("with showPeriodUpper config enabled", function() {
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(function (done) {
|
||||||
|
app.start().then(function() { done(); } );
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function (done) {
|
||||||
|
app.stop().then(function() { done(); });
|
||||||
|
});
|
||||||
|
|
||||||
|
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$/;
|
||||||
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -3,8 +3,7 @@ const path = require("path");
|
|||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
const chaiAsPromised = require("chai-as-promised");
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
|
||||||
// Set config sample for use in test
|
|
||||||
process.env.MM_CONFIG_FILE = "tests/confs/helloworld.js";
|
|
||||||
|
|
||||||
var electronPath = path.join(__dirname, "../../../", "node_modules", ".bin", "electron");
|
var electronPath = path.join(__dirname, "../../../", "node_modules", ".bin", "electron");
|
||||||
|
|
||||||
@ -27,6 +26,11 @@ global.before(function () {
|
|||||||
describe("Test helloworld module", function () {
|
describe("Test helloworld module", function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
// Set config sample for use in test
|
||||||
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js";
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
app.start().then(function() { done(); } );
|
app.start().then(function() { done(); } );
|
||||||
});
|
});
|
@ -1,7 +1,7 @@
|
|||||||
var chai = require("chai");
|
var chai = require("chai");
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
var classMM = require("../../js/class.js"); // require for load module.js
|
var classMM = require("../../../js/class.js"); // require for load module.js
|
||||||
var moduleMM = require("../../js/module.js")
|
var moduleMM = require("../../../js/module.js")
|
||||||
|
|
||||||
describe("Test function cmpVersions in js/module.js", function() {
|
describe("Test function cmpVersions in js/module.js", function() {
|
||||||
|
|
@ -3,8 +3,8 @@ var path = require("path");
|
|||||||
var chai = require("chai");
|
var chai = require("chai");
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
|
|
||||||
describe("Test global.root_path, set in js/app.js", function() {
|
describe("'global.root_path' set in js/app.js", function() {
|
||||||
var appMM = require("../../js/app.js")
|
var appMM = require("../../../js/app.js")
|
||||||
|
|
||||||
var expectedSubPaths = [
|
var expectedSubPaths = [
|
||||||
"modules",
|
"modules",
|
||||||
@ -17,7 +17,7 @@ describe("Test global.root_path, set in js/app.js", function() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
expectedSubPaths.forEach(subpath => {
|
expectedSubPaths.forEach(subpath => {
|
||||||
it(`should contain a file/folder "${subpath}"`, function() {
|
it(`contains a file/folder "${subpath}"`, function() {
|
||||||
expect(fs.existsSync(path.join(global.root_path, subpath))).to.equal(true);
|
expect(fs.existsSync(path.join(global.root_path, subpath))).to.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user