Compare commits
2 Commits
fix/41
...
burn/59-17
| Author | SHA1 | Date | |
|---|---|---|---|
| b6af9ca9db | |||
| 56f991d615 |
@@ -1,32 +0,0 @@
|
||||
# Issue #41 Verification
|
||||
|
||||
Status: already implemented on main
|
||||
|
||||
Issue:
|
||||
- #41 [P3] Service worker: cache crisis resources for offline
|
||||
|
||||
Acceptance criteria check:
|
||||
1. Passed — offline page includes 988 call button, Crisis Text Line, and grounding techniques
|
||||
2. Passed — service worker precaches `crisis-offline.html`
|
||||
3. Passed — phone number is clickable via `href="tel:988"`
|
||||
4. Passed — navigation timeout + offline fallback support intermittent connections
|
||||
|
||||
Evidence:
|
||||
- `sw.js` precaches `/crisis-offline.html`
|
||||
- `sw.js` contains `NAVIGATION_TIMEOUT_MS` and `AbortController`
|
||||
- `crisis-offline.html` contains:
|
||||
- `href="tel:988"`
|
||||
- Crisis Text Line / `741741`
|
||||
- grounding prompts for 5-4-3-2-1
|
||||
- `tests/test_service_worker_offline.py` already exists on main and passes
|
||||
|
||||
Verification run from fresh main clone:
|
||||
- `python3 -m pytest tests/test_service_worker_offline.py -q`
|
||||
- `10 passed`
|
||||
|
||||
Prior implementation trail:
|
||||
- Issue comment already states the core implementation is complete on main
|
||||
- Closed PR #122 documented the already-complete implementation and added the offline guarantees test coverage that is now present on main
|
||||
|
||||
Recommendation:
|
||||
- Close issue #41 as already implemented on main.
|
||||
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}"
|
||||
)
|
||||
Reference in New Issue
Block a user