Skip to content

feat(watchlist): add "Send test" button to verify webhook URL before first alert#208

Merged
NovaCode37 merged 1 commit into
NovaCode37:mainfrom
Maqbool61:feat/test-webhook-button
Jul 13, 2026
Merged

feat(watchlist): add "Send test" button to verify webhook URL before first alert#208
NovaCode37 merged 1 commit into
NovaCode37:mainfrom
Maqbool61:feat/test-webhook-button

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

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.py
Added POST /api/watchlist/test-webhook endpoint. Reuses the 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
    validation failure (400) or delivery failure (502).

frontend/src/lib/api.ts
Added testWebhook() calling the new endpoint.

frontend/src/components/views/WatchlistView.tsx

  • Added testingWebhook and webhookTestResult state
  • Added handleTestWebhook handler
  • Added Send test button inline with the webhook URL input
  • Shows green success / red error message below the field after each attempt
  • Result clears automatically when the URL is edited

tests/test_webhook.py
Added TestTestWebhookEndpoint with 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.

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
@Maqbool61 Maqbool61 requested a review from NovaCode37 as a code owner July 13, 2026 08:14
@NovaCode37 NovaCode37 merged commit 432bae1 into NovaCode37:main Jul 13, 2026
4 checks passed
@Maqbool61 Maqbool61 deleted the feat/test-webhook-button branch July 13, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a 'Send test webhook' button to the watchlist form

2 participants