Compare commits
2 Commits
fix/issue-
...
fix/98-off
| Author | SHA1 | Date | |
|---|---|---|---|
| b76bc4e517 | |||
| 5d1d0dc838 |
@@ -206,6 +206,18 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="panel" aria-labelledby="resources-title">
|
||||
<h2 class="section-title" id="resources-title">More crisis lines</h2>
|
||||
<ul>
|
||||
<li><strong>National Domestic Violence Hotline</strong> — call 1-800-799-7233 or text START to 88788</li>
|
||||
<li><strong>Trevor Project</strong> (LGBTQ youth) — call 1-866-488-7386 or text START to 678-678</li>
|
||||
<li><strong>Veterans Crisis Line</strong> — call 988 then press 1, or text 838255</li>
|
||||
<li><strong>SAMHSA Helpline</strong> (substance use) — call 1-800-662-4357</li>
|
||||
<li><strong>Trans Lifeline</strong> — call 877-565-8860</li>
|
||||
</ul>
|
||||
<p class="small" style="margin-top: 14px;">All lines are free, confidential, and available 24/7.</p>
|
||||
</section>
|
||||
|
||||
<section class="panel" aria-labelledby="hope-title">
|
||||
<h2 class="section-title" id="hope-title">Stay through the next ten minutes</h2>
|
||||
<p>Do not solve your whole life right now. Stay for the next breath. Then the next one.</p>
|
||||
|
||||
17
index.html
17
index.html
@@ -1029,12 +1029,12 @@ Sovereignty and service always.`;
|
||||
overlayDismissBtn.textContent = 'Continue to chat (' + countdown + 's)';
|
||||
|
||||
// Disable background interaction via inert attribute
|
||||
var mainApp = document.getElementById('app');
|
||||
var mainApp = document.querySelector('.app');
|
||||
if (mainApp) mainApp.setAttribute('inert', '');
|
||||
// Also hide from assistive tech
|
||||
var chatSection = document.getElementById('chat-area');
|
||||
var chatSection = document.getElementById('chat');
|
||||
if (chatSection) chatSection.setAttribute('aria-hidden', 'true');
|
||||
var footerEl = document.getElementById('footer');
|
||||
var footerEl = document.querySelector('footer');
|
||||
if (footerEl) footerEl.setAttribute('aria-hidden', 'true');
|
||||
|
||||
if (overlayTimer) clearInterval(overlayTimer);
|
||||
@@ -1050,10 +1050,7 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
var overlayCallLink = crisisOverlay.querySelector('.overlay-call');
|
||||
if (overlayCallLink && typeof overlayCallLink.focus === 'function') {
|
||||
overlayCallLink.focus();
|
||||
}
|
||||
overlayDismissBtn.focus();
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
@@ -1068,11 +1065,11 @@ Sovereignty and service always.`;
|
||||
}
|
||||
|
||||
// Re-enable background interaction
|
||||
var mainApp = document.getElementById('app');
|
||||
var mainApp = document.querySelector('.app');
|
||||
if (mainApp) mainApp.removeAttribute('inert');
|
||||
var chatSection = document.getElementById('chat-area');
|
||||
var chatSection = document.getElementById('chat');
|
||||
if (chatSection) chatSection.removeAttribute('aria-hidden');
|
||||
var footerEl = document.getElementById('footer');
|
||||
var footerEl = document.querySelector('footer');
|
||||
if (footerEl) footerEl.removeAttribute('aria-hidden');
|
||||
|
||||
// Restore focus to the element that had it before the overlay opened
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import pathlib
|
||||
import re
|
||||
import unittest
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
INDEX_HTML = ROOT / 'index.html'
|
||||
|
||||
|
||||
class TestCrisisOverlayInitialFocus(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.html = INDEX_HTML.read_text()
|
||||
|
||||
def test_overlay_focuses_enabled_call_link_on_open(self):
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"overlayCallLink\s*=\s*crisisOverlay\.querySelector\('\.overlay-call'\)",
|
||||
'Expected showOverlay() to capture the enabled 988 call link as the initial focus target.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"overlayCallLink\.focus\(\)",
|
||||
'Expected showOverlay() to focus the enabled 988 call link on open.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"overlayDismissBtn\.focus\(\)",
|
||||
'Initial focus should not target the disabled dismiss button.',
|
||||
)
|
||||
|
||||
def test_overlay_uses_live_dom_targets_for_background_locking(self):
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('app'\)",
|
||||
'Expected overlay to inert the live #app container.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('chat-area'\)",
|
||||
'Expected overlay to hide the live #chat-area region from assistive tech while active.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"document\.querySelector\('\.app'\)",
|
||||
'The overlay should not target a nonexistent .app selector.',
|
||||
)
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"document\.getElementById\('chat'\)",
|
||||
'The overlay should not target a nonexistent #chat region.',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
52
tests/test_offline_crisis.py
Normal file
52
tests/test_offline_crisis.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
Test: offline crisis resources load when network is unavailable.
|
||||
|
||||
Verifies that the service worker caches the crisis-offline.html page
|
||||
and that it serves as the navigation fallback when offline.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def test_service_worker_precaches_crisis_page():
|
||||
"""Service worker precache list includes crisis-offline.html."""
|
||||
sw_path = os.path.join(os.path.dirname(__file__), '..', 'sw.js')
|
||||
with open(sw_path) as f:
|
||||
sw_content = f.read()
|
||||
assert '/crisis-offline.html' in sw_content, "crisis-offline.html must be in PRECACHE_ASSETS"
|
||||
|
||||
def test_crisis_offline_page_has_988():
|
||||
"""Offline page contains 988 call link."""
|
||||
page_path = os.path.join(os.path.dirname(__file__), '..', 'crisis-offline.html')
|
||||
with open(page_path) as f:
|
||||
content = f.read()
|
||||
assert 'tel:988' in content, "Offline page must have 988 call link"
|
||||
assert '741741' in content, "Offline page must have Crisis Text Line (741741)"
|
||||
|
||||
def test_crisis_offline_page_has_local_resources():
|
||||
"""Offline page contains additional local crisis resources."""
|
||||
page_path = os.path.join(os.path.dirname(__file__), '..', 'crisis-offline.html')
|
||||
with open(page_path) as f:
|
||||
content = f.read()
|
||||
assert 'National Domestic Violence Hotline' in content, "Must include domestic violence hotline"
|
||||
assert 'Trevor Project' in content, "Must include Trevor Project"
|
||||
assert 'Veterans Crisis Line' in content, "Must include Veterans Crisis Line"
|
||||
|
||||
def test_crisis_offline_page_self_contained():
|
||||
"""Offline page must work without external resources (inline styles, no external scripts)."""
|
||||
page_path = os.path.join(os.path.dirname(__file__), '..', 'crisis-offline.html')
|
||||
with open(page_path) as f:
|
||||
content = f.read()
|
||||
# No external CSS files
|
||||
assert 'rel="stylesheet"' not in content, "Offline page must not depend on external stylesheets"
|
||||
# No external JS files
|
||||
assert '<script src=' not in content, "Offline page must not depend on external scripts"
|
||||
|
||||
def test_offline_fallback_path_configured():
|
||||
"""Service worker configures crisis-offline.html as the offline fallback."""
|
||||
sw_path = os.path.join(os.path.dirname(__file__), '..', 'sw.js')
|
||||
with open(sw_path) as f:
|
||||
sw_content = f.read()
|
||||
assert "OFFLINE_FALLBACK_PATH" in sw_content, "Must define OFFLINE_FALLBACK_PATH"
|
||||
assert "crisis-offline" in sw_content, "Fallback must reference crisis-offline.html"
|
||||
Reference in New Issue
Block a user