mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #2448 from khassel/electron11
fix e2e tests after spectron update
This commit is contained in:
commit
ef2fd16b69
@ -47,6 +47,7 @@ _This release is scheduled to be released on 2021-04-01._
|
||||
- Fix issue with unencoded characters in translated strings when using nunjuck template (`Loading …` as an example)
|
||||
- Fix socket.io backward compatibility with socket v2 clients
|
||||
- 3rd party module language loading if language is English
|
||||
- Fix e2e tests after spectron update
|
||||
|
||||
## [2.14.0] - 2021-01-01
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if (config.showFeelsLike or config.showPrecipitationAmount) and not config.onlyTemp %}
|
||||
<div class="normal medium">
|
||||
<div class="normal medium feelslike">
|
||||
{% if config.showFeelsLike %}
|
||||
<span class="dimmed">
|
||||
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
|
||||
|
@ -34,23 +34,15 @@ describe("Electron app environment", function () {
|
||||
it("should open a browserwindow", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
app.browserWindow.focus();
|
||||
const cnt = await app.client.getWindowCount();
|
||||
const min = await app.browserWindow.isMinimized();
|
||||
const dev = await app.browserWindow.isDevToolsOpened();
|
||||
const vis = await app.browserWindow.isVisible();
|
||||
const foc = await app.browserWindow.isFocused();
|
||||
expect(await app.client.getWindowCount()).to.equal(1);
|
||||
expect(await app.browserWindow.isMinimized()).to.be.false;
|
||||
expect(await app.browserWindow.isDevToolsOpened()).to.be.false;
|
||||
expect(await app.browserWindow.isVisible()).to.be.true;
|
||||
expect(await app.browserWindow.isFocused()).to.be.true;
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
const title = await app.browserWindow.getTitle();
|
||||
return (
|
||||
cnt.should.equal(1) &&
|
||||
min.should.be.false &&
|
||||
dev.should.be.false &&
|
||||
vis.should.be.true &&
|
||||
foc.should.be.true &&
|
||||
bounds.should.have.property("width").and.be.above(0) &&
|
||||
bounds.should.have.property("height").and.be.above(0) &&
|
||||
title.should.equal("MagicMirror²")
|
||||
);
|
||||
expect(bounds.width).to.be.above(0);
|
||||
expect(bounds.height).to.be.above(0);
|
||||
expect(await app.browserWindow.getTitle()).to.equal("MagicMirror²");
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||
|
@ -31,7 +31,7 @@ describe("Clock set to spanish language module", function () {
|
||||
});
|
||||
|
||||
it("shows date with correct format", async function () {
|
||||
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}$/;
|
||||
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}$/;
|
||||
const elem = await app.client.$(".clock .date");
|
||||
return elem.getText(".clock .date").should.eventually.match(dateRegex);
|
||||
});
|
||||
|
@ -23,6 +23,17 @@ describe("Weather module", function () {
|
||||
app.client.setupStub();
|
||||
}
|
||||
|
||||
async function getElement(element) {
|
||||
return await app.client.$(element);
|
||||
}
|
||||
|
||||
async function getText(element, result) {
|
||||
const elem = await getElement(element);
|
||||
return await elem.getText(element).then(function (text) {
|
||||
expect(text.trim()).to.equal(result);
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
@ -43,7 +54,7 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(2)", "6 WSW");
|
||||
});
|
||||
|
||||
it("should render sunrise", async function () {
|
||||
@ -53,9 +64,7 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather({ sys: { sunrise, sunset } });
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span.wi.dimmed.wi-sunrise", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(4)", "12:00 am", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(4)", "12:00 am");
|
||||
});
|
||||
|
||||
it("should render sunset", async function () {
|
||||
@ -65,25 +74,21 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather({ sys: { sunrise, sunset } });
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span.wi.dimmed.wi-sunset", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(4)", "11:59 pm", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(4)", "11:59 pm");
|
||||
});
|
||||
|
||||
it("should render temperature with icon", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .large.light span.wi.weathericon.wi-snow", 10000);
|
||||
|
||||
return await app.client.$(".weather .large.light span.bright", "1.5°", 10000);
|
||||
return getText(".weather .large.light span.bright", "1.5°");
|
||||
});
|
||||
|
||||
it("should render feels like temperature", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "Feels like -5.6°", 10000);
|
||||
return getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -5.6°");
|
||||
});
|
||||
});
|
||||
|
||||
@ -96,7 +101,16 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".compliments .module-content span", "snow", 10000);
|
||||
const wait = (time) => new Promise((resolve) => setTimeout(resolve, time));
|
||||
|
||||
var text = "";
|
||||
do {
|
||||
await wait(3000);
|
||||
elem = await app.client.$(".compliments");
|
||||
text = await elem.getText(".compliments .module-content span");
|
||||
} while (text === "");
|
||||
|
||||
return expect(text.trim()).to.equal("snow");
|
||||
});
|
||||
});
|
||||
|
||||
@ -109,34 +123,31 @@ describe("Weather module", function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
return await app.client.$(".weather .normal.medium span:nth-child(2)", "12", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(2)", "12");
|
||||
});
|
||||
|
||||
it("should render showWindDirectionAsArrow = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
const elem = await app.client.$(".weather .normal.medium sup i.fa-long-arrow-up", 10000);
|
||||
const element = await elem.getHTML(".weather .normal.medium sup i.fa-long-arrow-up");
|
||||
|
||||
expect(element).to.include("transform:rotate(250deg);");
|
||||
const elem = await getElement(".weather .normal.medium sup i.fa-long-arrow-up");
|
||||
return elem.getHTML(".weather .normal.medium sup i.fa-long-arrow-up").then(function (text) {
|
||||
expect(text).to.include("transform:rotate(250deg);");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render showHumidity = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(3)", "93", 10000);
|
||||
return await app.client.$(".weather .normal.medium sup i.wi-humidity", 10000);
|
||||
return getText(".weather .normal.medium span:nth-child(3)", "93.7");
|
||||
});
|
||||
|
||||
it("should render degreeLabel = true", async function () {
|
||||
const weather = generateWeather();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .large.light span.bright", "1°C", 10000);
|
||||
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "Feels like -6°C", 10000);
|
||||
return getText(".weather .large.light span.bright", "1°C") && getText(".weather .normal.medium.feelslike span.dimmed", "Feels like -6°C");
|
||||
});
|
||||
});
|
||||
|
||||
@ -158,9 +169,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(2)", "6 WSW", 10000);
|
||||
await app.client.$(".weather .large.light span.bright", "34,7°", 10000);
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "22,0°", 10000);
|
||||
return 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 decimalSymbol = ','", async function () {
|
||||
@ -176,9 +185,7 @@ describe("Weather module", function () {
|
||||
});
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather .normal.medium span:nth-child(3)", "93,7", 10000);
|
||||
await app.client.$(".weather .large.light span.bright", "34,7°", 10000);
|
||||
return await app.client.$(".weather .normal.medium span.dimmed", "22,0°", 10000);
|
||||
return 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°");
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -202,7 +209,7 @@ describe("Weather module", function () {
|
||||
const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"];
|
||||
|
||||
for (const [index, day] of days.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
|
||||
}
|
||||
});
|
||||
|
||||
@ -213,7 +220,7 @@ describe("Weather module", function () {
|
||||
const icons = ["day-cloudy", "rain", "day-sunny", "day-sunny", "day-sunny"];
|
||||
|
||||
for (const [index, icon] of icons.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(2) span.wi-${icon}`);
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,7 +231,7 @@ describe("Weather module", function () {
|
||||
const temperatures = ["24.4°", "21.0°", "22.9°", "23.4°", "20.6°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(3)`, temp);
|
||||
}
|
||||
});
|
||||
|
||||
@ -235,7 +242,7 @@ describe("Weather module", function () {
|
||||
const temperatures = ["15.3°", "13.6°", "13.8°", "13.9°", "10.9°"];
|
||||
|
||||
for (const [index, temp] of temperatures.entries()) {
|
||||
await app.client.$(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp, 10000);
|
||||
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(4)`, temp);
|
||||
}
|
||||
});
|
||||
|
||||
@ -245,7 +252,7 @@ describe("Weather module", function () {
|
||||
|
||||
const opacities = [1, 1, 0.8, 0.5333333333333333, 0.2666666666666667];
|
||||
|
||||
const elem = await app.client.$(".weather table.small", 10000);
|
||||
const elem = await getElement(".weather table.small");
|
||||
|
||||
for (const [index, opacity] of opacities.entries()) {
|
||||
const html = await elem.getHTML(`.weather table.small tr:nth-child(${index + 1})`);
|
||||
@ -263,15 +270,13 @@ describe("Weather module", function () {
|
||||
const weather = generateWeatherForecast();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather table.myTableClass", 10000);
|
||||
await getElement(".weather table.myTableClass");
|
||||
});
|
||||
|
||||
it("should render colored rows", async function () {
|
||||
const weather = generateWeatherForecast();
|
||||
await setup({ template, data: weather });
|
||||
|
||||
await app.client.$(".weather table.myTableClass", 10000);
|
||||
|
||||
const rows = await app.client.$$(".weather table.myTableClass tr.colored");
|
||||
|
||||
expect(rows.length).to.be.equal(5);
|
||||
|
@ -33,8 +33,8 @@ describe("Position of modules", function () {
|
||||
position = positions[idx];
|
||||
className = position.replace("_", ".");
|
||||
it("show text in " + position, function () {
|
||||
app.client.$("." + className).then((result) => {
|
||||
return this.getText("." + className).should.eventually.equal("Text in " + position);
|
||||
return app.client.$("." + className).then((result) => {
|
||||
return result.getText("." + className).should.eventually.equal("Text in " + position);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user