fix(cafe24): 대표이미지 적용 안 됨 + 옵션 썸네일 "없음" 오표시
- 대표이미지: NNEditor 업로드 경로를 PUT detail_image 에 넣던 방식은 카페24가
반영하지 않았다. 문서의 전용 API POST /admin/products/{no}/images 에
base64 data URI + image_upload_type=A 로 등록하고, 응답의 새 경로 4개로
화면·스냅샷을 맞춘다(응답에 updated_date 가 없어 스냅샷 시각은 등록 시각).
- 옵션 썸네일: 카페24는 option_link_image 등을 "/web/product/big/…" 상대경로로
준다. 그대로 src 에 넣어 우리 도메인에서 404 → "없음"으로 보였다. 옵션 GET 에
image_base(쇼핑몰 주소)를 내려 붙여 그리고, 후보(버튼→연결→품목 이미지)가
깨지면 다음 후보로 넘어간다. 카페24로 되보내는 hidden 값은 원본 그대로.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1193,6 +1193,34 @@ def test_upload_images_and_variants_wrappers():
|
||||
assert client.calls[-1][0] == "DELETE"
|
||||
|
||||
|
||||
def test_set_main_image_uses_product_images_endpoint():
|
||||
"""대표이미지는 POST /products/{no}/images 에 data URI 로 A 타입 등록 — 새 경로 4개를 돌려준다."""
|
||||
client = _RouteClient({
|
||||
"POST /admin/products/13/images": {"image": {
|
||||
"shop_no": 1, "product_no": 13,
|
||||
"detail_image": "https://d/web/product/big/x.png",
|
||||
"list_image": "https://d/web/product/medium/x.png",
|
||||
"tiny_image": "https://d/web/product/tiny/x.png",
|
||||
"small_image": "https://d/web/product/small/x.png",
|
||||
}},
|
||||
})
|
||||
out = products.set_main_image(client, 13, b"\x89PNG", content_type="image/png")
|
||||
assert out == {
|
||||
"detail_image": "https://d/web/product/big/x.png",
|
||||
"list_image": "https://d/web/product/medium/x.png",
|
||||
"tiny_image": "https://d/web/product/tiny/x.png",
|
||||
"small_image": "https://d/web/product/small/x.png",
|
||||
}
|
||||
method, path, body = client.calls[-1]
|
||||
assert (method, path) == ("POST", "/admin/products/13/images")
|
||||
assert body["shop_no"] == 1
|
||||
assert body["request"]["image_upload_type"] == "A"
|
||||
assert body["request"]["detail_image"].startswith("data:image/png;base64,")
|
||||
# 상품 PUT(detail_image 경로 넣기)은 더 이상 쓰지 않는다
|
||||
assert not [c for c in client.calls if c[0] == "PUT"]
|
||||
assert products.set_main_image(client, 13, b"") == {}
|
||||
|
||||
|
||||
def _run_all():
|
||||
fns = [v for k, v in sorted(globals().items()) if k.startswith("test_") and callable(v)]
|
||||
for fn in fns:
|
||||
|
||||
Reference in New Issue
Block a user