Skip to content

Commit

Permalink
Merge pull request #2454 from rejas/cleanup_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichMich authored Feb 13, 2021
2 parents 89152e5 + bdc4ed4 commit e3bee5a
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/configs/modules/calendar/auth-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/modules/calendar/basic-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 44 additions & 0 deletions tests/configs/modules/calendar/changed-port.js
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion tests/configs/modules/calendar/old-basic-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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;
});
Expand All @@ -56,6 +56,6 @@ exports.stopApplication = function (app) {
}

return app.stop().then(function () {
assert.equal(app.isRunning(), false);
assert.strictEqual(app.isRunning(), false);
});
};
25 changes: 13 additions & 12 deletions tests/e2e/modules/calendar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -92,15 +92,21 @@ describe("Calendar module", function () {
});
});

describe("Basic auth by default", function () {
describe("Basic auth", 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";
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/basic-auth.js";
});

after(function (done) {
serverBasicAuth.close(done());
it("should return TestEvents", function () {
return app.client.waitUntilTextExists(".calendar", "TestEvent", 10000);
});
});

describe("Basic auth by default", function () {
before(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/calendar/auth-default.js";
});

it("should return TestEvents", function () {
Expand All @@ -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);
});
Expand Down
14 changes: 3 additions & 11 deletions tests/e2e/modules/weather_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/vendor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit e3bee5a

Please sign in to comment.