- _RouteEdit_Render.watchTheme(data-theme · prefers-color-scheme · 공용 색 캐시가 먼저 비워지게 다음 프레임) · 편집기가 붙이고 떠날 때 뗌 - 시험: test_349_routeedit_theme_redraw 3 · 관련 37 통과 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Se7ytqbohmBQnfYpwYFnYf
46 lines
2.1 KiB
Python
46 lines
2.1 KiB
Python
"""349 — 밝음 · 어두움을 바꾸면 노선 편집 평면 캔버스를 다시 그림(바탕 · 등고선 · 노선 · 발자국 색).
|
|
|
|
그리기는 그릴 때마다 테마 토큰을 다시 읽음 — 테마 바꿈 알림에 다시 그리기만 붙었는지 글로 봄.
|
|
./venv/Scripts/python.exe -m pytest resources/tester/test_349_routeedit_theme_redraw.py -q
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
B05 = ROOT / "B05_Profile"
|
|
RENDER = (B05 / "B05_Profile_UI_RouteEdit_Render.ts").read_text(encoding="utf-8")
|
|
EDITOR = (B05 / "B05_Profile_UI_RouteEdit.ts").read_text(encoding="utf-8")
|
|
|
|
|
|
def _body(text: str, head: str) -> str:
|
|
at = text.index(head)
|
|
return text[at : text.index("\n}", at)]
|
|
|
|
|
|
def test_테마_알림_받아_다음_프레임에_다시_그림() -> None:
|
|
watch = _body(RENDER, "export function watchTheme(")
|
|
assert 'attributeFilter: ["data-theme"]' in watch # 단추로 바꿈
|
|
assert 'matchMedia("(prefers-color-scheme: dark)")' in watch # 시스템 바꿈
|
|
# 공용 색 캐시가 먼저 비워지게 다음 프레임에 · 뗄 때 모두 뗌
|
|
assert "requestAnimationFrame(onChange)" in watch
|
|
assert "observer.disconnect();" in watch and 'removeEventListener("change", later)' in watch
|
|
|
|
|
|
def test_편집기가_붙이고_떠날_때_뗌() -> None:
|
|
assert "const themeWatch = watchTheme(() => draw());" in EDITOR
|
|
dispose = _body(EDITOR, "const dispose = (): void => {")
|
|
assert "themeWatch();" in dispose
|
|
assert len(EDITOR.splitlines()) <= 700
|
|
|
|
|
|
def test_그릴_때마다_토큰을_다시_읽음() -> None:
|
|
scene = _body(RENDER, "export function drawRouteEditScene(")
|
|
assert "const style = getComputedStyle(document.documentElement);" in scene
|
|
assert 'style.getPropertyValue("--color-surface")' in scene # 바탕
|
|
assert 'style.getPropertyValue("--map-contour-major")' in scene # 등고선
|
|
assert 'style.getPropertyValue("--map-route")' in scene # 노선
|
|
footprint = (B05 / "B05_Profile_UI_RouteEdit_Footprint.ts").read_text(encoding="utf-8")
|
|
assert "context.strokeStyle = style.getPropertyValue(token).trim() || fallback;" in footprint
|