From b46160bcbcc8a545c3d9c343f857b759bfe7504c Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:20:16 +0100 Subject: [PATCH 1/6] Simplify weather-compliments test, increase timeWaitout for it --- tests/e2e/modules/weather_spec.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) 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"); }); }); From dbea348779aba476b78ab226d31c3cfd8b58fce2 Mon Sep 17 00:00:00 2001 From: veeck Date: Wed, 6 Jan 2021 12:41:52 +0100 Subject: [PATCH 2/6] Cleanup port usage in tests --- tests/configs/modules/calendar/auth-default.js | 2 +- tests/configs/modules/calendar/basic-auth.js | 2 +- tests/configs/modules/calendar/fail-basic-auth.js | 2 +- tests/configs/modules/calendar/old-basic-auth.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/fail-basic-auth.js b/tests/configs/modules/calendar/fail-basic-auth.js index 7ccb8bce..b5856589 100644 --- a/tests/configs/modules/calendar/fail-basic-auth.js +++ b/tests/configs/modules/calendar/fail-basic-auth.js @@ -28,7 +28,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8020/tests/configs/data/calendar_test.ics", + url: "http://localhost:8080/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "StairwayToHeaven", 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" } From 68bc77c81e6f28dfd8f614d1d4949c50b651af76 Mon Sep 17 00:00:00 2001 From: rejas Date: Fri, 5 Feb 2021 22:41:23 +0100 Subject: [PATCH 3/6] Cleanup global-setup code --- tests/e2e/global-setup.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); }); }; From efec49bb475e20962f0c1d0df47f72b49e9ccc22 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:22:03 +0100 Subject: [PATCH 4/6] Use es6 notations --- tests/e2e/vendor_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; From 35f3b315a2370d25c2ddeda52b73a7f948bf70c8 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 21:22:56 +0100 Subject: [PATCH 5/6] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From bdc4ed4d864a149863d6e9d001595b8a7d5ebdd1 Mon Sep 17 00:00:00 2001 From: rejas Date: Thu, 11 Feb 2021 22:18:51 +0100 Subject: [PATCH 6/6] Add specific change-port test and fix the others --- .../configs/modules/calendar/changed-port.js | 44 +++++++++++++++++++ .../modules/calendar/fail-basic-auth.js | 2 +- tests/e2e/modules/calendar_spec.js | 25 ++++++----- 3 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 tests/configs/modules/calendar/changed-port.js 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/fail-basic-auth.js b/tests/configs/modules/calendar/fail-basic-auth.js index b5856589..7ccb8bce 100644 --- a/tests/configs/modules/calendar/fail-basic-auth.js +++ b/tests/configs/modules/calendar/fail-basic-auth.js @@ -28,7 +28,7 @@ var config = { calendars: [ { maximumNumberOfDays: 10000, - url: "http://localhost:8080/tests/configs/data/calendar_test.ics", + url: "http://localhost:8020/tests/configs/data/calendar_test.ics", auth: { user: "MagicMirror", pass: "StairwayToHeaven", 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); });