diff --git a/CHANGELOG.md b/CHANGELOG.md index f22622f1..0c8e29a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ _This release is scheduled to be released on 2021-04-01._ - Moving weather provider specific code and configuration into each provider and making hourly part of the interface. - Bump electron to v11. - Dont update the DOM when a module is not displayed. -- Cleaned up jsdoc. +- Cleaned up jsdoc and tests. ### Removed diff --git a/tests/configs/modules/calendar/auth-default.js b/tests/configs/modules/calendar/auth-default.js index 0cb29184..dd65c53e 100644 --- a/tests/configs/modules/calendar/auth-default.js +++ b/tests/configs/modules/calendar/auth-default.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8011/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "CallMeADog" diff --git a/tests/configs/modules/calendar/basic-auth.js b/tests/configs/modules/calendar/basic-auth.js index 706e14ca..8937b2a3 100644 --- a/tests/configs/modules/calendar/basic-auth.js +++ b/tests/configs/modules/calendar/basic-auth.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8010/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "CallMeADog", diff --git a/tests/configs/modules/calendar/changed-port.js b/tests/configs/modules/calendar/changed-port.js new file mode 100644 index 00000000..fa0f7ae7 --- /dev/null +++ b/tests/configs/modules/calendar/changed-port.js @@ -0,0 +1,44 @@ +/* Magic Mirror Test config default calendar with auth by default + * + * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com + * 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, + enableRemoteModule: true + } + }, + + modules: [ + { + module: "calendar", + position: "bottom_bar", + config: { + calendars: [ + { + maximumNumberOfDays: 10000, + url: "http://localhost:8010/tests/configs/data/calendar_test.ics", + auth: { + user: "MagicMirror", + pass: "CallMeADog" + } + } + ] + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/configs/modules/calendar/old-basic-auth.js b/tests/configs/modules/calendar/old-basic-auth.js index e34954d5..fa7b70f3 100644 --- a/tests/configs/modules/calendar/old-basic-auth.js +++ b/tests/configs/modules/calendar/old-basic-auth.js @@ -26,7 +26,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8012/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", user: "MagicMirror", pass: "CallMeADog" } diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index cce9fc05..ed6217d3 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -20,7 +20,7 @@ global.before(function () { }); exports.getElectronPath = function () { - var electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron"); + let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron"); if (process.platform === "win32") { electronPath += ".cmd"; } @@ -42,9 +42,9 @@ exports.startApplication = function (options) { options.startTimeout = 30000; } - var app = new Application(options); + const app = new Application(options); return app.start().then(function () { - assert.equal(app.isRunning(), true); + assert.strictEqual(app.isRunning(), true); chaiAsPromised.transferPromiseness = app.transferPromiseness; return app; }); @@ -56,6 +56,6 @@ exports.stopApplication = function (app) { } return app.stop().then(function () { - assert.equal(app.isRunning(), false); + assert.strictEqual(app.isRunning(), false); }); }; diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index 3712871c..8d9b0c5a 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -76,11 +76,11 @@ describe("Calendar module", function () { }); }); - describe("Basic auth", function () { + describe("Changed port", function () { before(function () { serverBasicAuth.listen(8010); // Set config sample for use in test - process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js"; + process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/changed-port.js"; }); after(function (done) { @@ -92,17 +92,23 @@ describe("Calendar module", function () { }); }); + describe("Basic auth", function () { + before(function () { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js"; + }); + + it("should return TestEvents", function () { + return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); + }); + }); + describe("Basic auth by default", function () { before(function () { - serverBasicAuth.listen(8011); // Set config sample for use in test process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js"; }); - after(function (done) { - serverBasicAuth.close(done()); - }); - it("should return TestEvents", function () { return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); }); @@ -110,15 +116,10 @@ describe("Calendar module", function () { describe("Basic auth backward compatibility configuration: DEPRECATED", function () { before(function () { - serverBasicAuth.listen(8012); // Set config sample for use in test process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/old-basic-auth.js"; }); - after(function (done) { - serverBasicAuth.close(done()); - }); - it("should return TestEvents", function () { return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000); }); diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index 4b0944d3..cd386f3c 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -15,7 +15,8 @@ describe("Weather module", function () { async function setup(responses) { app = await helpers.startApplication({ - args: ["js/electron.js"] + args: ["js/electron.js"], + waitTimeout: 100000 }); wdajaxstub.init(app.client, responses); @@ -101,16 +102,7 @@ describe("Weather module", function () { const weather = generateWeather(); await setup({ template, data: weather }); - const wait = (time) => new Promise((resolve) => setTimeout(resolve, time)); - - var text = ""; - do { - await wait(3000); - elem = await app.client.$(".compliments"); - text = await elem.getText(".compliments .module-content span"); - } while (text === ""); - - return expect(text.trim()).to.equal("snow"); + return app.client.waitUntilTextExists(".compliments .module-content span", "snow"); }); }); diff --git a/tests/e2e/vendor_spec.js b/tests/e2e/vendor_spec.js index 206ee2ea..bc318b2e 100644 --- a/tests/e2e/vendor_spec.js +++ b/tests/e2e/vendor_spec.js @@ -28,7 +28,7 @@ describe("Vendors", function () { }); describe("Get list vendors", function () { - var vendors = require(__dirname + "/../../vendor/vendor.js"); + const vendors = require(__dirname + "/../../vendor/vendor.js"); Object.keys(vendors).forEach((vendor) => { it(`should return 200 HTTP code for vendor "${vendor}"`, function () { var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];