diff --git a/tests/integration_tests/user_recipe_tests/test_recipe_timeline_events.py b/tests/integration_tests/user_recipe_tests/test_recipe_timeline_events.py index 6b57f987b..2868be1ba 100644 --- a/tests/integration_tests/user_recipe_tests/test_recipe_timeline_events.py +++ b/tests/integration_tests/user_recipe_tests/test_recipe_timeline_events.py @@ -392,6 +392,10 @@ def test_recipe_created_system_event_is_translated( recipe = recipes[0] params = {"queryFilter": f"recipe_id={recipe.id}"} + # read the French string from the locale file, since Crowdin owns its exact wording + expected_fr = get_all_translations(RECIPE_CREATED_EVENT_SUBJECT)["fr-FR"] + assert expected_fr != "Recipe Created" + # fetch events in French — the system "recipe created" event should be translated fr_headers = {**unique_user.token, "Accept-Language": "fr-FR"} events_response = api_client.get(api_routes.recipes_timeline_events, params=params, headers=fr_headers) @@ -402,13 +406,13 @@ def test_recipe_created_system_event_is_translated( assert system_events, "expected at least one system event for a newly created recipe" for event in system_events: - assert event.subject == "Recette créée", f"expected French translation, got: {event.subject!r}" + assert event.subject == expected_fr, f"expected French translation, got: {event.subject!r}" # also verify the individual GET endpoint translates correctly single_response = api_client.get(api_routes.recipes_timeline_events_item_id(event.id), headers=fr_headers) assert single_response.status_code == 200 single_event = RecipeTimelineEventOut.model_validate(single_response.json()) - assert single_event.subject == "Recette créée" + assert single_event.subject == expected_fr # fetch the same events in English — subject should be the English string en_headers = {**unique_user.token, "Accept-Language": "en-US"} diff --git a/tests/unit_tests/services_tests/scheduler/tasks/test_create_timeline_events.py b/tests/unit_tests/services_tests/scheduler/tasks/test_create_timeline_events.py index baa9b0ded..b0b55b3ad 100644 --- a/tests/unit_tests/services_tests/scheduler/tasks/test_create_timeline_events.py +++ b/tests/unit_tests/services_tests/scheduler/tasks/test_create_timeline_events.py @@ -311,9 +311,9 @@ def test_mealplan_event_subject_is_translated(api_client: TestClient, unique_use expected2 = f"{unique_user.full_name} made this as a side" assert event2["subject"] == expected2, f"expected {expected2!r}, got {event2['subject']!r}" - # --- locale fallback: fr-FR doesn't have these keys yet, should fall back to en-US --- + # --- locale fallback: a locale with no messages file falls back to en-US --- recipe3, initial_count3 = _create_recipe_and_mealplan(api_client, unique_user, "lunch") - event3 = _get_mealplan_event(api_client, unique_user, recipe3, initial_count3, {"Accept-Language": "fr-FR"}) + event3 = _get_mealplan_event(api_client, unique_user, recipe3, initial_count3, {"Accept-Language": "xx-XX"}) expected3 = f"{unique_user.full_name} made this for lunch" assert event3["subject"] == expected3, f"expected en-US fallback {expected3!r}, got {event3['subject']!r}"