feat(watchlist): add "Send test" button to verify webhook URL before first alert#208
Merged
Merged
Conversation
Closes NovaCode37#179. When configuring a webhook URL on a watchlist there was no way to confirm it worked until the first scheduled alert fired — potentially hours later. Changes ------- web/app.py Added TestWebhookRequest model and POST /api/watchlist/test-webhook endpoint. Reuses existing _validate_webhook_url (SSRF protection) and _send_webhook (delivery + Slack formatting) so no new webhook logic is introduced. Returns {ok: true, url} on success or {error} on 400/502. frontend/src/lib/api.ts Added testWebhook() function calling POST /api/watchlist/test-webhook. frontend/src/components/views/WatchlistView.tsx Added testingWebhook and webhookTestResult state. Added handleTestWebhook handler. Added 'Send test' button inline with the webhook input. Shows green success / red error message below the field after each attempt. Clears result when the URL is edited. tests/test_webhook.py Added TestTestWebhookEndpoint class with 5 tests: test_returns_ok_on_success test_rejects_private_url test_rejects_invalid_scheme test_requires_api_key test_payload_shape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #179.
Problem
When adding a webhook URL to a watchlist entry, there was no way to
confirm it was reachable or correctly formatted until the first scheduled
alert fired — which could be hours away.
What changed
web/app.pyAdded
POST /api/watchlist/test-webhookendpoint. Reuses the existing_validate_webhook_url(SSRF protection) and_send_webhook(delivery{"ok": true, "url": "..."}on success, or{"error": "..."}onvalidation failure (400) or delivery failure (502).
frontend/src/lib/api.tsAdded
testWebhook()calling the new endpoint.frontend/src/components/views/WatchlistView.tsxtestingWebhookandwebhookTestResultstatehandleTestWebhookhandlertests/test_webhook.pyAdded
TestTestWebhookEndpointwith 5 tests covering: success response,private URL rejection, invalid scheme rejection, missing API key, and
payload shape.
Tests
221 passed, 19 warnings
All pre-existing tests pass alongside the 5 new endpoint tests.