test: add overlay debounce tests
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user