418 Commits

Author SHA1 Message Date
Veeck
432d900ecd
Add tests for some weather utils (#3103)
Co-authored-by: veeck <michael@veeck.de>
2023-05-15 21:04:50 +02:00
Ismar Slomic
83315f1fed
fix: don't filter out ongoing full day events in Calendar module (#3095) (#3096)
Fixes #3095.

Param `hideOngoing` is by default set to `false`, but the event
filtering handles `full day` & `non-full day` events inconsistently. For
`non-full day` _ongoing_ and _upcoming_ events are returned, while for
`full day` only _upcoming_ events where returned.
2023-05-15 20:16:33 +02:00
Karsten Hassel
a41aa48dd1
add .gitattributes and fix prettier/js warnings (#3094)
see title, as discussed in
https://github.com/MichMich/MagicMirror/pull/3093
2023-04-22 09:29:51 +02:00
Karsten Hassel
b80485b52f
use node v20 in github workflow (replacing v19) (#3093)
additional:

- update deps
- suppress more unwanted log errors in e2e tests
- add .gitattributes
- fix prettier/js warnings
2023-04-22 09:29:23 +02:00
Veeck
7e58b38ddf
Add no-param-reassign from eslint (#3089)
While waiting for the easterbunny I cleaned up some bad coding practice
:-)

Very open for comments especially regarding the places I commented
myself...

---------

Co-authored-by: veeck <michael@veeck.de>
2023-04-16 17:38:39 +02:00
Veeck
77f9c86774
Refactor calendar methods into util class (#3088)
Refactored some methods in calendar module:
- move methods into own file 
- dont call shorten method from titelTransform because why? just call
them after each other.
- added tests for util methods
- cleaned up other tests

---------

Co-authored-by: veeck <michael@veeck.de>
2023-04-09 12:49:50 +02:00
JakeBinney
dee3cd3da7
Fixed clock module sunrise/sunset timezone bug (#3070)
Updated sunrise/sunset times to display user-requested timezone rather
than system timezone.

Note: rebase of  #3069 against develop rather than master

Co-authored-by: Veeck <github@veeck.de>
2023-04-09 09:19:51 +02:00
Karsten Hassel
09f117c3d9
set Timezone Europe/Berlin in unit tests (#3087)
needed for new formatTime unit tests.

Avoiding ugly TZ setting in github workflows, see
https://github.com/MichMich/MagicMirror/pull/3073
2023-04-08 08:55:43 +02:00
Veeck
32192d1698
Refactor formatTime into util class (#3073)
While looking at https://github.com/MichMich/MagicMirror/pull/3070 I
noticed that the weather and clock module do some formatTime stuff, so
why not use a common function for that?

---------

Co-authored-by: veeck <michael@veeck.de>
2023-04-07 23:11:54 +02:00
Karsten Hassel
2c7beeaaaf
added test for serveronly (#3086)
- add test for serveronly, fixes #3076 
- use template literals in port_variable.js.template
2023-04-07 19:42:46 +02:00
Kristjan ESPERANTO
5f38c53260
Revise require imports (#3071)
- order (external first)
- remove superfluous file extensions
- new line after imports
- deconstruct (only one time (in `check_config.js`))
- fix path (only one time (in `global-setup.js`))
2023-03-22 23:53:10 +01:00
Kristjan ESPERANTO
ab0876f07a
Update Eslint config, add new rule and handle issue (#3068) 2023-03-20 22:18:58 +01:00
Kristjan ESPERANTO
d276a7ddb9
Use template literals instead of string concatenation (#3066)
We have used it inconsistently till now. Template literals are more
modern and easier to maintain in my opinion.

Because that's a large amount of changes, here's a way to reproduce it:
I added the rule `"prefer-template": "error"` to the `.eslintrc.json`
and did an autofix. Since this caused a new problem in line 409 of
`newsfeed.js`, I reversed it in that line and also removed the rule from
the eslint config file.

The rule is described here:
https://eslint.org/docs/latest/rules/prefer-template

Note: I've played around with some other linter rules as well, and some
seem to point to some specific, non-cosmetic, issues. But before I dive
even deeper and then introduce even bigger and hardly understandable
changes at once, I thought I'd start with this simple cosmetic rule.
2023-03-19 14:32:23 +01:00
Karsten Hassel
6d779235cf
fix e2e tests (failed after async changes) (#3063)
by running calendar and newsfeed tests last.

Additional change: allow unit tests to run parallel

This is no fix of the real issue of calendar and newsfeed tests but I
moved them to the end of the tests so other tests are not failing
anymore.

There are coming follow up PR's for the real fixes (when I find the
culprits).

With these change we can stay with the async changes done by @rejas and
https://github.com/MichMich/MagicMirror/pull/3060 is obsolete.
2023-03-12 10:22:23 +01:00
Veeck
1b2785cc56
Cleanup more callback things (#3051)
Looks quite stable on my computers, so maybe we give it a try?

---------

Co-authored-by: veeck <michael@veeck.de>
2023-02-26 18:36:47 +01:00
Veeck
fe0b915a5d
Convert app-start/-stop callbacks to async/await (#3035)
supersedes https://github.com/MichMich/MagicMirror/pull/3027 and just
touches the start/stop calls.

---------

Co-authored-by: veeck <michael@veeck.de>
2023-02-22 18:58:00 +01:00
Veeck
2b792cdbb8
Convert translator callbacks to async/await (#3048)
Co-authored-by: veeck <michael@veeck.de>
2023-02-21 22:58:18 +01:00
Thomas Hirschberger
a23769156e
Show events of a configurable amount of past days (#3046)
Hi,

want to include a birthday calendar to my mirror which shows upcoming
birthdays and as a reminder birthdays of the last two days.
I used
[MMM-CalendarExt2](https://github.com/MMM-CalendarExt2/MMM-CalendarExt2)
for this job in the past but the module is not supported any more and
very complicated to configure.
I managed to style the default calendar module to my needs but what i am
missing is to display already past events within a configurable time
range.

I included the translations of "YESTERDAY" and "DAYBEFOREYESTERDAY" to
all translation files and modified the code to accept a new option
`pastDaysCount` which controls of how many days past events should be
displayed.

---------

Co-authored-by: Veeck <github@veeck.de>
2023-02-21 22:39:21 +01:00
Veeck
6d86ffade4
Fix rounding in precipitation percentage (#3045)
Percentage should be always rounded so that we dont get something like
"47.0000000001 %"

Some small typo and naming fixes also while I am here

---------

Co-authored-by: veeck <michael@veeck.de>
2023-02-20 20:04:40 +01:00
Kristjan ESPERANTO
b08a4737af
Update stylelint (#3042)
1. Update `stylelint` dependencies
- As of stylelint v15, we do not need `stylelint-config-prettier`
anymore:
https://github.com/prettier/stylelint-config-prettier/releases/tag/v9.0.5
2. Switch to `stylelint-config-standard`:
`stylelint-prettier/recommended` has not been updated for a long time
and still needs the old `stylelint-config-prettier`
3. Handle new `stylelint` issues
2023-02-19 21:36:50 +01:00
Veeck
fb22a76796
Fix precipitation styles (#3041)
They weren't applied to wrong classnames, this PR fixes that and also
expands the weather util tests

---------

Co-authored-by: veeck <michael@veeck.de>
2023-02-18 18:24:11 +01:00
Karsten Hassel
a65ee86501
Introduce envsubst for config.js, update deps (#3032)
This is the implemenation of envsubst discussed in #1756 

Documentation update will follow after merge.
2023-02-12 22:34:57 +01:00
Veeck
1dc0a0d5b5
Update some tests (#3024)
Co-authored-by: veeck <michael@veeck.de>
2023-02-07 00:03:08 +01:00
Magnus
bf279d9a57
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
Veeck
a8dc563a31
Update weather tests (#3008)
Added a few tests for sunset/sunrise and feelsLike 
Lets see if they run through first...

Co-authored-by: veeck <michael@veeck.de>
2023-01-26 19:43:34 +01:00
Karsten Hassel
58b9ddcd9f
updatenotification: only notify mm-repo for master if tag present (#3004)
see discussion here:
https://github.com/MichMich/MagicMirror/pull/2991#issuecomment-1376372720

I still see a need for updating `master` in special cases (e.g. correct
errors in README.md which would otherwise be present up to 3 month until
next release) so with this PR **only for MagicMirror repo** and **only
for `master` branch** updatenotifications are only triggered if at least
one of the new commits has a tag.

May @MichMich must decide if this is wanted.

Co-authored-by: Veeck <github@veeck.de>
2023-01-26 13:21:30 +01:00
Magnus
67e4dbaacd
Point wind arrow in the direction the wind is flowing (#3022)
Fixes #3019

The previous implementation had the arrow pointing in to the wind. When
the wind blows from the north (0 degrees), the arrow should point
straight down. In other words, no rotation of the arrow-down symbol.
When the wind blows from the south (180 degrees), the arrow should point
straight up (I.e. the arrow down symbol rotated 180 degrees).

Co-authored-by: Magnus Marthinsen <magmar@online.no>
2023-01-22 11:41:19 +01:00
Dave Child
4244c05764
Fix calendar.js missing default symbol prefix (#3007)
Symbols provided in customEvents don't get the "fas fa-fw fa-" prefix,
which according to the docs they should. This fixes that.

Hello and thank you for wanting to contribute to the MagicMirror²
project

**Please make sure that you have followed these 4 rules before
submitting your Pull Request:**

> 1. Base your pull requests against the `develop` branch.
>
> 2. Include these infos in the description:
>
> - Does the pull request solve a **related** issue?
> - If so, can you reference the issue like this `Fixes
#<issue_number>`?
> - What does the pull request accomplish? Use a list if needed.
> - If it includes major visual changes please add screenshots.
>
> 3. Please run `npm run lint:prettier` before submitting so that
>    style issues are fixed.
>
> 4. Don't forget to add an entry about your changes to
>    the CHANGELOG.md file.

**Note**: Sometimes the development moves very fast. It is highly
recommended that you update your branch of `develop` before creating a
pull request to send us your changes. This makes everyone's lives
easier (including yours) and helps us out on the development team.

Thanks again and have a nice day!

Co-authored-by: veeck <michael@veeck.de>
2023-01-16 22:33:05 +01:00
Karsten Hassel
29e3ec06cb
added possibility to ignore MagicMirror repo in updatenotification (#3002)
was [requested in the
forum](https://forum.magicmirror.builders/topic/17519/updatenotification).

- added possibility to exclude MagicMirror Repo and renamed it from
`default` to `MagicMirror`
- improved getting `behind` in case a hard `git fetch` was already done
- removed test "excludes repo if refs don't match regex" because of
above improvement this case is obsolete
- improved `git fetch --dry-run` with `-n` option to exclude tags (noise
reduction)
2023-01-12 09:14:20 +01:00
Veeck
877f8ad380
Refactor mock-data for weather-tests generation (#3000)
Refactored the mock data generation for the tests so we can use plain
JSON files for the data and read it in a more general way.

Comments welcome!

Co-authored-by: veeck <michael@veeck.de>
2023-01-11 21:47:20 +01:00
Veeck
6e80e5a295
Add option to show hourly forecast in increments (#2998)
Adds new config option to show weather forecast for every X hour
(default value is 1 which reflects the current behaviour)
Also adds tests for hourly forecast
Fixes #2996

Co-authored-by: veeck <michael@veeck.de>
2023-01-10 18:55:07 +01:00
Karsten Hassel
76d9042e60
update playwright to v1.29.1 and other dependencies (#2980)
see title, fixes https://github.com/MichMich/MagicMirror/issues/2969
2022-12-22 16:40:53 +01:00
Karsten Hassel
2fec314ff5
improve electron tests (avoid errors in github workflows) (#2977)
Fix electron tests failing sometimes in github workflow.
2022-12-12 21:43:22 +01:00
Kristjan ESPERANTO
3124b0a9c5
Replace &hellip; with (#2973)
I think it is clearer if we don't use the HTML entity.

Co-authored-by: Karsten Hassel <hassel@gmx.de>
2022-12-10 21:50:56 +01:00
Veeck
a2624442cc
Cleanup compliments module (#2965)
Lots of small fixes and cleanups:
- only render something when there is a compliment
- cleanup naming
- use es6 notations
- use fetch instead of XMLHttpRequest in compliments

Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
2022-12-10 21:23:00 +01:00
Magnus
bd0b3c00ad
New weather provider: Yr.no (#2948)
# Added Yr.no as a weather provider

Yr.no is a free Norwegian weather service. The configuration is quite
simple:
```js
{
    weatherProvider: "yr",
    lat: 59.9171,
    lon: 10.7276,
    altitude: 30
}
```
The latitude and longitude cannot have more than 4 decimals, but that
should be plenty. To quote yr: "There is no need to ask for weather
forecasts with nanometer precision!". The altitude should be meters
above sea level and defaults to 0. If `type` is set to `current` the
symbol can display the next 1, 6 or 12 hours by setting
`currentForecastHours` (default is 1).

It states in [Getting
started-guide](https://developer.yr.no/doc/GettingStarted/) that users
of the API should cache the results and use the `Expires`-header to know
when to ask for new data. By using the `If-Modified-Since`-header we can
avoid downloading the same data over and over again. I chose not to
override the `User-Agent`-header set in
[`server.js`](https://github.com/MichMich/MagicMirror/blob/a328ce5/js/server.js#L97)
even though it does not comply with [the terms of
service](https://developer.yr.no/doc/TermsOfService/). It currently
works with the default header, and by searching the web for MagicMirror
the GitHub-repo should be easy to find without an explicit link.

I also had to make some minor changes to `server.js` and
`weatherprovider.js` to be able to send and return HTTP headers. To
handle the HTTP 304 response without body I chose to return `undefined`
so we easily can use the response as a condition: `if (response) ...`.

The documentation for the API is available here:
- [API Reference overview](https://api.met.no/weatherapi/)
-
[Locationforecast](https://api.met.no/weatherapi/locationforecast/2.0/)
- Used to get the weather forecast
- [Sunrise](https://api.met.no/weatherapi/sunrise/2.0/documentation) -
used to find sunrise and sunset times

Co-authored-by: Veeck <github@veeck.de>
2022-11-08 06:18:47 +01:00
Magnus
4d47c0837f
Support HTTP headers with CORS-method (#2957)
Adds support for sending and receiving HTTP-headers when using the
CORS-method.

This change is required for the Yr weather-provider introduced in
https://github.com/MichMich/MagicMirror/pull/2948.

To make it easier to add unit tests I moved the server-functions into a
separate file.
2022-10-30 18:14:02 +01:00
Veeck
3879949f58
Switch back to third party fetch lib for all node versions (#2961)
As discussed in https://github.com/MichMich/MagicMirror/pull/2952

Co-authored-by: veeck <michael@veeck.de>
2022-10-29 23:10:25 +02:00
buxxi
f25abfd2f8
Make the e2e tests wait for the app to start and close before running next test (#2952)
When trying to debug why the tests broke for
https://github.com/MichMich/MagicMirror/pull/2946 I found that the tests
does not wait for the app to start and close. So if the startup isn't
blocking that would fail.

So I added a callback for `close()` too and converted them to promises
for the `startApplication()` and `stopApplication()` and updated all the
e2e tests to await both. Will try to refactor all these callbacks to
promises in a later PR.
2022-10-29 22:34:17 +02:00
Veeck
f79d3f007d
Cleanup jest config (#2959)
Some small cleanups with regards to jest
- call jest directly (nyc is integrated in jest these days)
- move jest config into seperate file so we dont clutter up the
package.json
- remove empty test file for newsletter-unit-tests
- update dependencies that touch jest
- try out v8 as coverageProvider

Co-authored-by: veeck <michael@veeck.de>
2022-10-28 20:57:08 +02:00
Veeck
c191ff0032
Refactor common weather methods into utils class (#2958)
Co-authored-by: veeck <michael@veeck.de>
2022-10-28 19:56:55 +02:00
Veeck
2d3940a4ff
Use metric units internally in all weatherproviders (#2849)
So finally I think this refactorin is ready to be reviewed :-)

DONE:
- [x] Removed all conversion functions for wind and temperature from
specific weatherproviders
- [x] Use internally only metric units: celsius for temperature, meters
per seconds for wind
- [x] Convert temp and wind into the configured units when displaying
data on the UI
- [x] look how beaufort calculation uses metrics, added knots as new
windunit
- [x] add more e2e tests 

Checked providers:
- [x] Darksky
- [x] EnvCanada
- [x] OpenWeatherMap
- [x] SMHI provider 
- [x] UK Met Office
- [x] UK Met Office DataHub
- [x] WeatherBit
- [x] WeatherFlow
- [x] WeatherGov

TODO in different tickets:
- check weatherproviders for usage of weatherEndpoint (as seen in
https://github.com/MichMich/MagicMirror-Documentation/issues/131) -> see
#2926
- cleanup precipations -> #2953

Co-authored-by: veeck <michael@veeck.de>
2022-10-24 19:41:34 +02:00
Karsten Hassel
ad4dbd786a
added new electron tests supporting date mocking (#2947)
first PR for #2942 

- added new electron tests for calendar which test new css classes from
https://github.com/MichMich/MagicMirror/pull/2939
- moved some compliments tests from `e2e` to `electron` because of date
mocking
- removed mock stuff from compliments module
2022-10-17 07:20:23 +02:00
Veeck
a328ce537f
Cleanup test directory (#2937)
Moves files around and renames some so that the structure is cleaner and
more consistent
2022-10-07 12:16:37 -05:00
Veeck
ce4906d13b
Add test in compliments module for remotFile option (#2932)
nothing fancy here, just a simple test after @khassel's changes to the
test setup :-)

Co-authored-by: veeck <michael@veeck.de>
2022-10-04 14:26:31 +02:00
Karsten Hassel
f04d578704
improve tests (#2923)
use es6 syntax in all tests, split weather tests, remove callbacks
2022-10-04 10:15:24 +02:00
Karsten Hassel
0c1abad9df fix calendar_test_recurring.ics and uncomment recurring tests 2022-09-21 21:01:43 +02:00
Karsten Hassel
fb96cc3c72 fix e2e tests not failing on errors, disable recurring-event-tests of calendar 2022-09-21 00:28:43 +02:00
Karsten Hassel
4cc3e481cc update dependencies, revert electron to v19 2022-09-05 23:26:04 +02:00
Mike Bishop
0c1e5ea881 Use German as the base for tests 2022-07-25 18:23:27 -04:00