Notification tests
#760
Open
deefdragon wants to merge 30 commits from deefdragon/notif-tests
into master
pull from: deefdragon/notif-tests
merge into: topaLE:master
topaLE:1.6.X
topaLE:1.7.X
topaLE:1.9.X
topaLE:Mikhail5555/feature/remote-header-auth
topaLE:Nuckerr/master
topaLE:Saibamen/fix_871
topaLE:WillianRod/feat/add-favicon-badges
topaLE:andreasbrett/logging
topaLE:andreasbrett/securepush
topaLE:bertyhell/bugfix/heartbeat-bar-animation
topaLE:bertyhell/feature/monitor-checks
topaLE:bertyhell/feature/translations-extraction-script
topaLE:cert-notification
topaLE:chakflying/settings-redesign
topaLE:debian-docker
topaLE:deefdragon/Template-Engine
topaLE:e2e-test
topaLE:fdcastel/push-api-tags
topaLE:free-disk-space
topaLE:ivanbratovic/http-basicauth
topaLE:ivanbratovic/improve-translatables
topaLE:k8s-unofficial
topaLE:lucasra1/overall_status
topaLE:master
topaLE:mhkarimi1383/master
topaLE:mrphuongbn/master
topaLE:no-need-build
topaLE:philippdormann/feature/release-management
topaLE:proffalken/feature/680_add_labels_to_prometheus_metrics
topaLE:proffalken/feature/auto_build_and_release
topaLE:rebasesoftware/feature/request-with-http-proxy
topaLE:restructure-status-page
topaLE:sqlite-upgrade-prebuilt
topaLE:tarun7singh/master
topaLE:thomasleveil/feature/565-duplicate-monitor
topaLE:thomasleveil/ux/add-group-at-the-top
Reviewers
Request review
No reviewers
Labels
Something isn't working dependencies
Pull requests that update a dependency file discussion doc
Improvements or additions to documentation duplicate
This issue or pull request already exists feature-request
New feature or request good first issue
Good for newcomers hacktoberfest hacktoberfest-accepted help help wanted
Extra attention is needed High
High Priority impossible invalid
This doesn't seem right investigating k8s Low
Low Priority Medium
Medium Priority News prerelease bug question
Further information is requested resolved Unknown wontfix
This will not be worked on
Apply labels
Clear labels
bug
Something isn't working dependencies
Pull requests that update a dependency file discussion doc
Improvements or additions to documentation duplicate
This issue or pull request already exists feature-request
New feature or request good first issue
Good for newcomers hacktoberfest hacktoberfest-accepted help help wanted
Extra attention is needed High
High Priority impossible invalid
This doesn't seem right investigating k8s Low
Low Priority Medium
Medium Priority News prerelease bug question
Further information is requested resolved Unknown wontfix
This will not be worked on
No Label
bug
dependencies
discussion
doc
duplicate
feature-request
good first issue
hacktoberfest
hacktoberfest-accepted
help
help wanted
High
impossible
invalid
investigating
k8s
Low
Medium
News
prerelease bug
question
resolved
Unknown
wontfix
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
This pull request currently doesn't have any dependencies.
Reference in new issue
There is no content yet.
Delete Branch 'deefdragon/notif-tests'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
This is a PR of tests for the notifications. The SMTP notification tests first included only test the expected route, and do not cover any of the custom subject code.
This is mostly to confirm that this format is valid for usage with the rest of the notifications, but when approved, both erroring routes, and custom subjects will be tested.
It is amazing! Thanks for the big work.
However, I am still concerning that, because the tests only checked whether it is called correctly and it is not actually call to the API. Is it really enough to ensure everything is correct?
It is because unexpected situations would come from the other ends.
There were/still will be some required manual tests for major changes to the notifications to make sure that everything is proper, but that's really unavoidable, and I think the automated tests here are, if nothing else, a really good way to double check work (I have ~half a dozen small fixes and 2-3 TODOs already in the code from the first 5 notifiers). To go much further would be testing the services themselves anyway, which is out of scope of automated tests.
TLDR: Yes I think its enough if combined with the (already done IIRC) manual validation.
As a side note: Outside of SMTP, and apprise, its "create an object, and pass it to some transport". Both apprise and smtp are only barely exceptions, apprise using the message and URLs separately, and smtp having to build the transport internally.
It feels like there should be a way to make everything more flexible for future messages, but I am still thinking on it.
So that is what I am concerning, because eventually I am not able to test all of them manually. Because:
And why I accept these pull requests in the first place if I can't test it, because they shown me the screenshots.
In other words, #751 should not apply all notification providers in this stage, just because of testing problems.
It should only apply to providers which I am able to test it manually.
If you understand what I mean, I could mark them in the classes.
Like:
======
And sorry about that, usually I won't be that harsh. However, notification is a core feature of Uptime Kuma definitely. Most users are depending on it, so stable is always the highest priority in this part. If I don't take this seriously, it will be another 'statping' which just buggy and don't send any notification.
Also unpredictable bugs are always unpredictable. In the past, for example, #436. Although I tested working on many platforms, once it released, some users reported that their containers were not able to start after updated.
I will say that by large changes, I mean addition of a new notification/the notification's api changes, but I get the feelings expressed.
I think a lot of this problem boils down to the fact that a lot of the work on the notifications side is custom per notification.
If it was possible to just trust the notifications to send the message, then any future changes would just need to be done to
server/notification.js
, leaving most of the implementations alone. Right now, many notifications are creating custom objects based on the heartbeat/monitor.-- brainstorming --
The simplest solution would be to limit to just sending raw strings, and move message parsing to
server/notification.js
, but this would mean that a number features such as the cards in slack/discord etc. would be removed, and email subjects would not be possible.A complicated potential option,( and yes I am bringing this back to templates, apologies for the one track mind RN) might be something like this
Unfortunately, to reach the same level of features, you need to develop some complex templates for discord etc, which just moves the problem back to the template construction.
It should be easier to test the templates in this form mind, as the inputs and outputs from
notification.send
will be much more predictable & comparable to the default, but its not perfect, and it would take time to implement.This is a problem that likely needs fixing, regardless of the solution chosen (if its not possible to test the notifications for future changes, then it becomes much more difficult to add other notifications like for certificates), but trying to fix it almost creates more problems.
Assuming these all pass, this is ready to be reviewed & merged.
@deefdragon Working on adding tests for the newly added click send SMS notification integration.
Do I need to create a new branch and PR for it?
@tarun7singh yeah, new PR is needed. Mind, @louislam needs to merge this one in first.
Wondering it is able to put all *.spec.js in the
test
directory?I can move the tests if you wish, but I would advise against that kind of layout. Having all tests in one directory/a mirrored test directory tree can lead to a very messy/difficult to upkeep structure, whereas having the tests next to the code they test makes it a lot easier to work on them. (No need for
../../../src/server/foo
for example. Just./foo
)I don't know if/how Vue auto-generates tests, but with angular, when components are generated, the tests are generated at the same time, in the same folder. Go uses a similar layout.