From 5aa7097a6ecea0d325bd557229894e2a4649c039 Mon Sep 17 00:00:00 2001 From: rejas Date: Sat, 1 Aug 2020 12:20:16 +0200 Subject: [PATCH] Add test for displaying the header --- tests/configs/modules/display.js | 42 +++++++++++++++++++++++++++++++ tests/e2e/modules_display_spec.js | 41 ++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 tests/configs/modules/display.js create mode 100644 tests/e2e/modules_display_spec.js diff --git a/tests/configs/modules/display.js b/tests/configs/modules/display.js new file mode 100644 index 00000000..6550becc --- /dev/null +++ b/tests/configs/modules/display.js @@ -0,0 +1,42 @@ +/* Magic Mirror Test config for display setters module using the helloworld module + * + * MIT Licensed. + */ +var config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 24, + units: "metric", + electronOptions: { + fullscreen: false, + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true + } + }, + + modules: [ + { + module: "helloworld", + position: "top_bar", + header: "test_header", + config: { + text: "Test Display Header" + } + }, + { + module: "helloworld", + position: "bottom_bar", + config: { + text: "Test Hide Header" + } + } + ] +}; +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js new file mode 100644 index 00000000..9497c60b --- /dev/null +++ b/tests/e2e/modules_display_spec.js @@ -0,0 +1,41 @@ +const helpers = require("./global-setup"); + +const describe = global.describe; +const it = global.it; + +describe("Display of modules", 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("Using helloworld", function () { + before(function () { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/display.js"; + }); + + it("should show the test header", async () => { + await app.client.waitForExist("#module_0_helloworld", 10000); + return app.client.element("#module_0_helloworld .module-header").isVisible().should.eventually.equal(true).getText("#module_0_helloworld .module-header").should.eventually.equal("TEST_HEADER"); + }); + + it("should show no header if no header text is specified", async () => { + await app.client.waitForExist("#module_1_helloworld", 10000); + return app.client.element("#module_1_helloworld .module-header").isVisible().should.eventually.equal(false); + }); + }); +});