Rewrite reviewed-finding localStorage hooks.

Dashboard count and report toggle still migrate legacy keys and skip the first persist write.
This commit is contained in:
2026-09-20 20:12:20 +02:00
parent 7d82358e19
commit 72b4b20665
3 changed files with 145 additions and 0 deletions
@@ -0,0 +1,33 @@
"""Reviewed-finding localStorage hooks live under periscope/src."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / "periscope" / "src" / "frontend" / "src"
def test_reviewed_hooks_are_src():
for rel in ("hooks/use-reviewed-count.ts", "hooks/use-reviewed-findings.ts"):
text = (SRC / rel).read_text(encoding="utf-8")
assert "Native Periscope overlay" not in text[:400]
def test_reviewed_count_reads_migrated_key():
text = (SRC / "hooks/use-reviewed-count.ts").read_text(encoding="utf-8")
assert "export function useReviewedCount" in text
assert "reviewedFindingsKey" in text
assert "legacyReviewedFindingsKey" in text
assert "migrateLocalKey" in text
def test_reviewed_findings_return_shape():
text = (SRC / "hooks/use-reviewed-findings.ts").read_text(encoding="utf-8")
assert "export function useReviewedFindings" in text
assert "toggleReviewed" in text
assert "isReviewed" in text
assert "reviewedCount" in text
assert "reviewedIds" in text
assert "getFindingKey" in text
assert "skipFirstWrite" in text or "hydrated" in text