diff --git a/mealie/services/recipe/recipe_service.py b/mealie/services/recipe/recipe_service.py index ff3a2fced..680d72d80 100644 --- a/mealie/services/recipe/recipe_service.py +++ b/mealie/services/recipe/recipe_service.py @@ -38,6 +38,8 @@ from mealie.services.scraper import cleaner from .template_service import TemplateService +RECIPE_CREATED_EVENT_SUBJECT = "recipe.recipe-created" + class RecipeServiceBase(BaseService): def __init__(self, repos: AllRepositories, user: PrivateUser, household: HouseholdInDB, translator: Translator): @@ -224,7 +226,7 @@ class RecipeService(RecipeServiceBase): timeline_event_data = RecipeTimelineEventCreate( user_id=new_recipe.user_id, recipe_id=new_recipe.id, - subject="recipe.recipe-created", + subject=RECIPE_CREATED_EVENT_SUBJECT, event_type=TimelineEventType.system, timestamp=new_recipe.created_at or datetime.now(UTC), ) 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 1af090a3e..54fe786b3 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 @@ -3,6 +3,7 @@ from uuid import uuid4 import pytest from fastapi.testclient import TestClient +from mealie.lang.providers import get_all_translations from mealie.schema.recipe.recipe import Recipe from mealie.schema.recipe.recipe_timeline_events import ( RecipeTimelineEventOut, @@ -11,11 +12,15 @@ from mealie.schema.recipe.recipe_timeline_events import ( TimelineEventType, ) from mealie.schema.recipe.request_helpers import UpdateImageResponse +from mealie.services.recipe.recipe_service import RECIPE_CREATED_EVENT_SUBJECT from tests.utils import api_routes from tests.utils.factories import random_string from tests.utils.fixture_schemas import TestUser +PERSISTED_TRANSLATION_KEYS = [RECIPE_CREATED_EVENT_SUBJECT] + + @pytest.fixture(scope="function") def recipes(api_client: TestClient, unique_user: TestUser): recipes = [] @@ -342,6 +347,14 @@ def test_create_recipe_with_timeline_event( assert events_pagination.items +@pytest.mark.parametrize("translation_key", PERSISTED_TRANSLATION_KEYS) +def test_persisted_translation_keys_have_translations(translation_key: str): + translations = get_all_translations(translation_key) + missing_translations = [locale for locale, translation in translations.items() if translation == translation_key] + + assert missing_translations == [] + + def test_recipe_created_system_event_is_translated( api_client: TestClient, unique_user: TestUser,