mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 05:07:05 +00:00
fix e2e tests not failing on errors, disable recurring-event-tests of calendar
This commit is contained in:
@@ -4,13 +4,15 @@ const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { generateWeather, generateWeatherForecast } = require("./mocks");
|
||||
|
||||
describe("Weather module", function () {
|
||||
describe("Weather module", () => {
|
||||
/**
|
||||
* @param {string} done test done
|
||||
* @param {string} element css selector
|
||||
* @param {string} result Expected text in given selector
|
||||
*/
|
||||
function getText(element, result) {
|
||||
const getText = (done, element, result) => {
|
||||
helpers.waitForElement(element).then((elem) => {
|
||||
done();
|
||||
expect(elem).not.toBe(null);
|
||||
expect(
|
||||
elem.textContent
|
||||
@@ -19,14 +21,14 @@ describe("Weather module", function () {
|
||||
.replace(/[ ]+/g, " ")
|
||||
).toBe(result);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} configFile path to configuration file
|
||||
* @param {string} additionalMockData special data for mocking
|
||||
* @param {string} callback callback
|
||||
*/
|
||||
function startApp(configFile, additionalMockData, callback) {
|
||||
const startApp = (configFile, additionalMockData, callback) => {
|
||||
let mockWeather;
|
||||
if (configFile.includes("forecast")) {
|
||||
mockWeather = generateWeatherForecast(additionalMockData);
|
||||
@@ -38,94 +40,98 @@ describe("Weather module", function () {
|
||||
fs.writeFileSync(path.resolve(__dirname + "../../../../config/config.js"), content);
|
||||
helpers.startApplication("");
|
||||
helpers.getDocument(callback);
|
||||
}
|
||||
};
|
||||
|
||||
afterAll(async function () {
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
});
|
||||
|
||||
describe("Current weather", function () {
|
||||
describe("Default configuration", function () {
|
||||
beforeAll(function (done) {
|
||||
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", function () {
|
||||
getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||
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", function () {
|
||||
getText(".weather .large.light span.bright", "1.5°");
|
||||
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", function () {
|
||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
||||
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", function () {
|
||||
beforeAll(function (done) {
|
||||
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", function () {
|
||||
getText(".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||
it("should render sunrise", (done) => {
|
||||
getText(done, ".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Default configuration with sunset", function () {
|
||||
beforeAll(function (done) {
|
||||
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", function () {
|
||||
getText(".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||
it("should render sunset", (done) => {
|
||||
getText(done, ".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Compliments Integration", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Compliments Integration", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/currentweather_compliments.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render a compliment based on the current weather", function () {
|
||||
getText(".compliments .module-content span", "snow");
|
||||
it("should render a compliment based on the current weather", (done) => {
|
||||
getText(done, ".compliments .module-content span", "snow");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Configuration Options", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Configuration Options", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/currentweather_options.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render useBeaufort = false", function () {
|
||||
getText(".weather .normal.medium span:nth-child(2)", "12");
|
||||
it("should render useBeaufort = false", (done) => {
|
||||
getText(done, ".weather .normal.medium span:nth-child(2)", "12");
|
||||
});
|
||||
|
||||
it("should render showWindDirectionAsArrow = true", function () {
|
||||
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", function () {
|
||||
getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
||||
it("should render showHumidity = true", (done) => {
|
||||
getText(done, ".weather .normal.medium span:nth-child(3)", "93.7");
|
||||
});
|
||||
|
||||
it("should render degreeLabel = true", function () {
|
||||
getText(".weather .large.light span.bright", "1°C");
|
||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
||||
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", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Current weather units", () => {
|
||||
beforeAll((done) => {
|
||||
startApp(
|
||||
"tests/configs/modules/weather/currentweather_units.js",
|
||||
{
|
||||
@@ -142,98 +148,108 @@ describe("Weather module", function () {
|
||||
);
|
||||
});
|
||||
|
||||
it("should render imperial units", function () {
|
||||
getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||
getText(".weather .large.light span.bright", "34,7°");
|
||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
||||
it("should render imperial units for wind", (done) => {
|
||||
getText(done, ".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||
});
|
||||
|
||||
it("should render custom decimalSymbol = ','", function () {
|
||||
getText(".weather .normal.medium span:nth-child(3)", "93,7");
|
||||
getText(".weather .large.light span.bright", "34,7°");
|
||||
getText(".weather .normal.medium.feelslike span.dimmed", "Feels like 22,0°");
|
||||
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", function () {
|
||||
describe("Default configuration", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Weather Forecast", () => {
|
||||
describe("Default configuration", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/forecastweather_default.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render days", function () {
|
||||
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
for (const [index, day] of days.entries()) {
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||
}
|
||||
});
|
||||
|
||||
it("should render icons", function () {
|
||||
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
|
||||
|
||||
for (const [index, icon] of icons.entries()) {
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it("should render max temperatures", function () {
|
||||
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
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, (done) => {
|
||||
getText(done, `.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
||||
});
|
||||
}
|
||||
|
||||
it("should render min temperatures", function () {
|
||||
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
||||
}
|
||||
});
|
||||
|
||||
it("should render fading of rows", function () {
|
||||
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
|
||||
|
||||
for (const [index, opacity] of opacities.entries()) {
|
||||
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", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Absolute configuration", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/forecastweather_absolute.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render days", function () {
|
||||
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
|
||||
|
||||
for (const [index, day] of days.entries()) {
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||
}
|
||||
});
|
||||
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", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Configuration Options", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/forecastweather_options.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render custom table class", function () {
|
||||
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", function () {
|
||||
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);
|
||||
@@ -241,18 +257,17 @@ describe("Weather module", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Forecast weather units", function () {
|
||||
beforeAll(function (done) {
|
||||
describe("Forecast weather units", () => {
|
||||
beforeAll((done) => {
|
||||
startApp("tests/configs/modules/weather/forecastweather_units.js", {}, done);
|
||||
});
|
||||
|
||||
it("should render custom decimalSymbol = '_'", function () {
|
||||
const temperatures = ["24_4°", "21_0°", "22_9°", "23_4°", "20_6°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
||||
}
|
||||
});
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user