🧪 Smoke-test: fix typing_progress_flow (sentence_pl из БД)

Root cause: GET /typing/next возвращает sentence_id + translation,
но НЕ sentence_pl. Робот не мог отправить правильный текст.

Fix:
- Берём sentence_pl напрямую из базы по sentence_id
- Если completed=True — не FAIL, а SKIP (все пройдены)

Результат волны 2: 9/10 PASSED, 1 SKIPPED (typing)
This commit is contained in:
2026-09-26 09:13:04 +00:00
parent b883cd50bf
commit eef9c393ca
+38 -11
View File
@@ -446,7 +446,11 @@ async def test_sentences_check_wrong(smoke_user, smoke_conn):
async def test_typing_progress_flow(smoke_user, smoke_conn):
"""GET /typing/next → POST /typing/check → typing_progress.completed_at записан."""
"""GET /typing/next → POST /typing/check → typing_progress.completed_at записан.
ВАЖНО: GET /typing/next возвращает sentence_id + translation, но
НЕ sentence_pl. Правильный текст берём из БД напрямую.
"""
client = smoke_user
resp_next = await client.get("/typing/next")
@@ -460,19 +464,42 @@ async def test_typing_progress_flow(smoke_user, smoke_conn):
return
body = resp_next.json()
sentence_id = body.get("id") or body.get("sentence_id")
sentence_pl = body.get("sentence_pl", "")
if not sentence_id or not sentence_pl:
# Если предложения закончились — не FAIL, а SKIP
if body.get("completed") is True:
RESULTS.append(ScenarioResult(
"typing_progress_flow", "typing", False,
f"GET /typing/next не вернул id/sentence_pl: {body}",
{"body": body},
"typing_progress_flow", "typing", True,
"Все предложения уровня пройдены (completed=True)",
{"completed": True},
))
pytest.skip("Нет данных для typing check")
pytest.skip("Все предложения уровня пройдены")
return
# Отправляем правильный текст (само предложение)
sentence_id = body.get("sentence_id")
if not sentence_id:
RESULTS.append(ScenarioResult(
"typing_progress_flow", "typing", False,
f"GET /typing/next не вернул sentence_id: {body}",
{"body": body},
))
pytest.skip("Нет sentence_id")
return
# 🔧 Берём sentence_pl напрямую из базы — API его не возвращает
sentence_pl = await smoke_conn.fetchval(
"SELECT sentence_pl FROM sentences WHERE id = $1",
sentence_id,
)
if not sentence_pl:
RESULTS.append(ScenarioResult(
"typing_progress_flow", "typing", False,
f"В БД нет sentence_pl для sentence_id={sentence_id}",
{"sentence_id": sentence_id},
))
pytest.skip("Нет sentence_pl в БД")
return
# Отправляем правильный текст
resp_check = await client.post(
"/typing/check",
json={"sentence_id": sentence_id, "text": sentence_pl},
@@ -488,8 +515,8 @@ async def test_typing_progress_flow(smoke_user, smoke_conn):
RESULTS.append(ScenarioResult(
"typing_progress_flow", "typing", passed,
f"status={resp_check.status_code}, typing_progress записан={recorded}",
{"status": resp_check.status_code, "recorded": recorded},
f"status={resp_check.status_code}, sentence_id={sentence_id}, typing_progress записан={recorded}",
{"status": resp_check.status_code, "recorded": recorded, "sentence_id": sentence_id},
))
assert ok, f"POST /typing/check вернул {resp_check.status_code}"
assert recorded, "typing_progress.completed_at не записан в БД"