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