2025-11-08 21:59:05 +01:00
|
|
|
const { expect } = require("playwright/test");
|
|
|
|
|
const helpers = require("../helpers/global-setup");
|
2023-04-04 20:44:32 +02:00
|
|
|
const weatherFunc = require("../helpers/weather-functions");
|
|
|
|
|
|
|
|
|
|
describe("Weather module: Weather Hourly Forecast", () => {
|
2025-11-08 21:59:05 +01:00
|
|
|
let page;
|
|
|
|
|
|
2023-04-04 20:44:32 +02:00
|
|
|
afterAll(async () => {
|
2025-07-20 08:23:52 +02:00
|
|
|
await weatherFunc.stopApplication();
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Default configuration", () => {
|
|
|
|
|
beforeAll(async () => {
|
2026-02-23 10:27:29 +01:00
|
|
|
await weatherFunc.startApplication("tests/configs/modules/weather/hourlyweather_default.js", "weather_onecall_hourly.json");
|
2025-11-08 21:59:05 +01:00
|
|
|
page = helpers.getPage();
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const minTemps = ["7:00 pm", "8:00 pm", "9:00 pm", "10:00 pm", "11:00 pm"];
|
|
|
|
|
for (const [index, hour] of minTemps.entries()) {
|
|
|
|
|
it(`should render forecast for hour ${hour}`, async () => {
|
2025-11-08 21:59:05 +01:00
|
|
|
const dayCell = page.locator(`.weather table.small tr:nth-child(${index + 1}) td.day`);
|
|
|
|
|
await expect(dayCell).toHaveText(hour);
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Hourly weather options", () => {
|
|
|
|
|
beforeAll(async () => {
|
2026-02-23 10:27:29 +01:00
|
|
|
await weatherFunc.startApplication("tests/configs/modules/weather/hourlyweather_options.js", "weather_onecall_hourly.json");
|
2025-11-08 21:59:05 +01:00
|
|
|
page = helpers.getPage();
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Hourly increments of 2", () => {
|
|
|
|
|
const minTemps = ["7:00 pm", "9:00 pm", "11:00 pm", "1:00 am", "3:00 am"];
|
|
|
|
|
for (const [index, hour] of minTemps.entries()) {
|
|
|
|
|
it(`should render forecast for hour ${hour}`, async () => {
|
2025-11-08 21:59:05 +01:00
|
|
|
const dayCell = page.locator(`.weather table.small tr:nth-child(${index + 1}) td.day`);
|
|
|
|
|
await expect(dayCell).toHaveText(hour);
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Show precipitations", () => {
|
|
|
|
|
beforeAll(async () => {
|
2026-02-23 10:27:29 +01:00
|
|
|
await weatherFunc.startApplication("tests/configs/modules/weather/hourlyweather_showPrecipitation.js", "weather_onecall_hourly.json");
|
2025-11-08 21:59:05 +01:00
|
|
|
page = helpers.getPage();
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Shows precipitation amount", () => {
|
|
|
|
|
const amounts = [undefined, undefined, undefined, "0.13 mm", "0.13 mm"];
|
|
|
|
|
for (const [index, amount] of amounts.entries()) {
|
|
|
|
|
if (amount) {
|
|
|
|
|
it(`should render precipitation amount ${amount}`, async () => {
|
2025-11-08 21:59:05 +01:00
|
|
|
const amountCell = page.locator(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`);
|
|
|
|
|
await expect(amountCell).toHaveText(amount);
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Shows precipitation probability", () => {
|
2024-09-18 07:37:09 +02:00
|
|
|
const probabilities = [undefined, undefined, "12 %", "36 %", "44 %"];
|
2025-11-08 21:59:05 +01:00
|
|
|
for (const [index, probability] of probabilities.entries()) {
|
|
|
|
|
if (probability) {
|
|
|
|
|
it(`should render probability ${probability}`, async () => {
|
|
|
|
|
const probabilityCell = page.locator(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`);
|
|
|
|
|
await expect(probabilityCell).toHaveText(probability);
|
2023-04-04 20:44:32 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|