test: add overlay debounce tests
All checks were successful
Sanity Checks / sanity-test (pull_request) Successful in 11s
Smoke Test / smoke (pull_request) Successful in 24s

This commit is contained in:
2026-04-15 03:28:14 +00:00
parent e9d409641e
commit 34937247ee

View File

@@ -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()