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
Preserve SMTP rate limits and allow safe editing while email is off
pulse-triage[bot]d25c56ad44f2
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 44d19f48f2..f9cb544e8f 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -4298,6 +4298,27 @@ Formatting-only follow-up retains this warning-level contract. The production-cobrowser matrix was rerun after formatting at desktop and narrow widths, includingall/critical/warning save/reload, cancel, and warning webhook creation.+### SMTP rate-limit preference persistence++The existing SMTP editor's rate limit is included by+`alertDestinationsModel.buildEmailConfigPayload` on every destination save.+Unrelated email edits and switching email off must preserve the loaded limit;+an explicitly edited limit must reach the existing Notifications API unchanged.+Zero remains the backend's default-limit sentinel, not an omitted or unlimited+value. Missing saved limits still use the existing UI default of 60 per minute.+SMTP masks, TLS settings, recipients, tags and severity preferences are unchanged.+This repairs a missing UI-to-API field, not the schema or transport policy.+Revealing switched-off email settings permits pointer and keyboard editing without+enabling email. The status toggle remains off and Send test email stays disabled.++`emailRateLimit.persistence.test.tsx` connects the actual SMTP editor, destination+mutation owner, payload builder and email API to synthetic wire assertions.+The two payload-shape suites retain strict key checks including `rateLimit`.+`browser-tests/email-rate-limit.cjs` checks save and readback on desktop and phone,+including unrelated edits, disabled email and legacy zero. These fixtures do not+send notifications or establish native SMTP throughput, release availability or+the cause of an existing delivery failure.+### Pulse Mobile push destination without an upsellThe Alerts destinations page renders the mobile push panel only when thediff --git a/frontend-modern/browser-tests/email-rate-limit.cjs b/frontend-modern/browser-tests/email-rate-limit.cjsnew file mode 100644index 0000000000..53545ccdf2--- /dev/null+++ b/frontend-modern/browser-tests/email-rate-limit.cjs@@ -0,0 +1,258 @@+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');+const crypto = require('node:crypto');+const { chromium, webkit } = require('playwright');++const root = '/workspace/frontend-modern';+const output = '/workspace/tmp/email-rate-limit-proof';+const runtimePath = 'frontend-modern/src/features/alerts/alertDestinationsModel.ts';+const runtimePaths = [+ runtimePath,+ 'frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx',+];+const baseEmail = {+ 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',+};++(async () => {+ fs.mkdirSync(output, { recursive: true });+ const playwrightVersion = require('playwright/package.json').version;+ assert.equal(+ playwrightVersion,+ JSON.parse(fs.readFileSync('/workspace/tests/integration/package-lock.json')).packages[+ 'node_modules/@playwright/test'+ ].version,+ );+ const digests = Object.fromEntries(+ runtimePaths.map((file) => [+ file,+ crypto+ .createHash('sha256')+ .update(fs.readFileSync(path.join('/workspace', file)))+ .digest('hex'),+ ]),+ );+ const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));+ const server = await createServer({+ root,+ configFile: path.join(root, 'vite.config.ts'),+ cacheDir: path.join(output, 'vite-cache'),+ server: { host: '127.0.0.1', port: 5294, strictPort: true },+ });+ const results = [];+ let browser;+ let serverClosed = false;+ try {+ await server.listen();+ for (const [name, engine, width, height, dark] of [+ ['desktop-light', chromium, 1365, 900, false],+ ['desktop-dark', chromium, 1365, 900, true],+ ['phone-dark', webkit, 390, 844, true],+ ['narrow-light', webkit, 320, 844, false],+ ]) {+ browser = await engine.launch(+ engine === chromium+ ? { headless: true, channel: 'chromium', args: ['--no-sandbox'] }+ : { headless: true },+ );+ const browserVersion = browser.version();+ const page = await browser.newPage({+ viewport: { width, height },+ isMobile: width < 500,+ hasTouch: width < 500,+ locale: 'en-GB',+ timezoneId: 'UTC',+ colorScheme: dark ? 'dark' : 'light',+ });+ page.setDefaultTimeout(15000);+ let email = { ...baseEmail };+ const writes = [];+ const unexpected = [];+ const errors = [];+ const checks = [];+ const captures = [];+ page.on('pageerror', (error) => errors.push(error.message));+ await page.addInitScript((isDark) => {+ if (!isDark) return;+ const apply = () => document.documentElement.classList.add('dark');+ if (document.documentElement) apply();+ else document.addEventListener('DOMContentLoaded', apply, { once: true });+ }, dark);+ await page.route('**/*', async (route) => {+ const request = route.request();+ const url = new URL(request.url());+ if (url.origin !== 'http://127.0.0.1:5294') {+ unexpected.push('off-origin request');+ return route.abort();+ }+ if (!url.pathname.startsWith('/api/')) return route.continue();+ const key = `${request.method()} ${url.pathname}`;+ let body;+ if (key === 'GET /api/notifications/email') body = email;+ else if (key === 'GET /api/notifications/email-providers') body = [];+ else if (key === 'GET /api/notifications/webhooks') body = [];+ else if (key === 'GET /api/notifications/apprise') body = { enabled: false, targets: [] };+ else if (key === 'GET /api/alerts/deadman/config')+ body = { pingUrl: '', configured: false };+ else if (key === 'GET /api/health') body = { csrfToken: 'fixture-only' };+ else if (key === 'PUT /api/notifications/email') {+ const submitted = request.postDataJSON();+ assert.equal(submitted.password, baseEmail.password);+ assert.equal(submitted.tls, false);+ assert.equal(submitted.startTLS, true);+ assert.deepEqual(submitted.tagFilter, ['production']);+ assert.equal(submitted.tagFilterMode, 'any');+ assert.equal(submitted.minimumSeverity, 'warning');+ writes.push({ rateLimit: submitted.rateLimit, enabled: submitted.enabled });+ // Model the existing default only in the fixture, not in the client.+ email = { ...submitted, rateLimit: submitted.rateLimit ?? 60 };+ body = { success: true };+ } else if (key === 'PUT /api/notifications/apprise') {+ body = request.postDataJSON();+ } else if (key === 'PUT /api/alerts/deadman/config') {+ body = { success: true, configured: false };+ } else {+ unexpected.push(key);+ return route.abort();+ }+ return route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify(body),+ });+ });+ const open = async () => {+ await page.goto('http://127.0.0.1:5294/browser-tests/email-rate-limit.html');+ await page.getByRole('button', { name: 'Save changes' }).waitFor();+ assert.equal(+ await page.evaluate(() => document.documentElement.classList.contains('dark')),+ dark,+ );+ };+ const advanced = async () => {+ await page.getByRole('button', { name: 'Show advanced options' }).click();+ return page.getByRole('spinbutton', { name: 'Rate limit' });+ };+ const save = async (expectedLimit) => {+ const before = writes.length;+ await page.getByRole('button', { name: 'Save changes' }).click();+ await page+ .getByRole('status')+ .filter({ hasText: /^Saved$/ })+ .waitFor();+ assert.equal(writes.length, before + 1);+ assert.equal(writes.at(-1).rateLimit, expectedLimit);+ assert.equal(email.rateLimit, expectedLimit);+ };+ const check = async (label, run) => {+ await run();+ checks.push(label);+ };+ const capture = async (state) => {+ assert.ok(+ await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1),+ 'no horizontal overflow',+ );+ const file = `${name}-${state}.png`;+ await page.screenshot({ path: path.join(output, file), fullPage: true });+ captures.push(file);+ };+ await check('loaded non-default limit is visible', async () => {+ await open();+ assert.equal(await (await advanced()).inputValue(), '17');+ });+ await capture('loaded');+ await check('unrelated edit preserves limit, mask, TLS and routing on the wire', async () => {+ await page+ .getByRole('textbox', { name: 'From address', exact: true })+ .fill('[email protected]');+ await save(17);+ });+ await check('unrelated edit survives a reload with the same limit', async () => {+ await open();+ assert.equal(await (await advanced()).inputValue(), '17');+ assert.equal(+ await page.getByRole('textbox', { name: 'From address', exact: true }).inputValue(),+ '[email protected]',+ );+ });+ await check('edited limit is sent exactly once', async () => {+ await page.getByRole('spinbutton', { name: 'Rate limit' }).fill('12');+ await save(12);+ });+ await capture('saved');+ await check('edited limit is read back after reload', async () => {+ await open();+ assert.equal(await (await advanced()).inputValue(), '12');+ });+ await check('switching email off preserves its limit', async () => {+ await page.getByRole('button', { name: 'Email notifications Enabled' }).click();+ await save(12);+ assert.equal(email.enabled, false);+ });+ await check('switched-off settings read back the same limit', async () => {+ await open();+ await page.getByRole('button', { name: 'Show settings', exact: true }).click();+ assert.equal(await (await advanced()).inputValue(), '12');+ assert.equal(+ await page.getByRole('button', { name: 'Send test email' }).isDisabled(),+ true,+ );+ await page.getByRole('spinbutton', { name: 'Rate limit' }).fill('9');+ await save(9);+ assert.equal(email.enabled, false);+ });+ await capture('off');+ await check('legacy default sentinel zero remains zero in the saved payload', async () => {+ email = { ...baseEmail, rateLimit: 0 };+ await open();+ await save(0);+ });+ await check('no test, retry, dismissal, off-origin request or browser error', async () => {+ assert.deepEqual(unexpected, []);+ assert.deepEqual(errors, []);+ assert.equal(writes.length, 5);+ });+ results.push({ name, browserVersion, width, height, dark, checks, writes, captures });+ await browser.close();+ browser = undefined;+ }+ } finally {+ if (browser) await browser.close();+ await server.close();+ serverClosed = true;+ fs.writeFileSync(+ path.join(output, 'result.json'),+ JSON.stringify(+ {+ result: results.length === 4 ? 'passed' : 'incomplete',+ playwrightVersion,+ content_sha256: digests,+ browserClosed: true,+ serverClosed,+ results,+ },+ null,+ 2,+ ) + '\n',+ );+ }+ console.log(JSON.stringify({ result: 'passed', groups: 36, captures: 12, serverClosed }));+})().catch((error) => {+ console.error(error);+ process.exitCode = 1;+});diff --git a/frontend-modern/browser-tests/email-rate-limit.html b/frontend-modern/browser-tests/email-rate-limit.htmlnew file mode 100644index 0000000000..5c3b3dd9e9--- /dev/null+++ b/frontend-modern/browser-tests/email-rate-limit.html@@ -0,0 +1,12 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>SMTP rate-limit persistence verification</title>+ </head>+ <body>+ <div id="root"></div>+ <script type="module" src="./email-rate-limit.tsx"></script>+ </body>+</html>diff --git a/frontend-modern/browser-tests/email-rate-limit.tsx b/frontend-modern/browser-tests/email-rate-limit.tsxnew file mode 100644index 0000000000..f0aa26a35c--- /dev/null+++ b/frontend-modern/browser-tests/email-rate-limit.tsx@@ -0,0 +1,54 @@+// Existing SMTP editor and mutation owner with fixture-only persisted responses.+// No notification, retry, dismissal or licensed/native operation is performed.+import { Show, createSignal, onMount } from 'solid-js';+import { render } from 'solid-js/web';+import { AlertEmailDestinationsSection } from '../src/features/alerts/AlertEmailDestinationsSection';+import { useAlertDestinationsState } from '../src/features/alerts/useAlertDestinationsState';+import '../src/index.css';++function Fixture() {+ const state = useAlertDestinationsState({ activeTab: () => 'destinations' });+ const [ready, setReady] = createSignal(false);+ const [saving, setSaving] = createSignal(false);+ const [status, setStatus] = createSignal('');+ onMount(async () => {+ await state.loadDestinations();+ setReady(true);+ });+ return (+ <main class="mx-auto max-w-4xl p-3 text-base-content">+ <h1 class="mb-4 text-xl font-semibold">Notifications</h1>+ <Show when={ready()}>+ <AlertEmailDestinationsSection+ config={state.emailConfig()}+ setConfig={state.setEmailConfig}+ setHasUnsavedChanges={() => setStatus('Unsaved changes')}+ onTest={() => {+ throw new Error('Sending a test notification is outside this fixture');+ }}+ testing={false}+ />+ <button+ class="mt-3 rounded-md bg-blue-600 px-4 py-2 text-white"+ disabled={saving()}+ onClick={async () => {+ setSaving(true);+ try {+ await state.saveDestinations();+ setStatus('Saved');+ } catch {+ setStatus('Save failed');+ } finally {+ setSaving(false);+ }+ }}+ >+ Save changes+ </button>+ <p role="status">{status()}</p>+ </Show>+ </main>+ );+}++render(() => <Fixture />, document.getElementById('root')!);diff --git a/frontend-modern/browser-verification/226c5fee156bd820.json b/frontend-modern/browser-verification/226c5fee156bd820.jsonnew file mode 100644index 0000000000..4db0b243cc--- /dev/null+++ b/frontend-modern/browser-verification/226c5fee156bd820.json@@ -0,0 +1,114 @@+{+ "version": 1,+ "base_sha": "27576b90ff416cd16d1ef744cd299b83af4a2f36",+ "verified_at": "2026-10-10T03:40:27.414721Z",+ "result": "passed",+ "changed_paths": [+ "frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx",+ "frontend-modern/src/features/alerts/alertDestinationsModel.ts"+ ],+ "content_sha256": {+ "frontend-modern/src/features/alerts/alertDestinationsModel.ts": "1af3cc1bfcc6202d1033f56f8982a1f785a65dc93b2fd1734e1cfe124748e18c",+ "frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx": "131354cd4a7c835973173ea391a01d912e58cad0969f520c2dfb805a984bcb47"+ },+ "routes": [+ "Existing Alerts Notifications SMTP section via browser-tests/email-rate-limit.html (fixture only)"+ ],+ "viewports": [+ {+ "width": 1365,+ "height": 900+ },+ {+ "width": 1365,+ "height": 900+ },+ {+ "width": 390,+ "height": 844+ },+ {+ "width": 320,+ "height": 844+ }+ ],+ "states": [+ "Loaded non-default limit, saved unrelated edit, edited limit with reload, switched-off email with inspectable/editable settings, explicit legacy zero sentinel. Desktop light/dark and WebKit phone/narrow light."+ ],+ "interactions": [+ "Actual Email section, editor, destination mutation owner, payload builder and API client against synthetic persisted GET/PUT responses.",+ "Each viewport preserves loaded 17 through an unrelated edit, saves 12 and reloads it, switches email off then inspects/edits/saves 9 without enabling email or the Test button, and preserves zero on the wire.",+ "Thirty-six assertion groups and twelve individually inspected full-page captures. Masks, STARTTLS, tag routing and warning severity remain unchanged. No Test, retry, dismissal, Relay/native operation or external/provider request."+ ],+ "screenshots": [+ {+ "file": "desktop-light-loaded.png",+ "sha256": "bec915910540fd8f0936531b5e5a47723baf2eeeac0be774b839a3b5738da4da"+ },+ {+ "file": "desktop-light-saved.png",+ "sha256": "555902f2581fff7237f187fe9d34908ad5c1c1dc06f11ce3e856012f3c974455"+ },+ {+ "file": "desktop-light-off.png",+ "sha256": "54a29af969607ac81f63dee0c1120b7a508023bdba154cf790b1d31cb5153811"+ },+ {+ "file": "desktop-dark-loaded.png",+ "sha256": "f9ca2e82f774dbeee06f8d310da6832bbb612d501bed7e72fd7ac7c1da0d15ef"+ },+ {+ "file": "desktop-dark-saved.png",+ "sha256": "47575ae1a3fe600054e2dbb5a42f93b7d13049495b7b656ba1c9a8b915110a24"+ },+ {+ "file": "desktop-dark-off.png",+ "sha256": "2f0186f278b17996175e564b98c42670fbc01f393b4b7d0a7941ccc2324086c2"+ },+ {+ "file": "phone-dark-loaded.png",+ "sha256": "51bfbe5bda8b7a0a434a8c7de684c76b4995c6ab265fc3ffda66a3836c7482da"+ },+ {+ "file": "phone-dark-saved.png",+ "sha256": "9f70f6c89242953b9e301b70f094c01b3cf3dae4fc2b5be831f39eb3106eb89d"+ },+ {+ "file": "phone-dark-off.png",+ "sha256": "689c31341391f6102646d60a43e58089754ba11251d1725378fa2fd25e3ea4ba"+ },+ {+ "file": "narrow-light-loaded.png",+ "sha256": "43bbf97b82cd562d151f80c04e8cc75d3b74003c5330c3533a923ca0a8a1aea1"+ },+ {+ "file": "narrow-light-saved.png",+ "sha256": "f48237f0ebe5a6365cae3c9b52c7a86efe71660cb733bc4301818f2c5cd9fa24"+ },+ {+ "file": "narrow-light-off.png",+ "sha256": "902b2cb9af2dba6429c1a64824a4b9dd9bc9962c271dc4b7bf4314eddf5f3d38"+ }+ ],+ "tools": {+ "playwright": "1.56.1",+ "browser_versions": [+ {+ "name": "desktop-light",+ "version": "141.0.7390.37"+ },+ {+ "name": "desktop-dark",+ "version": "141.0.7390.37"+ },+ {+ "name": "phone-dark",+ "version": "26.0"+ },+ {+ "name": "narrow-light",+ "version": "26.0"+ }+ ]+ }+}diff --git a/frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx b/frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsxindex 563b8649fb..e0ebeedef8 100644--- a/frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx+++ b/frontend-modern/src/features/alerts/AlertEmailDestinationsSection.tsx@@ -67,10 +67,7 @@ export function AlertEmailDestinationsSection(props: AlertEmailDestinationsSecti/>}>- <div- ref={settingsRegion}- class={`${!props.config.enabled ? 'pointer-events-none opacity-50 transition-opacity' : 'transition-opacity'}`}- >+ <div ref={settingsRegion}><EmailProviderSelectconfig={props.config}onChange={(config) => {diff --git a/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712c.test.ts b/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712c.test.tsindex 0ca707d6bb..13c893e70a 100644--- a/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712c.test.ts+++ b/frontend-modern/src/features/alerts/__tests__/alertDestinationsModel.branchcov0712c.test.ts@@ -144,7 +144,7 @@ describe('buildEmailConfigPayload — branch coverage (batch 3 / 0712c)', () =>// the value-level toStrictEqual checks in the sibling suite.// -----------------------------------------------------------------------describe('payload contract — exact key set', () => {- it('emits exactly the EmailConfig keys in declaration order and omits replyTo/maxRetries/retryDelay/rateLimit', () => {+ it('emits exactly the EmailConfig keys including rateLimit and omits UI-only fields', () => {const result = buildEmailConfigPayload(makeUIEmailConfig({replyTo: '[email protected]',@@ -164,14 +164,13 @@ describe('buildEmailConfigPayload — branch coverage (batch 3 / 0712c)', () =>'to','tls','startTLS',+ 'rateLimit','minimumSeverity',]);expect(result).not.toHaveProperty('replyTo');expect(result).not.toHaveProperty('maxRetries');expect(result).not.toHaveProperty('retryDelay');- // rateLimit exists on EmailConfig (optional) yet is never- // forwarded — see GLM_REPORT.md (suspected source bug).- expect(result).not.toHaveProperty('rateLimit');+ expect(result).toHaveProperty('rateLimit', 50);});});diff --git a/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsx b/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsxindex da5c07fbd0..a957fef5a8 100644--- a/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsx+++ b/frontend-modern/src/features/alerts/__tests__/emailRateLimit.persistence.test.tsx@@ -33,30 +33,38 @@ const savedConfig = {};function writtenEmailConfig() {- const calls = vi.mocked(apiFetchJSON).mock.calls.filter(- ([path, options]) => path === '/api/notifications/email' && options?.method === 'PUT',- );+ 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;+ let loadedEnabled: boolean;beforeEach(() => {loadedRateLimit = 17;+ loadedEnabled = true;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');- });+ vi.mocked(apiFetchJSON).mockImplementation(+ async <T,>(path: string, options?: Parameters<typeof apiFetchJSON>[1]): Promise<T> => {+ if (path === '/api/notifications/email') {+ return (+ options?.method === 'PUT'+ ? { success: true }+ : { ...savedConfig, rateLimit: loadedRateLimit, enabled: loadedEnabled }+ ) as T;+ }+ if (path === '/api/notifications/apprise') return { enabled: false, targets: [] } as T;+ if (path === '/api/notifications/webhooks' || path === '/api/notifications/email-providers')+ return [] as T;+ throw new Error('Unexpected synthetic API call');+ },+ );});afterEach(cleanup);@@ -72,16 +80,19 @@ describe('email rate-limit persistence', () => {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();+ 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);- });+ expect(writtenEmailConfig().rateLimit).toBe(limit);+ },+ );it('sends the existing default when the saved config has no rate limit', async () => {loadedRateLimit = undefined;@@ -94,46 +105,54 @@ describe('email rate-limit persistence', () => {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: 'Show advanced options' }));- 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());+ it.each([true, false])(+ 'saves an edited rate limit while email enabled is %s',+ async (enabled) => {+ loadedEnabled = enabled;+ 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 />);+ if (!enabled) {+ fireEvent.click(await screen.findByRole('button', { name: 'Show settings' }));+ expect(screen.getByRole('button', { name: 'Send test email' })).toBeDisabled();+ }+ fireEvent.click(await screen.findByRole('button', { name: 'Show advanced options' }));+ 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 });- });+ expect(writtenEmailConfig()).toEqual({ ...savedConfig, rateLimit: 12, enabled });+ },+ );});diff --git a/frontend-modern/src/features/alerts/alertDestinationsModel.ts b/frontend-modern/src/features/alerts/alertDestinationsModel.tsindex 6e33c860a8..b29b9865df 100644--- a/frontend-modern/src/features/alerts/alertDestinationsModel.ts+++ b/frontend-modern/src/features/alerts/alertDestinationsModel.ts@@ -42,6 +42,7 @@ export function buildEmailConfigPayload(config: UIEmailConfig): EmailConfig {to: config.to.map((entry) => entry.trim()).filter((entry) => entry.length > 0),tls: config.tls,startTLS: config.startTLS,+ rateLimit: config.rateLimit,};if (config.tagFilter !== undefined) {payload.tagFilter = config.tagFilter;