2023-01-10 18:55:07 +01:00
|
|
|
const helpers = require("../helpers/global-setup");
|
|
|
|
const weatherFunc = require("../helpers/weather-functions");
|
|
|
|
|
|
|
|
describe("Weather module: Weather Hourly Forecast", () => {
|
|
|
|
afterAll(async () => {
|
|
|
|
await helpers.stopApplication();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Default configuration", () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await weatherFunc.startApp("tests/configs/modules/weather/hourlyweather_default.js", {});
|
|
|
|
});
|
|
|
|
|
|
|
|
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 () => {
|
|
|
|
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Hourly weather options", () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await weatherFunc.startApp("tests/configs/modules/weather/hourlyweather_options.js", {});
|
|
|
|
});
|
|
|
|
|
|
|
|
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 () => {
|
|
|
|
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.day`, hour);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
Tidy up precipitation (#3023)
Fixes #2953
This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.
The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).
<details>
<summary>Examples</summary>
### Yr
I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.
Config:
```js
{
module: "weather",
config: {
weatherProvider: "yr",
type: "current",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "hourly",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "daily",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
}
```
Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">
</details>
---------
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
|
|
|
|
|
|
|
describe("Show precipitations", () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await weatherFunc.startApp("tests/configs/modules/weather/hourlyweather_showPrecipitation.js", {});
|
|
|
|
});
|
|
|
|
|
|
|
|
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 () => {
|
2023-02-18 18:24:11 +01:00
|
|
|
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount);
|
Tidy up precipitation (#3023)
Fixes #2953
This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.
The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).
<details>
<summary>Examples</summary>
### Yr
I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.
Config:
```js
{
module: "weather",
config: {
weatherProvider: "yr",
type: "current",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "hourly",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "daily",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
}
```
Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">
</details>
---------
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-18 18:24:11 +01:00
|
|
|
describe("Shows precipitation probability", () => {
|
Tidy up precipitation (#3023)
Fixes #2953
This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.
The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).
<details>
<summary>Examples</summary>
### Yr
I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.
Config:
```js
{
module: "weather",
config: {
weatherProvider: "yr",
type: "current",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "hourly",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "daily",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
}
```
Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">
</details>
---------
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
|
|
|
const propabilities = [undefined, undefined, "12%", "36%", "44%"];
|
|
|
|
for (const [index, pop] of propabilities.entries()) {
|
|
|
|
if (pop) {
|
2023-02-18 18:24:11 +01:00
|
|
|
it(`should render probability ${pop}`, async () => {
|
|
|
|
await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop);
|
Tidy up precipitation (#3023)
Fixes #2953
This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.
The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).
<details>
<summary>Examples</summary>
### Yr
I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.
Config:
```js
{
module: "weather",
config: {
weatherProvider: "yr",
type: "current",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "hourly",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "daily",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
}
```
Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">
</details>
---------
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-01-10 18:55:07 +01:00
|
|
|
});
|