diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 580b25b..1d240e2 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -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 не записан в БД"