[chore] solution,admin,ontology: 코드 주석을 한 줄로 — 히스토리 주석 삭제
여러 줄 주석이 설명보다 경위(예전·실측·지적)를 적고 있어 읽는 사람이 결론을 찾기 어려웠다. - ts·tsx·js·mjs·css·py 478개: 여러 줄 주석은 첫 문장 한 줄로, 과거형·날짜 문장은 삭제 - 주석 위치는 TypeScript 파서·파이썬 tokenize/ast 로 찾는다 — 문자열 안의 # · /* 는 건드리지 않는다 - eslint·ts·noqa·type: ignore 같은 지시 주석은 그대로 둔다 파이썬 275개 정리 전후 AST 동일, TS 298개 주석 뺀 토큰 동일(빈 JSX 주석 10곳만 차이). site·frontend·admin tsc, site vitest 105 passed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c6908629f3
commit
11d30bb3d1
479 files changed
+3337
-13091
No files matched your search
@@ -1,13 +1,4 @@
|
||||
"""디자인(색·서체·섹션) 저장과 발행 payload 반영.
|
||||
|
||||
이 경로가 절대 하면 안 되는 것:
|
||||
- 고른 디자인을 브라우저에만 두는 것 — 발행 잡이 읽을 곳이 없어 업종 기본 모양으로 굽는다.
|
||||
사장님이 섹션을 끄고 순서를 바꿔도 발행본이 안 바뀌던 것이 이 API 가 생긴 이유다.
|
||||
- ★ 잠긴 섹션(SEO·필수 마크업)을 끈 채로 내보내는 것 — 끄기로도, 목록에서 빼기로도 막아야 한다.
|
||||
한쪽만 막으면 "끄는 대신 빼면 그만"이라 잠금이 무의미해진다.
|
||||
- 템플릿 정의(templates.json)에 없는 모양·템플릿으로 굽는 것.
|
||||
- templateId 를 theme 안에 같이 보관하는 것 — sites.template_id 와 갈린다.
|
||||
"""
|
||||
"""디자인(색·서체·섹션) 저장과 발행 payload 반영."""
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
@@ -18,7 +9,7 @@ from common.enums import ErrorType, PlaceCategory, SiteStatus
|
||||
from common.template_catalog import INDUSTRIES, TEMPLATES, UnknownTemplate
|
||||
from services.site_payload import to_site_payload
|
||||
|
||||
# 계약 그대로의 최소 테마. 배열 순서가 곧 섹션 순서다(별도 order 필드가 없다).
|
||||
# 계약 그대로의 최소 테마.
|
||||
_THEME = {
|
||||
"colors": {"accent": "#c2410c"},
|
||||
"colorPaletteId": "warm-sand",
|
||||
@@ -44,9 +35,7 @@ async def _get_site(client, headers, pid):
|
||||
|
||||
|
||||
async def test_set_theme_creates_site_row_and_round_trips(auth_headers, client):
|
||||
"""검증: 사이트 행이 없어도 디자인을 먼저 고를 수 있고, 저장한 모양 그대로 다시 읽힌다.
|
||||
기대결과: SUCCESS + 조회 응답의 site.theme 가 보낸 것과 같다.
|
||||
★ 다시 읽히지 않으면 저장은 됐는데 에디터는 기본값으로 돌아간다."""
|
||||
"""검증: 사이트 행이 없어도 디자인을 먼저 고를 수 있고, 저장한 모양 그대로 다시 읽힌다."""
|
||||
h = await auth_headers("thm1")
|
||||
pid = await _place(client, h)
|
||||
|
||||
@@ -69,8 +58,7 @@ async def test_unknown_sections_are_accepted(auth_headers, client):
|
||||
|
||||
|
||||
async def test_oversized_theme_is_refused(auth_headers, client):
|
||||
"""검증: 해석하지 않는 값이라 크기만은 막는다 — 안 막으면 jsonb 하나가 DB 와 스냅샷을 부풀린다.
|
||||
기대결과: INVALID_REQUEST_DATA."""
|
||||
"""검증: 해석하지 않는 값이라 크기만은 막는다 — 안 막으면 jsonb 하나가 DB 와 스냅샷을 부풀린다."""
|
||||
h = await auth_headers("thm3")
|
||||
pid = await _place(client, h)
|
||||
|
||||
@@ -80,8 +68,7 @@ async def test_oversized_theme_is_refused(auth_headers, client):
|
||||
|
||||
|
||||
async def test_template_id_is_not_stored_inside_theme(auth_headers, client):
|
||||
"""검증: templateId 는 sites.template_id 컬럼이 소유한다.
|
||||
기대결과: theme 안에 실려 와도 저장되지 않는다 — 두 곳에 두면 어느 쪽이 진짜인지 갈린다."""
|
||||
"""검증: templateId 는 sites.template_id 컬럼이 소유한다."""
|
||||
h = await auth_headers("thm4")
|
||||
pid = await _place(client, h)
|
||||
|
||||
@@ -92,8 +79,7 @@ async def test_template_id_is_not_stored_inside_theme(auth_headers, client):
|
||||
|
||||
|
||||
async def test_empty_theme_clears_to_default(auth_headers, client):
|
||||
"""검증: 빈 값은 '고르지 않음'이다 — NULL 로 되돌아가 업종 기본으로 떨어진다.
|
||||
기대결과: 저장 후 {} 를 보내면 theme 가 응답에서 사라진다(None)."""
|
||||
"""검증: 빈 값은 '고르지 않음'이다 — NULL 로 되돌아가 업종 기본으로 떨어진다."""
|
||||
h = await auth_headers("thm5")
|
||||
pid = await _place(client, h)
|
||||
await _set_theme(client, h, pid, _THEME)
|
||||
@@ -105,8 +91,7 @@ async def test_empty_theme_clears_to_default(auth_headers, client):
|
||||
|
||||
|
||||
async def test_published_site_theme_is_not_locked(auth_headers, client, db_engine):
|
||||
"""검증: ★ 발행된 사이트도 디자인은 바꿀 수 있다(주소와 다르다 — URL 이 그대로라 색인이 안 깨진다).
|
||||
기대결과: SUCCESS + 재빌드 필요 표시(needs_rebuild)."""
|
||||
"""검증: ★ 발행된 사이트도 디자인은 바꿀 수 있다(주소와 다르다 — URL 이 그대로라 색인이 안 깨진다)."""
|
||||
h = await auth_headers("thm6")
|
||||
pid = await _place(client, h)
|
||||
await _set_theme(client, h, pid, _THEME)
|
||||
@@ -124,8 +109,7 @@ async def test_published_site_theme_is_not_locked(auth_headers, client, db_engin
|
||||
|
||||
|
||||
async def test_other_owners_place_is_blocked(auth_headers, client):
|
||||
"""검증: 남의 사업장의 디자인은 바꿀 수 없다.
|
||||
기대결과: PLACE_NOT_FOUND(존재 여부조차 알려주지 않는다)."""
|
||||
"""검증: 남의 사업장의 디자인은 바꿀 수 없다."""
|
||||
h = await auth_headers("thm7")
|
||||
intruder = await auth_headers("thm8")
|
||||
pid = await _place(client, h)
|
||||
@@ -156,9 +140,7 @@ def test_payload_without_saved_theme_uses_industry_default():
|
||||
|
||||
|
||||
def test_payload_follows_saved_order_and_toggles():
|
||||
"""검증: 저장된 배열 순서와 on/off 가 발행본에 그대로 간다.
|
||||
기대결과: 저장 순서대로 앞자리를 채우고, 끈 섹션은 꺼진 채로 나간다.
|
||||
★ 예전엔 enabled 가 True 로 박혀 있어 끈 섹션이 그대로 발행됐다."""
|
||||
"""검증: 저장된 배열 순서와 on/off 가 발행본에 그대로 간다."""
|
||||
theme = _payload_theme(_THEME)
|
||||
assert [s["id"] for s in theme["sections"]][:3] == ["faq", "hero", "rooms"]
|
||||
assert next(s for s in theme["sections"] if s["id"] == "rooms")["enabled"] is False
|
||||
@@ -172,25 +154,20 @@ def test_payload_drops_variant_id():
|
||||
|
||||
|
||||
def test_payload_ignores_saved_look():
|
||||
"""검증: 모양(look)은 템플릿 정의가 정한다. 저장값의 look은 무시한다."""
|
||||
"""검증: 모양(look)은 템플릿 정의가 정한다."""
|
||||
theme = _payload_theme({"look": {"fontHeading": "Comic Sans"}})
|
||||
assert theme["look"] == TEMPLATES["retro"]["look"]
|
||||
|
||||
|
||||
def test_locked_section_cannot_be_published_disabled():
|
||||
"""검증: ★ 잠긴 섹션을 껐다고 저장한 경우.
|
||||
기대결과: 켜서 내보낸다 — SEO·필수 마크업 때문에 잠긴 것이라 꺼진 채로 나갈 수 없다.
|
||||
★ 저장값의 locked:false 도 믿지 않는다. 믿으면 클라이언트가 locked 를 내려 보내는 것만으로
|
||||
필수 섹션을 끌 수 있어 잠금 자체가 무의미해진다."""
|
||||
"""검증: ★ 잠긴 섹션을 껐다고 저장한 경우."""
|
||||
theme = _payload_theme({"sections": [{"id": "hero", "name": "히어로", "enabled": False, "locked": False}]})
|
||||
hero = next(s for s in theme["sections"] if s["id"] == "hero")
|
||||
assert hero["enabled"] is True and hero["locked"] is True
|
||||
|
||||
|
||||
def test_locked_section_omitted_from_saved_list_comes_back_enabled():
|
||||
"""검증: ★ 잠긴 섹션을 아예 목록에서 뺀 경우.
|
||||
기대결과: 끝에 켜서 덧붙는다 — 끄기만 막고 빼기를 통과시키면
|
||||
"끄는 대신 빼면 그만"이라 위 규칙이 그대로 뚫린다."""
|
||||
"""검증: ★ 잠긴 섹션을 아예 목록에서 뺀 경우."""
|
||||
theme = _payload_theme({"sections": [{"id": "faq", "name": "FAQ", "enabled": True, "locked": False}]})
|
||||
for sid in ("hero", "info", "map"):
|
||||
entry = next(s for s in theme["sections"] if s["id"] == sid)
|
||||
@@ -198,13 +175,7 @@ def test_locked_section_omitted_from_saved_list_comes_back_enabled():
|
||||
|
||||
|
||||
def test_section_missing_from_saved_list_comes_back_enabled():
|
||||
"""검증: 저장값에 없는 기본 섹션(= 나중에 추가한 섹션).
|
||||
기대결과: ★ 끝에 **켜서** 덧붙는다.
|
||||
|
||||
에디터에는 섹션을 빼는 기능이 없다(toggleSection·reorderSection 뿐).
|
||||
그래서 저장값에 없다는 건 "사장님이 뺐다"가 아니라 "저장할 당시 그 섹션이 없었다"는 뜻이다.
|
||||
꺼서 붙이면 새로 만든 섹션이 기존 사업장에 영원히 안 나온다 — 에디터에는 보이는데
|
||||
발행본에는 없는 상태가 된다(실측: 날씨 섹션이 그렇게 빠져 있었다)."""
|
||||
"""검증: 저장값에 없는 기본 섹션(= 나중에 추가한 섹션)."""
|
||||
theme = _payload_theme({"sections": [{"id": "faq", "name": "FAQ", "enabled": True, "locked": False}]})
|
||||
photos = next(s for s in theme["sections"] if s["id"] == "photos")
|
||||
assert photos["enabled"] is True
|
||||
@@ -214,15 +185,13 @@ def test_section_missing_from_saved_list_comes_back_enabled():
|
||||
|
||||
|
||||
def test_owner_disabled_section_stays_disabled():
|
||||
"""검증: 사장님이 **끈** 섹션(목록에는 있고 enabled=False).
|
||||
기대결과: 꺼진 채로 나간다 — 위 규칙이 "끈 것"까지 켜버리면 안 된다."""
|
||||
"""검증: 사장님이 **끈** 섹션(목록에는 있고 enabled=False)."""
|
||||
theme = _payload_theme({"sections": [{"id": "photos", "name": "사진", "enabled": False, "locked": False}]})
|
||||
assert next(s for s in theme["sections"] if s["id"] == "photos")["enabled"] is False
|
||||
|
||||
|
||||
def test_owner_written_section_body_reaches_publish_payload():
|
||||
"""검증: 에디터에서 직접 쓴 소개 본문.
|
||||
기대결과: 발행 payload 에 그대로 남는다 — 저장만 되고 경계에서 버려지면 발행본과 계수에 못 쓴다."""
|
||||
"""검증: 에디터에서 직접 쓴 소개 본문."""
|
||||
theme = _payload_theme({"sections": [{
|
||||
"id": "intro", "name": "소개", "enabled": True, "locked": False,
|
||||
"body": "바다를 보며 조용히 쉬어가는 작은 숙소입니다.",
|
||||
@@ -233,8 +202,7 @@ def test_owner_written_section_body_reaches_publish_payload():
|
||||
|
||||
|
||||
def test_partial_colors_are_filled_from_category_default():
|
||||
"""검증: 저장된 색이 일부 키만 담고 있을 때.
|
||||
기대결과: 빠진 자리는 템플릿 색이 메운다(렌더러는 6개를 모두 요구한다)."""
|
||||
"""검증: 저장된 색이 일부 키만 담고 있을 때."""
|
||||
colors = _payload_theme({"colors": {"accent": "#c2410c"}})["colors"]
|
||||
assert colors["accent"] == "#c2410c"
|
||||
assert colors["bg"] == TEMPLATES["retro"]["colors"]["bg"]
|
||||
@@ -242,9 +210,7 @@ def test_partial_colors_are_filled_from_category_default():
|
||||
|
||||
|
||||
def test_color_palette_id_never_reaches_the_payload():
|
||||
"""검증: colorPaletteId 는 에디터 복원 전용이다.
|
||||
기대결과: 저장·반환은 되지만 발행 payload 의 theme 에는 없다 —
|
||||
발행 계약(SitePayload.SiteTheme)에 없는 필드를 흘리지 않는다."""
|
||||
"""검증: colorPaletteId 는 에디터 복원 전용이다."""
|
||||
assert "colorPaletteId" not in _payload_theme(_THEME)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user