MagicMirror/tests/e2e/modules/newsfeed_spec.js

78 lines
2.5 KiB
JavaScript
Raw Normal View History

const helpers = require("../helpers/global-setup");
2021-09-26 00:06:06 +02:00
describe("Newsfeed module", () => {
afterAll(async () => {
await helpers.stopApplication();
2021-09-26 00:06:06 +02:00
});
describe("Default configuration", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/default.js");
await helpers.getDocument();
2021-09-26 00:06:06 +02:00
});
it("should show the newsfeed title", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-source");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
2021-09-26 00:06:06 +02:00
});
it("should show the newsfeed article", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("QPanel");
2021-09-26 00:06:06 +02:00
});
it("should NOT show the newsfeed description", async () => {
await helpers.waitForElement(".newsfeed");
const element = document.querySelector(".newsfeed .newsfeed-desc");
expect(element).toBe(null);
2021-09-26 00:06:06 +02:00
});
});
describe("Custom configuration", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
await helpers.getDocument();
2021-09-26 00:06:06 +02:00
});
it("should not show articles with prohibited words", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Problema VirtualBox");
2021-09-26 00:06:06 +02:00
});
it("should show the newsfeed description", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-desc");
expect(elem).not.toBe(null);
expect(elem.textContent.length).not.toBe(0);
2021-09-26 00:06:06 +02:00
});
});
describe("Invalid configuration", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
await helpers.getDocument();
2021-09-26 00:06:06 +02:00
});
it("should show malformed url warning", async () => {
const elem = await helpers.waitForElement(".newsfeed .small", "No news at the moment.");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
2021-09-26 00:06:06 +02:00
});
});
2021-12-20 13:35:50 +01:00
describe("Ignore items", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
await helpers.getDocument();
2021-12-20 13:35:50 +01:00
});
it("should show empty items info message", async () => {
const elem = await helpers.waitForElement(".newsfeed .small");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("No news at the moment.");
2021-12-20 13:35:50 +01:00
});
});
2021-09-26 00:06:06 +02:00
});