mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge pull request #2 from QNimbus/activate-test-e2e
Change suggestion for e2e testing
This commit is contained in:
commit
dccfcc9663
@ -10,7 +10,8 @@ before_script:
|
|||||||
- sleep 5
|
- sleep 5
|
||||||
script:
|
script:
|
||||||
- grunt
|
- grunt
|
||||||
- npm run test
|
- npm run test:unit
|
||||||
|
- npm run test:e2e
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
@ -17,7 +17,6 @@ const BrowserWindow = electron.BrowserWindow;
|
|||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
|
|
||||||
var electronOptionsDefaults = {
|
var electronOptionsDefaults = {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
@ -47,7 +46,7 @@ function createWindow() {
|
|||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
// If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
|
// If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
|
||||||
var address = config.address === void 0 | config.address === "" ? config.address = "localhost" : config.address;
|
var address = (config.address === void 0) | (config.address === "") ? (config.address = "localhost") : config.address;
|
||||||
mainWindow.loadURL(`http://${address}:${config.port}`);
|
mainWindow.loadURL(`http://${address}:${config.port}`);
|
||||||
|
|
||||||
// Open the DevTools if run with "npm start dev"
|
// Open the DevTools if run with "npm start dev"
|
||||||
@ -100,7 +99,7 @@ app.on("activate", function() {
|
|||||||
// Start the core application if server is run on localhost
|
// Start the core application if server is run on localhost
|
||||||
// This starts all node helpers and starts the webserver.
|
// This starts all node helpers and starts the webserver.
|
||||||
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) {
|
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) {
|
||||||
core.start(function (c) {
|
core.start(function(c) {
|
||||||
config = c;
|
config = c;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,54 +1,65 @@
|
|||||||
const Application = require("spectron").Application;
|
const helpers = require("./global-setup");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const request = require("request");
|
||||||
const expect = chai.expect;
|
|
||||||
const chaiAsPromised = require("chai-as-promised");
|
|
||||||
|
|
||||||
var electronPath = path.join(__dirname, "../../", "node_modules", ".bin", "electron");
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
const describe = global.describe;
|
||||||
electronPath += ".cmd";
|
const it = global.it;
|
||||||
}
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
var appPath = path.join(__dirname, "../../js/electron.js");
|
|
||||||
|
|
||||||
var app = new Application({
|
|
||||||
path: electronPath
|
|
||||||
});
|
|
||||||
|
|
||||||
global.before(function () {
|
|
||||||
chai.should();
|
|
||||||
chai.use(chaiAsPromised);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Argument 'dev'", function () {
|
|
||||||
this.timeout(20000);
|
|
||||||
|
|
||||||
|
describe("Development console tests", function() {
|
||||||
// This tests fail and crash another tests
|
// This tests fail and crash another tests
|
||||||
|
// Suspect problem with window focus
|
||||||
// FIXME
|
// FIXME
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
describe("Without 'dev' commandline argument", function() {
|
||||||
app.stop().then(function() { done(); });
|
before(function() {
|
||||||
});
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should not open dev console when absent", function () {
|
after(function() {
|
||||||
app.args = [appPath];
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
return app.start().then(function() {
|
it("should not open dev console when absent", function() {
|
||||||
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(false);
|
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should open dev console when provided", function () {
|
describe("With 'dev' commandline argument", function() {
|
||||||
app.args = [appPath, "dev"];
|
before(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js", "dev"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return app.start().then(function() {
|
after(function() {
|
||||||
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should open dev console when provided", function() {
|
||||||
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(true);
|
return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,47 +1,69 @@
|
|||||||
const globalSetup = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const chai = require("chai");
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe("Electron app environment", function () {
|
const expect = require("chai").expect;
|
||||||
this.timeout(20000);
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
|
describe("Electron app environment", function() {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function() {
|
||||||
app.start().then(function() { done(); } );
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function() {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is set to open new app window", function () {
|
it("should open a browserwindow", function() {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client
|
||||||
.getWindowCount().should.eventually.equal(1);
|
.waitUntilWindowLoaded()
|
||||||
|
.browserWindow.focus()
|
||||||
|
.getWindowCount()
|
||||||
|
.should.eventually.equal(1)
|
||||||
|
.browserWindow.isMinimized()
|
||||||
|
.should.eventually.be.false.browserWindow.isDevToolsOpened()
|
||||||
|
.should.eventually.be.false.browserWindow.isVisible()
|
||||||
|
.should.eventually.be.true.browserWindow.isFocused()
|
||||||
|
.should.eventually.be.true.browserWindow.getBounds()
|
||||||
|
.should.eventually.have.property("width")
|
||||||
|
.and.be.above(0)
|
||||||
|
.browserWindow.getBounds()
|
||||||
|
.should.eventually.have.property("height")
|
||||||
|
.and.be.above(0)
|
||||||
|
.browserWindow.getTitle()
|
||||||
|
.should.eventually.equal("Magic Mirror");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets correct window title", function () {
|
it("get request from http://localhost:8080 should return 200", function(done) {
|
||||||
return app.client.waitUntilWindowLoaded()
|
request.get("http://localhost:8080", function(err, res, body) {
|
||||||
.getTitle().should.eventually.equal("Magic Mirror");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
|
||||||
request.get("http://localhost:8080", function (err, res, body) {
|
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.statusCode).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
it("get request from http://localhost:8080/nothing should return 404", function(done) {
|
||||||
request.get("http://localhost:8080/nothing", function (err, res, body) {
|
request.get("http://localhost:8080/nothing", function(err, res, body) {
|
||||||
expect(res.statusCode).to.equal(404);
|
expect(res.statusCode).to.equal(404);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -9,26 +9,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const Application = require("spectron").Application;
|
const Application = require("spectron").Application;
|
||||||
const path = require("path");
|
const assert = require("assert");
|
||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
const chaiAsPromised = require("chai-as-promised");
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
|
||||||
var electronPath = path.join(__dirname, "../../", "node_modules", ".bin", "electron");
|
const path = require("path");
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
global.before(function() {
|
||||||
electronPath += ".cmd";
|
|
||||||
}
|
|
||||||
|
|
||||||
var appPath = path.join(__dirname, "../../js/electron.js");
|
|
||||||
|
|
||||||
var app = new Application({
|
|
||||||
path: electronPath,
|
|
||||||
args: [appPath]
|
|
||||||
});
|
|
||||||
|
|
||||||
global.before(function () {
|
|
||||||
chai.should();
|
chai.should();
|
||||||
chai.use(chaiAsPromised);
|
chai.use(chaiAsPromised);
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.app = app;
|
exports.getElectronPath = function() {
|
||||||
|
var electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron");
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
electronPath += ".cmd";
|
||||||
|
}
|
||||||
|
return electronPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set timeout - if this is run within Travis, increase timeout
|
||||||
|
exports.setupTimeout = function(test) {
|
||||||
|
if (process.env.CI) {
|
||||||
|
test.timeout(30000);
|
||||||
|
} else {
|
||||||
|
test.timeout(10000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.startApplication = function(options) {
|
||||||
|
options.path = exports.getElectronPath();
|
||||||
|
if (process.env.CI) {
|
||||||
|
options.startTimeout = 30000;
|
||||||
|
}
|
||||||
|
|
||||||
|
var app = new Application(options);
|
||||||
|
return app.start().then(function() {
|
||||||
|
assert.equal(app.isRunning(), true);
|
||||||
|
chaiAsPromised.transferPromiseness = app.transferPromiseness;
|
||||||
|
return app;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.stopApplication = function(app) {
|
||||||
|
if (!app || !app.isRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return app.stop().then(function() {
|
||||||
|
assert.equal(app.isRunning(), false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
const globalSetup = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const chai = require("chai");
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
describe("ipWhitelist directive configuration", function () {
|
describe("ipWhitelist directive configuration", function () {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
this.timeout(20000);
|
var app = null;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function () {
|
||||||
app.start().then(function() { done(); } );
|
return helpers.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function () {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Set ipWhitelist without access", function () {
|
describe("Set ipWhitelist without access", function () {
|
||||||
before(function() {
|
before(function () {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
||||||
});
|
});
|
||||||
@ -31,7 +38,7 @@ describe("ipWhitelist directive configuration", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Set ipWhitelist []", function () {
|
describe("Set ipWhitelist []", function () {
|
||||||
before(function() {
|
before(function () {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
||||||
});
|
});
|
||||||
|
@ -1,19 +1,32 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const serverBasicAuth = require("../../servers/basic-auth.js");
|
const path = require("path");
|
||||||
const app = globalSetup.app;
|
const request = require("request");
|
||||||
const chai = require("chai");
|
const serverBasicAuth = require("../../servers/basic-auth.js");
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe("Calendar module", function () {
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
this.timeout(20000);
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
describe("Calendar module", function() {
|
||||||
app.start().then(function() { done(); } );
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function() {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration", function() {
|
describe("Default configuration", function() {
|
||||||
@ -22,12 +35,11 @@ describe("Calendar module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/default.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return TestEvents", function () {
|
it("Should return TestEvents", function() {
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("Basic auth", function() {
|
describe("Basic auth", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
serverBasicAuth.listen(8010);
|
serverBasicAuth.listen(8010);
|
||||||
@ -35,12 +47,15 @@ describe("Calendar module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return TestEvents", function () {
|
after(function(done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return TestEvents", function() {
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("Basic auth by default", function() {
|
describe("Basic auth by default", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
serverBasicAuth.listen(8011);
|
serverBasicAuth.listen(8011);
|
||||||
@ -48,7 +63,11 @@ describe("Calendar module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return TestEvents", function () {
|
after(function(done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return TestEvents", function() {
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -60,7 +79,11 @@ describe("Calendar module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return TestEvents", function () {
|
after(function(done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return TestEvents", function() {
|
||||||
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -72,10 +95,12 @@ describe("Calendar module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/fail-basic-auth.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return No upcoming events", function () {
|
after(function(done) {
|
||||||
|
serverBasicAuth.close(done());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return No upcoming events", function() {
|
||||||
return app.client.waitUntilTextExists(".calendar", "No upcoming events.", 10000);
|
return app.client.waitUntilTextExists(".calendar", "No upcoming events.", 10000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,32 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
|
const request = require("request");
|
||||||
|
|
||||||
describe("Clock set to spanish language module", function () {
|
const expect = require("chai").expect;
|
||||||
this.timeout(20000);
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
|
describe("Clock set to spanish language module", function() {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
describe("with default 24hr clock config", function() {
|
describe("with default 24hr clock config", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
@ -10,24 +34,14 @@ describe("Clock set to spanish language module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_24hr.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
it("shows date with correct format", function() {
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function (done) {
|
|
||||||
app.stop().then(function() { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows date with correct format", function () {
|
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
.getText(".clock .date").should.eventually.match(dateRegex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 24hr format", function() {
|
it("shows time in 24hr format", function() {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,24 +51,14 @@ describe("Clock set to spanish language module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_12hr.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
it("shows date with correct format", function() {
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function (done) {
|
|
||||||
app.stop().then(function() { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows date with correct format", function () {
|
|
||||||
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
.getText(".clock .date").should.eventually.match(dateRegex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 12hr format", function() {
|
it("shows time in 12hr format", function() {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -64,18 +68,9 @@ describe("Clock set to spanish language module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/clock_showPeriodUpper.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/es/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() {
|
it("shows 12hr time with upper case AM/PM", function() {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,32 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
|
const request = require("request");
|
||||||
|
|
||||||
describe("Clock module", function () {
|
const expect = require("chai").expect;
|
||||||
this.timeout(20000);
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
|
describe("Clock module", function() {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
describe("with default 24hr clock config", function() {
|
describe("with default 24hr clock config", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
@ -10,24 +34,14 @@ describe("Clock module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
it("shows date with correct format", function() {
|
||||||
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}$/;
|
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()
|
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
.getText(".clock .date").should.eventually.match(dateRegex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 24hr format", function() {
|
it("shows time in 24hr format", function() {
|
||||||
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,24 +51,14 @@ describe("Clock module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
it("shows date with correct format", function() {
|
||||||
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}$/;
|
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()
|
return app.client.waitUntilWindowLoaded().getText(".clock .date").should.eventually.match(dateRegex);
|
||||||
.getText(".clock .date").should.eventually.match(dateRegex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows time in 12hr format", function() {
|
it("shows time in 12hr format", function() {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -64,18 +68,9 @@ describe("Clock module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
|
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() {
|
it("shows 12hr time with upper case AM/PM", function() {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,18 +80,9 @@ describe("Clock module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function (done) {
|
|
||||||
app.stop().then(function() { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows 12hr time without seconds am/pm", function() {
|
it("shows 12hr time without seconds am/pm", function() {
|
||||||
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .time").should.eventually.match(timeRegex);
|
||||||
.getText(".clock .time").should.eventually.match(timeRegex);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -106,29 +92,17 @@ describe("Clock module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function (done) {
|
|
||||||
app.stop().then(function() { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("shows week with correct format", function() {
|
it("shows week with correct format", function() {
|
||||||
const weekRegex = /^Week [0-9]{1,2}$/;
|
const weekRegex = /^Week [0-9]{1,2}$/;
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".clock .week").should.eventually.match(weekRegex);
|
||||||
.getText(".clock .week").should.eventually.match(weekRegex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows week with correct number of week of year", function() {
|
it("shows week with correct number of week of year", function() {
|
||||||
|
it("FIXME: if the day is a sunday this not match");
|
||||||
it("FIXME: if the day is a sunday this not match");
|
// const currentWeekNumber = require("current-week-number")();
|
||||||
// const currentWeekNumber = require("current-week-number")();
|
// const weekToShow = "Week " + currentWeekNumber;
|
||||||
// const weekToShow = "Week " + currentWeekNumber;
|
// return app.client.waitUntilWindowLoaded()
|
||||||
// return app.client.waitUntilWindowLoaded()
|
// .getText(".clock .week").should.eventually.equal(weekToShow);
|
||||||
// .getText(".clock .week").should.eventually.equal(weekToShow);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,77 +1,81 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const request = require("request");
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe("Compliments module", function () {
|
const expect = require("chai").expect;
|
||||||
this.timeout(20000);
|
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
describe("Compliments module", function() {
|
||||||
app.start().then(function() { done(); } );
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function() {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("parts of days", function() {
|
describe("parts of days", function() {
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Morning compliments for that part of day", function () {
|
it("if Morning compliments for that part of day", function() {
|
||||||
var hour = new Date().getHours();
|
var hour = new Date().getHours();
|
||||||
if (hour >= 3 && hour < 12) {
|
if (hour >= 3 && hour < 12) {
|
||||||
// if morning check
|
// if morning check
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||||
.getText(".compliments").then(function (text) {
|
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
|
||||||
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Afternoon show Compliments for that part of day", function () {
|
it("if Afternoon show Compliments for that part of day", function() {
|
||||||
var hour = new Date().getHours();
|
var hour = new Date().getHours();
|
||||||
if (hour >= 12 && hour < 17) {
|
if (hour >= 12 && hour < 17) {
|
||||||
// if morning check
|
// if morning check
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||||
.getText(".compliments").then(function (text) {
|
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
|
||||||
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if Evening show Compliments for that part of day", function () {
|
it("if Evening show Compliments for that part of day", function() {
|
||||||
var hour = new Date().getHours();
|
var hour = new Date().getHours();
|
||||||
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
||||||
// if evening check
|
// if evening check
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||||
.getText(".compliments").then(function (text) {
|
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
|
||||||
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("Feature anytime in compliments module", function() {
|
describe("Feature anytime in compliments module", function() {
|
||||||
|
|
||||||
describe("Set anytime and empty compliments for morning, evening and afternoon ", function() {
|
describe("Set anytime and empty compliments for morning, evening and afternoon ", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js";
|
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", function () {
|
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", function() {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||||
.getText(".compliments").then(function (text) {
|
expect(text).to.be.oneOf(["Anytime here"]);
|
||||||
expect(text).to.be.oneOf(["Anytime here"]);
|
});
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,15 +85,11 @@ describe("Compliments module", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Show anytime compliments", function () {
|
it("Show anytime compliments", function() {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||||
.getText(".compliments").then(function (text) {
|
expect(text).to.be.oneOf(["Anytime here"]);
|
||||||
expect(text).to.be.oneOf(["Anytime here"]);
|
});
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,39 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
|
const request = require("request");
|
||||||
|
|
||||||
describe("Test helloworld module", function () {
|
const expect = require("chai").expect;
|
||||||
this.timeout(20000);
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
|
describe("Test helloworld module", function() {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/helloworld/helloworld.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
afterEach(function() {
|
||||||
app.start().then(function() { done(); } );
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
it("Test message helloworld module", function() {
|
||||||
app.stop().then(function() { done(); });
|
return app.client.waitUntilWindowLoaded().getText(".helloworld").should.eventually.equal("Test HelloWorld Module");
|
||||||
});
|
|
||||||
|
|
||||||
it("Test message helloworld module", function () {
|
|
||||||
return app.client.waitUntilWindowLoaded()
|
|
||||||
.getText(".helloworld").should.eventually.equal("Test HelloWorld Module");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,27 +1,39 @@
|
|||||||
const globalSetup = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const request = require("request");
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe("Newsfeed module", function () {
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
this.timeout(20000);
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
describe("Newsfeed module", function() {
|
||||||
app.start().then(function() { done(); } );
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
return helpers
|
||||||
|
.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
})
|
||||||
|
.then(function(startedApp) {
|
||||||
|
app = startedApp;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function() {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Default configuration", function() {
|
describe("Default configuration", function() {
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("show title newsfeed", function () {
|
it("show title newsfeed", function() {
|
||||||
return app.client.waitUntilTextExists(".newsfeed .small", "Rodrigo Ramirez Blog", 10000).should.be.fulfilled;
|
return app.client.waitUntilTextExists(".newsfeed .small", "Rodrigo Ramirez Blog", 10000).should.be.fulfilled;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,24 +1,32 @@
|
|||||||
const globalSetup = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const request = require("request");
|
||||||
const expect = chai.expect;
|
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
describe("Position of modules", function () {
|
describe("Position of modules", function () {
|
||||||
this.timeout(20000);
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
|
var app = null;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function () {
|
||||||
app.start().then(function() { done(); } );
|
return helpers.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function () {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Using helloworld", function () {
|
||||||
|
|
||||||
describe("Using helloworld", function() {
|
before(function () {
|
||||||
|
|
||||||
before(function() {
|
|
||||||
// Set config sample for use in test
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/positions.js";
|
||||||
});
|
});
|
||||||
@ -32,7 +40,7 @@ describe("Position of modules", function () {
|
|||||||
for (idx in positions) {
|
for (idx in positions) {
|
||||||
position = positions[idx];
|
position = positions[idx];
|
||||||
className = position.replace("_", ".");
|
className = position.replace("_", ".");
|
||||||
it("show text in " + position , function () {
|
it("show text in " + position, function () {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded()
|
||||||
.getText("." + className).should.eventually.equal("Text in " + position);
|
.getText("." + className).should.eventually.equal("Text in " + position);
|
||||||
});
|
});
|
||||||
|
@ -1,27 +1,35 @@
|
|||||||
const globalSetup = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const chai = require("chai");
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
describe("port directive configuration", function () {
|
describe("port directive configuration", function () {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
this.timeout(20000);
|
var app = null;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function () {
|
||||||
app.start().then(function() { done(); } );
|
return helpers.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function () {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Set port 8090", function () {
|
describe("Set port 8090", function () {
|
||||||
before(function() {
|
before(function () {
|
||||||
// Set config sample for use in this test
|
// Set config sample for use in this test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
request.get("http://localhost:8090", function (err, res, body) {
|
request.get("http://localhost:8090", function (err, res, body) {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.statusCode).to.equal(200);
|
||||||
@ -31,15 +39,16 @@ describe("port directive configuration", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Set port 8100 on enviroment variable MM_PORT", function () {
|
describe("Set port 8100 on enviroment variable MM_PORT", function () {
|
||||||
before(function() {
|
before(function () {
|
||||||
process.env.MM_PORT = 8100;
|
process.env.MM_PORT = 8100;
|
||||||
// Set config sample for use in this test
|
// Set config sample for use in this test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function(){
|
after(function () {
|
||||||
delete process.env.MM_PORT;
|
delete process.env.MM_PORT;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
request.get("http://localhost:8100", function (err, res, body) {
|
request.get("http://localhost:8100", function (err, res, body) {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.statusCode).to.equal(200);
|
||||||
|
@ -1,34 +1,38 @@
|
|||||||
const globalSetup = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const app = globalSetup.app;
|
const path = require("path");
|
||||||
const request = require("request");
|
const request = require("request");
|
||||||
const chai = require("chai");
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
describe("Vendors", function () {
|
describe("Vendors", function () {
|
||||||
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
this.timeout(20000);
|
var app = null;
|
||||||
|
|
||||||
// FIXME: This test fail in Travis
|
beforeEach(function () {
|
||||||
return true;
|
return helpers.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
beforeEach(function (done) {
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function () {
|
||||||
app.stop().then(function() { done(); });
|
return helpers.stopApplication(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Get list vendors", function () {
|
describe("Get list vendors", function () {
|
||||||
|
|
||||||
before(function() {
|
before(function () {
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
var vendors = require(__dirname + "/../../vendor/vendor.js");
|
var vendors = require(__dirname + "/../../vendor/vendor.js");
|
||||||
Object.keys(vendors).forEach(vendor => {
|
Object.keys(vendors).forEach(vendor => {
|
||||||
it(`should return 200 HTTP code for vendor "${vendor}"`, function() {
|
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
|
||||||
urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
|
urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
|
||||||
request.get(urlVendor, function (err, res, body) {
|
request.get(urlVendor, function (err, res, body) {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.statusCode).to.equal(200);
|
||||||
|
@ -1,44 +1,34 @@
|
|||||||
const Application = require("spectron").Application;
|
const helpers = require("./global-setup");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const request = require("request");
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
|
const describe = global.describe;
|
||||||
|
const it = global.it;
|
||||||
|
const beforeEach = global.beforeEach;
|
||||||
|
const afterEach = global.afterEach;
|
||||||
|
|
||||||
describe("Check configuration without modules", function () {
|
describe("Check configuration without modules", function () {
|
||||||
this.timeout(20000);
|
helpers.setupTimeout(this);
|
||||||
|
|
||||||
before(function() {
|
var app = null;
|
||||||
// Set config sample for use in test
|
|
||||||
|
beforeEach(function () {
|
||||||
|
return helpers.startApplication({
|
||||||
|
args: ["js/electron.js"]
|
||||||
|
}).then(function (startedApp) { app = startedApp; })
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
return helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
// Set config sample for use in test
|
||||||
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
|
||||||
app.start().then(function() { done(); } );
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function (done) {
|
|
||||||
app.stop().then(function() { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Show the message MagicMirror title", function () {
|
it("Show the message MagicMirror title", function () {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded()
|
||||||
.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2")
|
.getText("#module_1_helloworld .module-content").should.eventually.equal("Magic Mirror2")
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
var http = require("http");
|
var http = require("http");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var auth = require("http-auth");
|
var auth = require("http-auth");
|
||||||
var express = require("express")
|
var express = require("express");
|
||||||
|
var app = express();
|
||||||
|
|
||||||
var basic = auth.basic({
|
var server;
|
||||||
realm: "MagicMirror Area restricted."
|
|
||||||
}, (username, password, callback) => {
|
|
||||||
callback(username === "MagicMirror" && password === "CallMeADog");
|
|
||||||
});
|
|
||||||
|
|
||||||
this.server = express();
|
var basic = auth.basic(
|
||||||
this.server.use(auth.connect(basic));
|
{
|
||||||
|
realm: "MagicMirror Area restricted."
|
||||||
|
},
|
||||||
|
(username, password, callback) => {
|
||||||
|
callback(username === "MagicMirror" && password === "CallMeADog");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
app.use(auth.connect(basic));
|
||||||
|
|
||||||
// Set directories availables
|
// Set directories availables
|
||||||
var directories = ["/tests/configs"];
|
var directories = ["/tests/configs"];
|
||||||
@ -18,13 +23,13 @@ var directory;
|
|||||||
rootPath = path.resolve(__dirname + "/../../");
|
rootPath = path.resolve(__dirname + "/../../");
|
||||||
for (i in directories) {
|
for (i in directories) {
|
||||||
directory = directories[i];
|
directory = directories[i];
|
||||||
this.server.use(directory, express.static(path.resolve(rootPath + directory)));
|
app.use(directory, express.static(path.resolve(rootPath + directory)));
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.listen = function () {
|
exports.listen = function() {
|
||||||
this.server.listen.apply(this.server, arguments);
|
server = app.listen.apply(app, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.close = function (callback) {
|
exports.close = function(callback) {
|
||||||
this.server.close(callback);
|
server.close(callback);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user