Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Exercise SMTP rate-limit loss through the actual save owner
pulse-triage[bot]9734adadfaef
diff --git a/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712.test.ts b/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712.test.tsindex e510c6d050..cc328a8163 100644--- a/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712.test.ts+++ b/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712.test.ts@@ -83,7 +83,7 @@ describe('buildEmailConfigPayload — branch coverage (batch 2)', () => {// -----------------------------------------------------------------------// Exact payload shape — toStrictEqual verifies that UI-only fields- // (replyTo, maxRetries, retryDelay, rateLimit) are absent from the+ // (replyTo, maxRetries, retryDelay) are absent from the// output and that falsy scalar values pass through unchanged.// -----------------------------------------------------------------------describe('payload shape', () => {@@ -117,16 +117,14 @@ describe('buildEmailConfigPayload — branch coverage (batch 2)', () => {to: ['[email protected]'],tls: false,startTLS: false,+ rateLimit: 100,minimumSeverity: 'all',});});- it('does not include rateLimit in the payload even when set in the UI config', () => {- // SUSPECTED SOURCE BUG: UIEmailConfig.rateLimit is required but- // buildEmailConfigPayload never forwards it to the backend payload.- // See GLM_REPORT.md.+ it('includes the rate limit already supported by the email API', () => {const result = buildEmailConfigPayload(makeUIEmailConfig({ rateLimit: 100 }));- expect(result).not.toHaveProperty('rateLimit');+ expect(result).toHaveProperty('rateLimit', 100);});it('does not include replyTo, maxRetries, or retryDelay in the payload', () => {diff --git a/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsx b/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsxnew file mode 100644index 0000000000..28bdf148b8--- /dev/null+++ b/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsx@@ -0,0 +1,139 @@+import { cleanup, fireEvent, render, renderHook, screen, waitFor } from '@solidjs/testing-library';+import { Show, createSignal, onMount } from 'solid-js';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { apiFetchJSON } from '@/utils/apiClient';+import { AlertEmailDestinationsSection } from '../AlertEmailDestinationsSection';+import { useAlertDestinationsState } from '../useAlertDestinationsState';++vi.mock('@/utils/apiClient', () => ({ apiFetchJSON: vi.fn() }));+vi.mock('@/stores/license', () => ({ hasFeature: () => false }));+vi.mock('@/api/alerts', () => ({+ AlertsAPI: {+ getDeadManConfig: vi.fn().mockResolvedValue({ pingUrl: '', configured: false }),+ updateDeadManConfig: vi.fn().mockResolvedValue({ success: true, configured: false }),+ },+}));++const savedConfig = {+ enabled: true,+ provider: '',+ server: 'smtp.example.test',+ port: 587,+ username: '[email protected]',+ password: '***REDACTED***',+ from: '[email protected]',+ to: ['[email protected]'],+ tls: false,+ startTLS: true,+ rateLimit: 17,+ tagFilter: ['production'],+ tagFilterMode: 'any',+ minimumSeverity: 'warning',+};++function writtenEmailConfig() {+ const calls = vi.mocked(apiFetchJSON).mock.calls.filter(+ ([path, options]) => path === '/api/notifications/email' && options?.method === 'PUT',+ );+ expect(calls).toHaveLength(1);+ return JSON.parse(String(calls[0][1]?.body));+}++describe('email rate-limit persistence', () => {+ let loadedRateLimit: number | undefined;++ beforeEach(() => {+ loadedRateLimit = 17;+ vi.mocked(apiFetchJSON).mockReset();+ vi.mocked(apiFetchJSON).mockImplementation(async (path, options) => {+ if (path === '/api/notifications/email') {+ return options?.method === 'PUT'+ ? { success: true }+ : { ...savedConfig, rateLimit: loadedRateLimit };+ }+ if (path === '/api/notifications/apprise') return { enabled: false, targets: [] };+ if (path === '/api/notifications/webhooks' || path === '/api/notifications/email/providers')+ return [];+ throw new Error('Unexpected synthetic API call');+ });+ });++ afterEach(cleanup);++ it('keeps the loaded rate limit when saving an unrelated email edit', async () => {+ const { result } = renderHook(() =>+ useAlertDestinationsState({ activeTab: () => 'destinations' }),+ );+ await result.loadDestinations();+ result.setEmailConfig({ ...result.emailConfig(), from: '[email protected]' });+ await result.saveDestinations();++ expect(writtenEmailConfig()).toEqual({ ...savedConfig, from: '[email protected]' });+ });++ it.each([0, 1, 120])('preserves an explicit saved rate limit of %i on the wire', async (limit) => {+ loadedRateLimit = limit;+ const { result } = renderHook(() =>+ useAlertDestinationsState({ activeTab: () => 'destinations' }),+ );+ await result.loadDestinations();+ await result.saveDestinations();++ expect(writtenEmailConfig().rateLimit).toBe(limit);+ });++ it('sends the existing default when the saved config has no rate limit', async () => {+ loadedRateLimit = undefined;+ const { result } = renderHook(() =>+ useAlertDestinationsState({ activeTab: () => 'destinations' }),+ );+ await result.loadDestinations();+ await result.saveDestinations();++ expect(writtenEmailConfig().rateLimit).toBe(60);+ });++ it('saves the rate limit entered in the actual SMTP editor through its mutation owner', async () => {+ function Fixture() {+ const state = useAlertDestinationsState({ activeTab: () => 'destinations' });+ const [ready, setReady] = createSignal(false);+ const [saved, setSaved] = createSignal(false);+ onMount(async () => {+ await state.loadDestinations();+ setReady(true);+ });+ return (+ <Show when={ready()}>+ <AlertEmailDestinationsSection+ config={state.emailConfig()}+ setConfig={state.setEmailConfig}+ setHasUnsavedChanges={() => {}}+ onTest={() => {+ throw new Error('No notification test is allowed in this fixture');+ }}+ testing={false}+ />+ <button+ onClick={async () => {+ await state.saveDestinations();+ setSaved(true);+ }}+ >+ Save changes+ </button>+ <Show when={saved()}>Saved</Show>+ </Show>+ );+ }+ render(() => <Fixture />);+ fireEvent.click(await screen.findByRole('button', { name: 'Advanced settings' }));+ const input = screen.getByRole('spinbutton', { name: 'Rate limit' });+ expect(input).toHaveValue(17);+ fireEvent.input(input, { target: { value: '12' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save changes' }));+ await waitFor(() => expect(screen.getByText('Saved')).toBeInTheDocument());++ expect(writtenEmailConfig()).toEqual({ ...savedConfig, rateLimit: 12 });+ });+});