# Telegram Notification Provider — Test Failure Remediation Plan **Date:** 2026-03-11 **Author:** Planning Agent **Status:** Remediation Required — All security scans pass, test failures block merge **Previous Plan:** Archived as `docs/plans/telegram_implementation_spec.md` --- ## 1. Introduction The Telegram notification provider feature is functionally complete with passing security scans and coverage gates. However, **56 E2E test failures** and **2 frontend unit test failures** block the PR merge. This plan identifies root causes, categorises each failure set, and provides specific remediation steps. ### Failure Summary | Spec File | Failures | Browsers | Unique Est. | Category | |---|---|---|---|---| | `notifications.spec.ts` | 48 | 3 | ~16 | **Our change** | | `notifications-payload.spec.ts` | 18 | 3 | ~6 | **Our change** | | `telegram-notification-provider.spec.ts` | 4 | 1–3 | ~2 | **Our change** | | `encryption-management.spec.ts` | 20 | 3 | ~7 | Pre-existing | | `auth-middleware-cascade.spec.ts` | 18 | 3 | 6 | Pre-existing | | `Notifications.test.tsx` (unit) | 2 | — | 2 | **Our change** | CI retries: 2 per test (`playwright.config.js` L144). Failure counts above represent unique test failures × browser projects. --- ## 2. Root Cause Analysis ### Root Cause A: `isNew` Guard on Test Button (CRITICAL — Causes ~80% of failures) **What changed:** The Telegram feature added a guard in `Notifications.tsx` (L117-124) that blocks the "Test" button for new (unsaved) providers: ```typescript // Line 117-124: handleTest() early return guard const handleTest = () => { const formData = watch(); const currentType = normalizeProviderType(formData.type); if (!formData.id && currentType !== 'email') { toast.error(t('notificationProviders.saveBeforeTesting')); return; } testMutation.mutate({ ...formData, type: currentType } as Partial); }; ``` And a `disabled` attribute on the test button at `Notifications.tsx` (L382): ```typescript // Line 382: Button disabled state disabled={testMutation.isPending || (isNew && !isEmail)} ``` **Why it was added:** The backend `Test` handler at `notification_provider_handler.go` (L333-336) requires a saved provider ID for all non-email types. For Gotify/Telegram, the server needs the stored token. For Discord/Webhook, the server still fetches the provider from DB. Without a saved provider, the backend returns `MISSING_PROVIDER_ID`. **Why it breaks tests:** Many existing E2E and unit tests click the test button from a **new (unsaved) provider form** using mocked endpoints. With the new guard: 1. The `