diff --git a/tests/configs/modules/newsfeed/default.js b/tests/configs/modules/newsfeed/default.js index 1a112566..160212f1 100644 --- a/tests/configs/modules/newsfeed/default.js +++ b/tests/configs/modules/newsfeed/default.js @@ -3,8 +3,12 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -20,7 +24,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/newsfeed/incorrect_url.js b/tests/configs/modules/newsfeed/incorrect_url.js index ab126aa4..bdaa0341 100644 --- a/tests/configs/modules/newsfeed/incorrect_url.js +++ b/tests/configs/modules/newsfeed/incorrect_url.js @@ -2,8 +2,12 @@ * * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -19,7 +23,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/configs/modules/newsfeed/prohibited_words.js b/tests/configs/modules/newsfeed/prohibited_words.js index f4040557..55c71e29 100644 --- a/tests/configs/modules/newsfeed/prohibited_words.js +++ b/tests/configs/modules/newsfeed/prohibited_words.js @@ -2,8 +2,12 @@ * * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + language: "en", timeFormat: 12, + units: "metric", modules: [ { @@ -21,7 +25,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory( } } ] -}); +}; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") { diff --git a/tests/e2e/modules/newsfeed_spec.js b/tests/e2e/modules/newsfeed_spec.js new file mode 100644 index 00000000..0b2869e2 --- /dev/null +++ b/tests/e2e/modules/newsfeed_spec.js @@ -0,0 +1,63 @@ +const helpers = require("../global-setup"); + +describe("Newsfeed module", function () { + afterAll(function () { + helpers.stopApplication(); + }); + + describe("Default configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/default.js"); + helpers.getDocument(done, 3000); + }); + + it("should show the newsfeed title", function () { + const elem = document.querySelector(".newsfeed .newsfeed-source"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Rodrigo Ramirez Blog"); + }); + + it("should show the newsfeed article", function () { + const elem = document.querySelector(".newsfeed .newsfeed-title"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("QPanel"); + }); + + it("should NOT show the newsfeed description", async () => { + const elem = document.querySelector(".newsfeed .newsfeed-desc"); + expect(elem).toBe(null); + }); + }); + + describe("Custom configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js"); + helpers.getDocument(done, 3000); + }); + + it("should not show articles with prohibited words", function () { + const elem = document.querySelector(".newsfeed .newsfeed-title"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Problema VirtualBox"); + }); + + it("should show the newsfeed description", async () => { + const elem = document.querySelector(".newsfeed .newsfeed-desc"); + expect(elem).not.toBe(null); + expect(elem.textContent.length).not.toBe(0); + }); + }); + + describe("Invalid configuration", function () { + beforeAll(function (done) { + helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js"); + helpers.getDocument(done, 3000); + }); + + it("should show malformed url warning", function () { + const elem = document.querySelector(".newsfeed .small"); + expect(elem).not.toBe(null); + expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url."); + }); + }); +}); diff --git a/tests/electron/modules/newsfeed_spec.js b/tests/electron/modules/newsfeed_spec.js deleted file mode 100644 index fe544a0b..00000000 --- a/tests/electron/modules/newsfeed_spec.js +++ /dev/null @@ -1,67 +0,0 @@ -const helpers = require("../global-setup"); - -describe("Newsfeed module", function () { - helpers.setupTimeout(this); - - let app = null; - - beforeEach(function () { - return helpers - .startApplication({ - args: ["js/electron.js"] - }) - .then(function (startedApp) { - app = startedApp; - }); - }); - - afterEach(function () { - return helpers.stopApplication(app); - }); - - describe("Default configuration", function () { - beforeAll(function () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/default.js"; - }); - - it("should show the newsfeed title", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-source", "Rodrigo Ramirez Blog", 10000); - }); - - it("should show the newsfeed article", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); - }); - - it("should NOT show the newsfeed description", async () => { - await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "QPanel", 10000); - const events = await app.client.$$(".newsfeed .newsfeed-desc"); - return expect(events.length).toBe(0); - }); - }); - - describe("Custom configuration", function () { - beforeAll(function () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/prohibited_words.js"; - }); - - it("should not show articles with prohibited words", function () { - return app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); - }); - - it("should show the newsfeed description", async () => { - await app.client.waitUntilTextExists(".newsfeed .newsfeed-title", "Problema VirtualBox", 10000); - const events = await app.client.$$(".newsfeed .newsfeed-desc"); - return expect(events.length).toBe(1); - }); - }); - - describe("Invalid configuration", function () { - beforeAll(function () { - process.env.MM_CONFIG_FILE = "tests/configs/modules/newsfeed/incorrect_url.js"; - }); - - it("should show malformed url warning", function () { - return app.client.waitUntilTextExists(".newsfeed .small", "Error in the Newsfeed module. Malformed url.", 10000); - }); - }); -});