Compare commits
2 Commits
fix/38
...
burn/59-17
| Author | SHA1 | Date | |
|---|---|---|---|
| b6af9ca9db | |||
| 56f991d615 |
75
index.html
75
index.html
@@ -241,48 +241,6 @@ html, body {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ===== CHAT HEADER ===== */
|
||||
#chat-header {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #21262d;
|
||||
background: #11161d;
|
||||
}
|
||||
|
||||
.chat-header-title {
|
||||
font-size: 0.85rem;
|
||||
color: #8b949e;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
#chat-safety-plan-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 8px 12px;
|
||||
min-height: 36px;
|
||||
border: 1px solid #30363d;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: #c9d1d9;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#chat-safety-plan-btn:hover,
|
||||
#chat-safety-plan-btn:focus {
|
||||
border-color: #58a6ff;
|
||||
background: rgba(88, 166, 255, 0.12);
|
||||
outline: 2px solid #58a6ff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* ===== CHAT AREA ===== */
|
||||
#chat-area {
|
||||
flex: 1;
|
||||
@@ -691,14 +649,6 @@ html, body {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="chat-header">
|
||||
<div class="chat-header-title" aria-hidden="true">Conversation</div>
|
||||
<button id="chat-safety-plan-btn" type="button" aria-label="Open My Safety Plan from chat header">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
|
||||
My Safety Plan
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Chat messages -->
|
||||
<div id="chat-area" role="log" aria-label="Chat messages" aria-live="polite" tabindex="0">
|
||||
<!-- Messages inserted here -->
|
||||
@@ -730,7 +680,7 @@ html, body {
|
||||
|
||||
<!-- Footer -->
|
||||
<footer id="footer">
|
||||
<a href="/about" aria-label="About The Door">about</a>
|
||||
<a href="/about.html" aria-label="About The Door">about</a>
|
||||
<button id="safety-plan-btn" aria-label="Open My Safety Plan">my safety plan</button>
|
||||
<button id="clear-chat-btn" aria-label="Clear chat history">clear chat</button>
|
||||
</footer>
|
||||
@@ -864,7 +814,6 @@ Sovereignty and service always.`;
|
||||
|
||||
// Safety Plan Elements
|
||||
var safetyPlanBtn = document.getElementById('safety-plan-btn');
|
||||
var chatSafetyPlanBtn = document.getElementById('chat-safety-plan-btn');
|
||||
var crisisSafetyPlanBtn = document.getElementById('crisis-safety-plan-btn');
|
||||
var safetyPlanModal = document.getElementById('safety-plan-modal');
|
||||
var closeSafetyPlan = document.getElementById('close-safety-plan');
|
||||
@@ -1336,25 +1285,19 @@ Sovereignty and service always.`;
|
||||
_spTriggerEl = null;
|
||||
}
|
||||
|
||||
function openSafetyPlan(triggerEl) {
|
||||
loadSafetyPlan();
|
||||
safetyPlanModal.classList.add('active');
|
||||
_activateSafetyPlanFocusTrap(triggerEl || document.activeElement);
|
||||
}
|
||||
|
||||
// Wire open buttons to activate focus trap
|
||||
safetyPlanBtn.addEventListener('click', function() {
|
||||
openSafetyPlan(safetyPlanBtn);
|
||||
});
|
||||
|
||||
chatSafetyPlanBtn.addEventListener('click', function() {
|
||||
openSafetyPlan(chatSafetyPlanBtn);
|
||||
loadSafetyPlan();
|
||||
safetyPlanModal.classList.add('active');
|
||||
_activateSafetyPlanFocusTrap(safetyPlanBtn);
|
||||
});
|
||||
|
||||
// Crisis panel safety plan button (if crisis panel is visible)
|
||||
if (crisisSafetyPlanBtn) {
|
||||
crisisSafetyPlanBtn.addEventListener('click', function() {
|
||||
openSafetyPlan(crisisSafetyPlanBtn);
|
||||
loadSafetyPlan();
|
||||
safetyPlanModal.classList.add('active');
|
||||
_activateSafetyPlanFocusTrap(crisisSafetyPlanBtn);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1501,7 +1444,9 @@ Sovereignty and service always.`;
|
||||
// Check for URL params (e.g., ?safetyplan=true for PWA shortcut)
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.get('safetyplan') === 'true') {
|
||||
openSafetyPlan(chatSafetyPlanBtn || safetyPlanBtn);
|
||||
loadSafetyPlan();
|
||||
safetyPlanModal.classList.add('active');
|
||||
_activateSafetyPlanFocusTrap(safetyPlanBtn);
|
||||
// Clean up URL
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
}
|
||||
|
||||
76
tests/test_link_integrity.py
Normal file
76
tests/test_link_integrity.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""Tests for the-door static site link integrity.
|
||||
|
||||
Validates that all internal links in HTML files point to existing files,
|
||||
preventing broken navigation from deployed static servers.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
PROJECT_ROOT = Path(__file__).parent.parent
|
||||
|
||||
|
||||
def _extract_internal_links(html_content: str) -> list[str]:
|
||||
"""Extract href values that point to local paths (not http/https/mailto/#)."""
|
||||
pattern = r'href="(/[^"]*|[^"]*\.html)"'
|
||||
links = re.findall(pattern, html_content)
|
||||
return [
|
||||
link for link in links
|
||||
if not link.startswith("http")
|
||||
and not link.startswith("mailto:")
|
||||
and not link.startswith("#")
|
||||
and not link.startswith("https://")
|
||||
]
|
||||
|
||||
|
||||
def _link_to_filepath(link: str) -> Path:
|
||||
"""Convert an href path to a filesystem path relative to project root."""
|
||||
if link.startswith("/"):
|
||||
return PROJECT_ROOT / link.lstrip("/")
|
||||
return PROJECT_ROOT / link
|
||||
|
||||
|
||||
@pytest.mark.parametrize("html_file", [
|
||||
"index.html",
|
||||
"about.html",
|
||||
"testimony.html",
|
||||
"crisis-offline.html",
|
||||
])
|
||||
def test_internal_links_resolve(html_file: str):
|
||||
"""All internal links in HTML files should point to existing files."""
|
||||
html_path = PROJECT_ROOT / html_file
|
||||
if not html_path.exists():
|
||||
pytest.skip(f"{html_file} not found")
|
||||
|
||||
content = html_path.read_text(encoding="utf-8")
|
||||
links = _extract_internal_links(content)
|
||||
|
||||
broken = []
|
||||
for link in links:
|
||||
target = _link_to_filepath(link)
|
||||
if not target.exists():
|
||||
broken.append(f" {link} -> {target} (NOT FOUND)")
|
||||
|
||||
assert not broken, (
|
||||
f"Broken links in {html_file}:\n" + "\n".join(broken)
|
||||
)
|
||||
|
||||
|
||||
def test_about_link_points_to_html():
|
||||
"""Specific regression test: the about footer link must point to about.html, not /about."""
|
||||
index_path = PROJECT_ROOT / "index.html"
|
||||
content = index_path.read_text(encoding="utf-8")
|
||||
|
||||
# Should contain about.html link
|
||||
assert 'href="/about.html"' in content, (
|
||||
"Footer about link should be '/about.html', not '/about'"
|
||||
)
|
||||
|
||||
# Should NOT contain bare /about link (which 404s on static servers)
|
||||
about_links = re.findall(r'href="(/about)"', content)
|
||||
assert not about_links, (
|
||||
f"Found bare '/about' link(s) that will 404 on static servers: {about_links}"
|
||||
)
|
||||
@@ -1,20 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
INDEX = Path("index.html")
|
||||
|
||||
|
||||
def test_chat_header_has_persistent_safety_plan_button():
|
||||
html = INDEX.read_text()
|
||||
assert 'id="chat-header"' in html
|
||||
assert 'id="chat-safety-plan-btn"' in html
|
||||
assert 'aria-label="Open My Safety Plan from chat header"' in html
|
||||
assert 'My Safety Plan' in html
|
||||
|
||||
|
||||
def test_chat_header_button_opens_existing_safety_plan_modal():
|
||||
html = INDEX.read_text()
|
||||
assert "var chatSafetyPlanBtn = document.getElementById('chat-safety-plan-btn');" in html
|
||||
assert "chatSafetyPlanBtn.addEventListener('click'" in html
|
||||
assert "function openSafetyPlan(triggerEl)" in html
|
||||
assert "safetyPlanModal.classList.add('active');" in html
|
||||
assert "openSafetyPlan(chatSafetyPlanBtn);" in html
|
||||
Reference in New Issue
Block a user