From 34937247ee5a8d1d5a6f031e0c5aab7b2eb0602c Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Wed, 15 Apr 2026 03:28:14 +0000 Subject: [PATCH] test: add overlay debounce tests --- tests/test_crisis_overlay_focus_trap.py | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_crisis_overlay_focus_trap.py b/tests/test_crisis_overlay_focus_trap.py index f657afc..c3d05b6 100644 --- a/tests/test_crisis_overlay_focus_trap.py +++ b/tests/test_crisis_overlay_focus_trap.py @@ -53,5 +53,36 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase): ) + def test_overlay_debounce_rate_limiting(self): + """Crisis overlay has 10-minute debounce to prevent spam.""" + self.assertRegex( + self.html, + r"_lastOverlayShownTime", + 'Expected overlay debounce timestamp variable.', + ) + self.assertRegex( + self.html, + r"OVERLAY_DEBOUNCE_MS\s*=\s*10\s*\*\s*60\s*\*\s*1000", + 'Expected 10-minute debounce window (600000ms).', + ) + self.assertRegex( + self.html, + r"Date\.now\(\)\s*-\s*_lastOverlayShownTime.*OVERLAY_DEBOUNCE_MS", + 'Expected showOverlay to check time since last shown.', + ) + + def test_overlay_force_bypasses_debounce(self): + """showOverlay(force) bypasses rate limiting for manual access.""" + self.assertRegex( + self.html, + r"function\s+showOverlay\s*\(\s*force\s*\)", + 'Expected showOverlay to accept force parameter.', + ) + self.assertRegex( + self.html, + r"!force\s*&&", + 'Expected force flag to bypass debounce check.', + ) + if __name__ == '__main__': unittest.main()