diff --git a/frontend/src/components/SecurityWarningModal.tsx b/frontend/src/components/SecurityWarningModal.tsx index 9a3e9e1..ae93147 100644 --- a/frontend/src/components/SecurityWarningModal.tsx +++ b/frontend/src/components/SecurityWarningModal.tsx @@ -55,6 +55,12 @@ export function SecurityWarningModal({ health }: SecurityWarningModalProps) { } }, [shouldWarn]); + useEffect(() => { + if (health?.bots_disabled !== true) { + setBotsDisabledLocally(false); + } + }, [health?.bots_disabled, health?.bots_disabled_source]); + if (!shouldWarn) { return null; } diff --git a/frontend/src/test/securityWarningModal.test.tsx b/frontend/src/test/securityWarningModal.test.tsx index 7bf26e8..287555a 100644 --- a/frontend/src/test/securityWarningModal.test.tsx +++ b/frontend/src/test/securityWarningModal.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { beforeEach, describe, expect, it, vi } from 'vitest'; @@ -95,4 +95,25 @@ describe('SecurityWarningModal', () => { expect(mocks.toast.success).toHaveBeenCalledWith('Bots disabled until restart'); expect(screen.queryByText('Unprotected bot execution is enabled')).not.toBeInTheDocument(); }); + + it('shows the warning again after temporary bot disable disappears on a later health update', async () => { + const user = userEvent.setup(); + const { rerender } = render(); + + await user.click(screen.getByRole('button', { name: 'Disable Bots Until Server Restart' })); + expect(screen.queryByText('Unprotected bot execution is enabled')).not.toBeInTheDocument(); + + rerender( + + ); + expect(screen.queryByText('Unprotected bot execution is enabled')).not.toBeInTheDocument(); + + rerender(); + + await waitFor(() => { + expect(screen.getByText('Unprotected bot execution is enabled')).toBeInTheDocument(); + }); + }); });