Release 2.22.0 (#2983)

## [2.22.0] - 2023-01-01

Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @Tom.

Special thanks to @khassel, @rejas and @sdetweil for taking over most
(if not all) of the work on this release as project collaborators. This
version would not be there without their effort. Thank you!

### Added

- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"

### Removed

- Removed usage of internal fetch function of node until it is more
stable

### Updated

- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
  - Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
  - Reworked how weatherproviders handle units (#2849)
  - Use unix() method for parsing times, fix suntimes on the way (#2950)
  - Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `…` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)

### Fixed

- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Malte Hallström <46646495+SkySails@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: dWoolridge <dwoolridge@charter.net>
Co-authored-by: Johan <jojjepersson@yahoo.se>
Co-authored-by: Dario Mratovich <dario_mratovich@hotmail.com>
Co-authored-by: Dario Mratovich <dario.mratovich@outlook.com>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: buxxi <buxxi@omfilm.net>
Co-authored-by: Thomas Hirschberger <47733292+Tom-Hirschberger@users.noreply.github.com>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Andrés Vanegas Jiménez <142350+angeldeejay@users.noreply.github.com>
This commit is contained in:
Michael Teeuw
2023-01-01 18:09:08 +01:00
committed by GitHub
parent 9e0293047f
commit 0300ce05d5
151 changed files with 5890 additions and 4949 deletions

View File

@@ -1,19 +1,17 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Alert module", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/alert/default.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/alert/default.js");
await helpers.getDocument();
});
afterAll(async () => {
await helpers.stopApplication();
});
it("should show the welcome message", (done) => {
helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Welcome, start was successful!");
});
it("should show the welcome message", async () => {
const elem = await helpers.waitForElement(".ns-box .ns-box-inner .light.bright.small");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Welcome, start was successful!");
});
});

View File

@@ -1,29 +0,0 @@
const path = require("path");
const auth = require("express-basic-auth");
const express = require("express");
const app = express();
const basicAuth = auth({
realm: "MagicMirror² Area restricted.",
users: { MagicMirror: "CallMeADog" }
});
app.use(basicAuth);
// Set available directories
const directories = ["/tests/configs"];
const rootPath = path.resolve(__dirname + "/../../../");
for (let directory of directories) {
app.use(directory, express.static(path.resolve(rootPath + directory)));
}
let server;
exports.listen = function () {
server = app.listen.apply(app, arguments);
};
exports.close = function (callback) {
server.close(callback);
};

View File

@@ -1,31 +1,26 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("./basic-auth.js");
const helpers = require("../helpers/global-setup");
const serverBasicAuth = require("../helpers/basic-auth.js");
describe("Calendar module", () => {
/**
* @param {string} done test done
* @param {string} element css selector
* @param {string} result expected number
* @param {string} not reverse result
*/
const testElementLength = (done, element, result, not) => {
helpers.waitForAllElements(element).then((elem) => {
done();
expect(elem).not.toBe(null);
if (not === "not") {
expect(elem.length).not.toBe(result);
} else {
expect(elem.length).toBe(result);
}
});
const testElementLength = async (element, result, not) => {
const elem = await helpers.waitForAllElements(element);
expect(elem).not.toBe(null);
if (not === "not") {
expect(elem.length).not.toBe(result);
} else {
expect(elem.length).toBe(result);
}
};
const testTextContain = (done, element, text) => {
helpers.waitForElement(element, "undefinedLoading").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain(text);
});
const testTextContain = async (element, text) => {
const elem = await helpers.waitForElement(element, "undefinedLoading");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain(text);
};
afterAll(async () => {
@@ -33,133 +28,133 @@ describe("Calendar module", () => {
});
describe("Default configuration", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/default.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/default.js");
await helpers.getDocument();
});
it("should show the default maximumEntries of 10", (done) => {
testElementLength(done, ".calendar .event", 10);
it("should show the default maximumEntries of 10", async () => {
await testElementLength(".calendar .event", 10);
});
it("should show the default calendar symbol in each event", (done) => {
testElementLength(done, ".calendar .event .fa-calendar-alt", 0, "not");
it("should show the default calendar symbol in each event", async () => {
await testElementLength(".calendar .event .fa-calendar-alt", 0, "not");
});
});
describe("Custom configuration", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/custom.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/custom.js");
await helpers.getDocument();
});
it("should show the custom maximumEntries of 4", (done) => {
testElementLength(done, ".calendar .event", 4);
it("should show the custom maximumEntries of 4", async () => {
await testElementLength(".calendar .event", 4);
});
it("should show the custom calendar symbol in each event", (done) => {
testElementLength(done, ".calendar .event .fa-birthday-cake", 4);
it("should show the custom calendar symbol in each event", async () => {
await testElementLength(".calendar .event .fa-birthday-cake", 4);
});
it("should show two custom icons for repeating events", (done) => {
testElementLength(done, ".calendar .event .fa-undo", 2);
it("should show two custom icons for repeating events", async () => {
await testElementLength(".calendar .event .fa-undo", 2);
});
it("should show two custom icons for day events", (done) => {
testElementLength(done, ".calendar .event .fa-calendar-day", 2);
it("should show two custom icons for day events", async () => {
await testElementLength(".calendar .event .fa-calendar-day", 2);
});
});
describe("Recurring event", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/recurring.js");
await helpers.getDocument();
});
it("should show the recurring birthday event 6 times", (done) => {
testElementLength(done, ".calendar .event", 6);
it("should show the recurring birthday event 6 times", async () => {
await testElementLength(".calendar .event", 6);
});
});
process.setMaxListeners(0);
for (let i = -12; i < 12; i++) {
describe("Recurring event per timezone", () => {
beforeAll((done) => {
beforeAll(async () => {
Date.prototype.getTimezoneOffset = () => {
return i * 60;
};
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
helpers.getDocument(done);
await helpers.startApplication("tests/configs/modules/calendar/recurring.js");
await helpers.getDocument();
});
it('should contain text "Mar 25th" in timezone UTC ' + -i, (done) => {
testTextContain(done, ".calendar", "Mar 25th");
it('should contain text "Mar 25th" in timezone UTC ' + -i, async () => {
await testTextContain(".calendar", "Mar 25th");
});
});
}
describe("Changed port", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
serverBasicAuth.listen(8010);
helpers.getDocument(done);
await helpers.getDocument();
});
afterAll((done) => {
serverBasicAuth.close(done());
afterAll(async () => {
await serverBasicAuth.close();
});
it("should return TestEvents", (done) => {
testElementLength(done, ".calendar .event", 0, "not");
it("should return TestEvents", async () => {
await testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
await helpers.getDocument();
});
it("should return TestEvents", (done) => {
testElementLength(done, ".calendar .event", 0, "not");
it("should return TestEvents", async () => {
await testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth by default", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
await helpers.getDocument();
});
it("should return TestEvents", (done) => {
testElementLength(done, ".calendar .event", 0, "not");
it("should return TestEvents", async () => {
await testElementLength(".calendar .event", 0, "not");
});
});
describe("Basic auth backward compatibility configuration: DEPRECATED", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
await helpers.getDocument();
});
it("should return TestEvents", (done) => {
testElementLength(done, ".calendar .event", 0, "not");
it("should return TestEvents", async () => {
await testElementLength(".calendar .event", 0, "not");
});
});
describe("Fail Basic auth", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
serverBasicAuth.listen(8020);
helpers.getDocument(done);
await helpers.getDocument();
});
afterAll((done) => {
serverBasicAuth.close(done());
afterAll(async () => {
await serverBasicAuth.close();
});
it("should show Unauthorized error", (done) => {
testTextContain(done, ".calendar", "Error in the calendar module. Authorization failed");
it("should show Unauthorized error", async () => {
await testTextContain(".calendar", "Error in the calendar module. Authorization failed");
});
});
});

View File

@@ -1,73 +1,65 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Clock set to spanish language module", () => {
afterAll(async () => {
await helpers.stopApplication();
});
const testMatch = (done, element, regex) => {
helpers.waitForElement(element).then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toMatch(regex);
});
};
describe("with default 24hr clock config", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_24hr.js");
await helpers.getDocument();
});
it("shows date with correct format", (done) => {
it("shows date with correct format", async () => {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
testMatch(done, ".clock .date", dateRegex);
await helpers.testMatch(".clock .date", dateRegex);
});
it("shows time in 24hr format", (done) => {
it("shows time in 24hr format", async () => {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with default 12hr clock config", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_12hr.js");
await helpers.getDocument();
});
it("shows date with correct format", (done) => {
it("shows date with correct format", async () => {
const dateRegex = /^(?:lunes|martes|miércoles|jueves|viernes|sábado|domingo), \d{1,2} de (?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre) de \d{4}$/;
testMatch(done, ".clock .date", dateRegex);
await helpers.testMatch(".clock .date", dateRegex);
});
it("shows time in 12hr format", (done) => {
it("shows time in 12hr format", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with showPeriodUpper config enabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_showPeriodUpper.js");
await helpers.getDocument();
});
it("shows 12hr time with upper case AM/PM", (done) => {
it("shows 12hr time with upper case AM/PM", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with showWeek config enabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek.js");
await helpers.getDocument();
});
it("shows week with correct format", (done) => {
it("shows week with correct format", async () => {
const weekRegex = /^Semana [0-9]{1,2}$/;
testMatch(done, ".clock .week", weekRegex);
await helpers.testMatch(".clock .week", weekRegex);
});
});
});

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
const moment = require("moment");
describe("Clock module", () => {
@@ -6,118 +6,105 @@ describe("Clock module", () => {
await helpers.stopApplication();
});
const testMatch = (done, element, regex) => {
helpers.waitForElement(element).then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toMatch(regex);
});
};
describe("with default 24hr clock config", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_24hr.js");
await helpers.getDocument();
});
it("should show the date in the correct format", (done) => {
it("should show the date in the correct format", async () => {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
testMatch(done, ".clock .date", dateRegex);
await helpers.testMatch(".clock .date", dateRegex);
});
it("should show the time in 24hr format", (done) => {
it("should show the time in 24hr format", async () => {
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with default 12hr clock config", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_12hr.js");
await helpers.getDocument();
});
it("should show the date in the correct format", (done) => {
it("should show the date in the correct format", async () => {
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
testMatch(done, ".clock .date", dateRegex);
await helpers.testMatch(".clock .date", dateRegex);
});
it("should show the time in 12hr format", (done) => {
it("should show the time in 12hr format", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with showPeriodUpper config enabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showPeriodUpper.js");
await helpers.getDocument();
});
it("should show 12hr time with upper case AM/PM", (done) => {
it("should show 12hr time with upper case AM/PM", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with displaySeconds config disabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_displaySeconds_false.js");
await helpers.getDocument();
});
it("should show 12hr time without seconds am/pm", (done) => {
it("should show 12hr time without seconds am/pm", async () => {
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/;
testMatch(done, ".clock .time", timeRegex);
await helpers.testMatch(".clock .time", timeRegex);
});
});
describe("with showTime config disabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showTime.js");
await helpers.getDocument();
});
it("should not show the time when digital clock is shown", (done) => {
const elem = document.querySelector(".clock .digital .time");
done();
it("should not show the time when digital clock is shown", async () => {
const elem = await document.querySelector(".clock .digital .time");
expect(elem).toBe(null);
});
});
describe("with showWeek config enabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showWeek.js");
await helpers.getDocument();
});
it("should show the week in the correct format", (done) => {
it("should show the week in the correct format", async () => {
const weekRegex = /^Week [0-9]{1,2}$/;
testMatch(done, ".clock .week", weekRegex);
await helpers.testMatch(".clock .week", weekRegex);
});
it("should show the week with the correct number of week of year", (done) => {
it("should show the week with the correct number of week of year", async () => {
const currentWeekNumber = moment().week();
const weekToShow = "Week " + currentWeekNumber;
helpers.waitForElement(".clock .week").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toBe(weekToShow);
});
const elem = await helpers.waitForElement(".clock .week");
expect(elem).not.toBe(null);
expect(elem.textContent).toBe(weekToShow);
});
});
describe("with analog clock face enabled", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
await helpers.getDocument();
});
it("should show the analog clock face", (done) => {
helpers.waitForElement(".clockCircle").then((elem) => {
done();
expect(elem).not.toBe(null);
});
it("should show the analog clock face", async () => {
const elem = helpers.waitForElement(".clockCircle");
expect(elem).not.toBe(null);
});
});
});

View File

@@ -1,98 +1,55 @@
const helpers = require("../global-setup");
/**
* move similar tests in function doTest
*
* @param {string} done test done
* @param {Array} complimentsArray The array of compliments.
*/
const doTest = (done, complimentsArray) => {
helpers.waitForElement(".compliments").then((elem) => {
expect(elem).not.toBe(null);
helpers.waitForElement(".module-content").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(complimentsArray).toContain(elem.textContent);
});
});
};
const helpers = require("../helpers/global-setup");
describe("Compliments module", () => {
/**
* move similar tests in function doTest
*
* @param {Array} complimentsArray The array of compliments.
*/
const doTest = async (complimentsArray) => {
let elem = await helpers.waitForElement(".compliments");
expect(elem).not.toBe(null);
elem = await helpers.waitForElement(".module-content");
expect(elem).not.toBe(null);
expect(complimentsArray).toContain(elem.textContent);
};
afterAll(async () => {
await helpers.stopApplication();
});
describe("parts of days", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js");
helpers.getDocument(done);
});
it("if Morning compliments for that part of day", (done) => {
const hour = new Date().getHours();
if (hour >= 3 && hour < 12) {
// if morning check
doTest(done, ["Hi", "Good Morning", "Morning test"]);
} else {
done();
}
});
it("if Afternoon show Compliments for that part of day", (done) => {
const hour = new Date().getHours();
if (hour >= 12 && hour < 17) {
// if afternoon check
doTest(done, ["Hello", "Good Afternoon", "Afternoon test"]);
} else {
done();
}
});
it("if Evening show Compliments for that part of day", (done) => {
const hour = new Date().getHours();
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
// if evening check
doTest(done, ["Hello There", "Good Evening", "Evening test"]);
} else {
done();
}
});
});
describe("Feature anytime in compliments module", () => {
describe("Set anytime and empty compliments for morning, evening and afternoon ", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js");
await helpers.getDocument();
});
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", (done) => {
doTest(done, ["Anytime here"]);
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async () => {
await doTest(["Anytime here"]);
});
});
describe("Only anytime present in configuration compliments", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js");
await helpers.getDocument();
});
it("Show anytime compliments", (done) => {
doTest(done, ["Anytime here"]);
it("Show anytime compliments", async () => {
await doTest(["Anytime here"]);
});
});
});
describe("Feature date in compliments module", () => {
describe("Set date and empty compliments for anytime, morning, evening and afternoon", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/compliments/compliments_date.js");
helpers.getDocument(done);
});
describe("remoteFile option", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/compliments/compliments_remote.js");
await helpers.getDocument();
});
it("Show happy new year compliment on new years day", (done) => {
doTest(done, ["Happy new year!"]);
});
it("should show compliments from a remote file", async () => {
await doTest(["Remote compliment file works!"]);
});
});
});

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Test helloworld module", () => {
afterAll(async () => {
@@ -6,32 +6,28 @@ describe("Test helloworld module", () => {
});
describe("helloworld set config text", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/helloworld/helloworld.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/helloworld/helloworld.js");
await helpers.getDocument();
});
it("Test message helloworld module", (done) => {
helpers.waitForElement(".helloworld").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Test HelloWorld Module");
});
it("Test message helloworld module", async () => {
const elem = await helpers.waitForElement(".helloworld");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Test HelloWorld Module");
});
});
describe("helloworld default config text", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/helloworld/helloworld_default.js");
await helpers.getDocument();
});
it("Test message helloworld module", (done) => {
helpers.waitForElement(".helloworld").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Hello World!");
});
it("Test message helloworld module", async () => {
const elem = await helpers.waitForElement(".helloworld");
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Hello World!");
});
});
});

View File

@@ -1,4 +0,0 @@
const generateWeather = require("./weather_current");
const generateWeatherForecast = require("./weather_forecast");
module.exports = { generateWeather, generateWeatherForecast };

View File

@@ -1,64 +0,0 @@
const _ = require("lodash");
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked current weather data
*/
function generateWeather(extendedData = {}) {
return JSON.stringify(
_.merge(
{},
{
coord: {
lon: 11.58,
lat: 48.14
},
weather: [
{
id: 615,
main: "Snow",
description: "light rain and snow",
icon: "13d"
},
{
id: 500,
main: "Rain",
description: "light rain",
icon: "10d"
}
],
base: "stations",
main: {
temp: 1.49,
pressure: 1005,
humidity: 93.7,
temp_min: 1,
temp_max: 2
},
visibility: 7000,
wind: {
speed: 11.8,
deg: 250
},
clouds: {
all: 75
},
dt: 1547387400,
sys: {
type: 1,
id: 1267,
message: 0.0031,
country: "DE",
sunrise: 1547362817,
sunset: 1547394301
},
id: 2867714,
name: "Munich",
cod: 200
},
extendedData
)
);
}
module.exports = generateWeather;

View File

@@ -1,115 +0,0 @@
const _ = require("lodash");
/**
* @param {object} extendedData extra data to add to the default mock data
* @returns {string} mocked forecast weather data
*/
function generateWeatherForecast(extendedData = {}) {
return JSON.stringify(
_.merge(
{},
{
city: {
id: 2867714,
name: "Munich",
coord: { lon: 11.5754, lat: 48.1371 },
country: "DE",
population: 1260391,
timezone: 7200
},
cod: "200",
message: 0.9653487,
cnt: 7,
list: [
{
dt: 1568372400,
sunrise: 1568350044,
sunset: 1568395948,
temp: { day: 24.44, min: 15.35, max: 24.44, night: 15.35, eve: 18, morn: 23.03 },
pressure: 1031.65,
humidity: 70,
weather: [{ id: 801, main: "Clouds", description: "few clouds", icon: "02d" }],
speed: 3.35,
deg: 314,
clouds: 21
},
{
dt: 1568458800,
sunrise: 1568436525,
sunset: 1568482223,
temp: { day: 20.81, min: 13.56, max: 21.02, night: 13.56, eve: 16.6, morn: 15.88 },
pressure: 1028.81,
humidity: 72,
weather: [{ id: 500, main: "Rain", description: "light rain", icon: "10d" }],
speed: 2.21,
deg: 81,
clouds: 100
},
{
dt: 1568545200,
sunrise: 1568523007,
sunset: 1568568497,
temp: { day: 22.65, min: 13.76, max: 22.88, night: 15.27, eve: 17.45, morn: 13.76 },
pressure: 1023.75,
humidity: 64,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 1.15,
deg: 7,
clouds: 0
},
{
dt: 1568631600,
sunrise: 1568609489,
sunset: 1568654771,
temp: { day: 23.45, min: 13.95, max: 23.45, night: 13.95, eve: 17.75, morn: 15.21 },
pressure: 1020.41,
humidity: 64,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 3.07,
deg: 298,
clouds: 7
},
{
dt: 1568718000,
sunrise: 1568695970,
sunset: 1568741045,
temp: { day: 20.55, min: 10.95, max: 20.55, night: 10.95, eve: 14.82, morn: 13.24 },
pressure: 1019.4,
humidity: 66,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.8,
deg: 333,
clouds: 2
},
{
dt: 1568804400,
sunrise: 1568782452,
sunset: 1568827319,
temp: { day: 18.15, min: 7.75, max: 18.15, night: 7.75, eve: 12.45, morn: 9.41 },
pressure: 1017.56,
humidity: 52,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.92,
deg: 34,
clouds: 0
},
{
dt: 1568890800,
sunrise: 1568868934,
sunset: 1568913593,
temp: { day: 14.85, min: 5.56, max: 15.05, night: 5.56, eve: 9.56, morn: 6.25 },
pressure: 1022.7,
humidity: 59,
weather: [{ id: 800, main: "Clear", description: "sky is clear", icon: "01d" }],
speed: 2.89,
deg: 51,
clouds: 1
}
]
},
extendedData
)
);
}
module.exports = generateWeatherForecast;

View File

@@ -1,4 +1,4 @@
const helpers = require("../global-setup");
const helpers = require("../helpers/global-setup");
describe("Newsfeed module", () => {
afterAll(async () => {
@@ -6,86 +6,72 @@ describe("Newsfeed module", () => {
});
describe("Default configuration", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/default.js");
await helpers.getDocument();
});
it("should show the newsfeed title", (done) => {
helpers.waitForElement(".newsfeed .newsfeed-source").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
});
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");
});
it("should show the newsfeed article", (done) => {
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("QPanel");
});
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");
});
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);
});
it("should NOT show the newsfeed description", async () => {
await helpers.waitForElement(".newsfeed");
const element = document.querySelector(".newsfeed .newsfeed-desc");
expect(element).toBe(null);
});
});
describe("Custom configuration", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
await helpers.getDocument();
});
it("should not show articles with prohibited words", (done) => {
helpers.waitForElement(".newsfeed .newsfeed-title").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Problema VirtualBox");
});
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");
});
it("should show the newsfeed description", (done) => {
helpers.waitForElement(".newsfeed .newsfeed-desc").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent.length).not.toBe(0);
});
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);
});
});
describe("Invalid configuration", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
await helpers.getDocument();
});
it("should show malformed url warning", (done) => {
helpers.waitForElement(".newsfeed .small", "No news at the moment.").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
});
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.");
});
});
describe("Ignore items", () => {
beforeAll((done) => {
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
helpers.getDocument(done);
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
await helpers.getDocument();
});
it("should show empty items info message", (done) => {
helpers.waitForElement(".newsfeed .small").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.textContent).toContain("No news at the moment.");
});
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.");
});
});
});

View File

@@ -0,0 +1,84 @@
const helpers = require("../helpers/global-setup");
const weatherFunc = require("../helpers/weather-functions");
describe("Weather module", () => {
afterAll(async () => {
await helpers.stopApplication();
});
describe("Current weather", () => {
describe("Default configuration", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_default.js", {});
});
it("should render wind speed and wind direction", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "12 WSW");
});
it("should render temperature with icon", async () => {
await weatherFunc.getText(".weather .large.light span.bright", "1.5°");
});
it("should render feels like temperature", async () => {
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
});
});
});
describe("Compliments Integration", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_compliments.js", {});
});
it("should render a compliment based on the current weather", async () => {
await weatherFunc.getText(".compliments .module-content span", "snow");
});
});
describe("Configuration Options", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_options.js", {});
});
it("should render windUnits in beaufort", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "6");
});
it("should render windDirection with an arrow", async () => {
const elem = await helpers.waitForElement(".weather .normal.medium sup i.fa-long-arrow-alt-up");
expect(elem).not.toBe(null);
expect(elem.outerHTML).toContain("transform:rotate(250deg);");
});
it("should render humidity", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(3)", "93.7");
});
it("should render degreeLabel for temp", async () => {
await weatherFunc.getText(".weather .large.light span.bright", "1°C");
});
it("should render degreeLabel for feels like", async () => {
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
});
});
describe("Current weather with imperial units", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/currentweather_units.js", {});
});
it("should render wind in imperial units", async () => {
await weatherFunc.getText(".weather .normal.medium span:nth-child(2)", "26 WSW");
});
it("should render temperatures in fahrenheit", async () => {
await weatherFunc.getText(".weather .large.light span.bright", "34,7°");
});
it("should render 'feels like' in fahrenheit", async () => {
await weatherFunc.getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 21,9°");
});
});
});

View File

@@ -0,0 +1,96 @@
const helpers = require("../helpers/global-setup");
const weatherFunc = require("../helpers/weather-functions");
describe("Weather module: Weather Forecast", () => {
afterAll(async () => {
await helpers.stopApplication();
});
describe("Default configuration", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/forecastweather_default.js", {});
});
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it("should render day " + day, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
});
}
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
for (const [index, icon] of icons.entries()) {
it("should render icon " + icon, async () => {
const elem = await helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`);
expect(elem).not.toBe(null);
});
}
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
for (const [index, temp] of maxTemps.entries()) {
it("should render max temperature " + temp, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
});
}
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
for (const [index, temp] of minTemps.entries()) {
it("should render min temperature " + temp, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
});
}
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
for (const [index, opacity] of opacities.entries()) {
it("should render fading of rows with opacity=" + opacity, async () => {
const elem = await helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1})`);
expect(elem).not.toBe(null);
expect(elem.outerHTML).toContain(`<tr style="opacity: ${opacity};">`);
});
}
});
describe("Absolute configuration", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/forecastweather_absolute.js", {});
});
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it("should render day " + day, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
});
}
});
describe("Configuration Options", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/forecastweather_options.js", {});
});
it("should render custom table class", async () => {
const elem = await helpers.waitForElement(".weather table.myTableClass");
expect(elem).not.toBe(null);
});
it("should render colored rows", async () => {
const table = await helpers.waitForElement(".weather table.myTableClass");
expect(table).not.toBe(null);
expect(table.rows).not.toBe(null);
expect(table.rows.length).toBe(5);
});
});
describe("Forecast weather units", () => {
beforeAll(async () => {
await weatherFunc.startApp("tests/configs/modules/weather/forecastweather_units.js", {});
});
const temperatures = ["75_9°", "69_8°", "73_2°", "74_1°", "69_1°"];
for (const [index, temp] of temperatures.entries()) {
it("should render custom decimalSymbol = '_' for temp " + temp, async () => {
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
});
}
});
});

View File

@@ -1,273 +0,0 @@
const moment = require("moment");
const helpers = require("../global-setup");
const path = require("path");
const fs = require("fs");
const { generateWeather, generateWeatherForecast } = require("./mocks");
describe("Weather module", () => {
/**
* @param {string} done test done
* @param {string} element css selector
* @param {string} result Expected text in given selector
*/
const getText = (done, element, result) => {
helpers.waitForElement(element).then((elem) => {
done();
expect(elem).not.toBe(null);
expect(
elem.textContent
.trim()
.replace(/(\r\n|\n|\r)/gm, "")
.replace(/[ ]+/g, " ")
).toBe(result);
});
};
/**
* @param {string} configFile path to configuration file
* @param {string} additionalMockData special data for mocking
* @param {string} callback callback
*/
const startApp = (configFile, additionalMockData, callback) => {
let mockWeather;
if (configFile.includes("forecast")) {
mockWeather = generateWeatherForecast(additionalMockData);
} else {
mockWeather = generateWeather(additionalMockData);
}
let content = fs.readFileSync(path.resolve(__dirname + "../../../../" + configFile)).toString();
content = content.replace("#####WEATHERDATA#####", mockWeather);
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content);
helpers.startApplication("");
helpers.getDocument(callback);
};
afterAll(async () => {
await helpers.stopApplication();
});
describe("Current weather", () => {
describe("Default configuration", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/currentweather_default.js", {}, done);
});
it("should render wind speed and wind direction", (done) => {
getText(done, ".weather .normal.medium span:nth-child(2)", "6 WSW"); // now "12"
});
it("should render temperature with icon", (done) => {
getText(done, ".weather .large.light span.bright", "1.5°"); // now "1°C"
});
it("should render feels like temperature", (done) => {
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°"); // now "Feels like -6°C"
});
});
describe("Default configuration with sunrise", () => {
beforeAll((done) => {
const sunrise = moment().startOf("day").unix();
const sunset = moment().startOf("day").unix();
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
});
it("should render sunrise", (done) => {
getText(done, ".weather .normal.medium span:nth-child(4)", "12:00 am");
});
});
describe("Default configuration with sunset", () => {
beforeAll((done) => {
const sunrise = moment().startOf("day").unix();
const sunset = moment().endOf("day").unix();
startApp("tests/configs/modules/weather/currentweather_default.js", { sys: { sunrise, sunset } }, done);
});
it("should render sunset", (done) => {
getText(done, ".weather .normal.medium span:nth-child(4)", "11:59 pm");
});
});
});
describe("Compliments Integration", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/currentweather_compliments.js", {}, done);
});
it("should render a compliment based on the current weather", (done) => {
getText(done, ".compliments .module-content span", "snow");
});
});
describe("Configuration Options", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/currentweather_options.js", {}, done);
});
it("should render useBeaufort = false", (done) => {
getText(done, ".weather .normal.medium span:nth-child(2)", "12");
});
it("should render showWindDirectionAsArrow = true", (done) => {
helpers.waitForElement(".weather .normal.medium sup i.fa-long-arrow-alt-up").then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.outerHTML).toContain("transform:rotate(250deg);");
});
});
it("should render showHumidity = true", (done) => {
getText(done, ".weather .normal.medium span:nth-child(3)", "93.7");
});
it("should render degreeLabel = true for temp", (done) => {
getText(done, ".weather .large.light span.bright", "1°C");
});
it("should render degreeLabel = true for feels like", (done) => {
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
});
});
describe("Current weather units", () => {
beforeAll((done) => {
startApp(
"tests/configs/modules/weather/currentweather_units.js",
{
main: {
temp: (1.49 * 9) / 5 + 32,
temp_min: (1 * 9) / 5 + 32,
temp_max: (2 * 9) / 5 + 32
},
wind: {
speed: 11.8 * 2.23694
}
},
done
);
});
it("should render imperial units for wind", (done) => {
getText(done, ".weather .normal.medium span:nth-child(2)", "6 WSW");
});
it("should render imperial units for temp", (done) => {
getText(done, ".weather .large.light span.bright", "34,7°");
});
it("should render imperial units for feels like", (done) => {
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
});
it("should render custom decimalSymbol = ',' for humidity", (done) => {
getText(done, ".weather .normal.medium span:nth-child(3)", "93,7");
});
it("should render custom decimalSymbol = ',' for temp", (done) => {
getText(done, ".weather .large.light span.bright", "34,7°");
});
it("should render custom decimalSymbol = ',' for feels like", (done) => {
getText(done, ".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
});
});
describe("Weather Forecast", () => {
describe("Default configuration", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/forecastweather_default.js", {}, done);
});
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it("should render day " + day, (done) => {
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
});
}
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
for (const [index, icon] of icons.entries()) {
it("should render icon " + icon, (done) => {
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`).then((elem) => {
done();
expect(elem).not.toBe(null);
});
});
}
const maxTemps = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
for (const [index, temp] of maxTemps.entries()) {
it("should render max temperature " + temp, (done) => {
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
});
}
const minTemps = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
for (const [index, temp] of minTemps.entries()) {
it("should render min temperature " + temp, (done) => {
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
});
}
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
for (const [index, opacity] of opacities.entries()) {
it("should render fading of rows with opacity=" + opacity, (done) => {
helpers.waitForElement(`.weather table.small tr:nth-child(${index + 1})`).then((elem) => {
done();
expect(elem).not.toBe(null);
expect(elem.outerHTML).toContain(`<tr style="opacity: ${opacity};">`);
});
});
}
});
describe("Absolute configuration", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/forecastweather_absolute.js", {}, done);
});
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
it("should render day " + day, (done) => {
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
});
}
});
describe("Configuration Options", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/forecastweather_options.js", {}, done);
});
it("should render custom table class", (done) => {
helpers.waitForElement(".weather table.myTableClass").then((elem) => {
done();
expect(elem).not.toBe(null);
});
});
it("should render colored rows", (done) => {
helpers.waitForElement(".weather table.myTableClass").then((table) => {
done();
expect(table).not.toBe(null);
expect(table.rows).not.toBe(null);
expect(table.rows.length).toBe(5);
});
});
});
describe("Forecast weather units", () => {
beforeAll((done) => {
startApp("tests/configs/modules/weather/forecastweather_units.js", {}, done);
});
const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
for (const [index, temp] of temperatures.entries()) {
it("should render custom decimalSymbol = '_' for temp " + temp, (done) => {
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
});
}
});
});
});