feat(translation): expose translated fields in post feed + provenance payloads (#143 step 4)
post_feed_service (card + detail) and provenance_service._post_dict now include post_title_translated, description_translated (card-truncated / detail-uncapped) and translated_source_lang, keeping the originals for the toggle. Feed serialization test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM
This commit is contained in:
@@ -283,6 +283,30 @@ async def test_scroll_item_shape_minimal(db):
|
||||
assert "description_full" not in item
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scroll_surfaces_translation_fields(db):
|
||||
# #143: a translated post exposes the translated title/description + source
|
||||
# lang, with the originals still present for the toggle.
|
||||
artist = await _seed_artist(db, "alice-tr")
|
||||
src = await _seed_source(db, artist.id, "pixiv", "https://p/alice-tr")
|
||||
p = await _seed_post(
|
||||
db, src.id, external_id="TR", post_date=datetime.now(UTC),
|
||||
title="ねこ", description="<p>かわいい</p>",
|
||||
)
|
||||
p.post_title_translated = "cat"
|
||||
p.description_translated = "cute"
|
||||
p.translated_source_lang = "ja"
|
||||
await db.commit()
|
||||
|
||||
page = await PostFeedService(db).scroll(cursor=None, limit=10)
|
||||
item = page["items"][0]
|
||||
assert item["post_title_translated"] == "cat"
|
||||
assert item["description_translated"] == "cute"
|
||||
assert item["translated_source_lang"] == "ja"
|
||||
assert item["post_title"] == "ねこ" # original kept for the toggle
|
||||
assert item["description_plain"] == "かわいい"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scroll_description_truncates_long_text(db):
|
||||
artist = await _seed_artist(db, "alice-long")
|
||||
|
||||
Reference in New Issue
Block a user