From 4b992afc6720f60f44448a9f9fb41eb71951ddb8 Mon Sep 17 00:00:00 2001 From: Shlok Sheth <92412925+shethshlok@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:00:23 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20Recipe=20comments=20display=20a=20userna?= =?UTF-8?q?me/id=20rather=20than=20=E2=80=A6=20(#4726)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kuchenpirat Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com> --- .../Recipe/RecipePage/RecipePageParts/RecipePageComments.vue | 2 +- mealie/schema/recipe/recipe_comments.py | 1 + tests/fixtures/fixture_admin.py | 1 + tests/fixtures/fixture_users.py | 5 +++++ .../user_recipe_tests/test_recipe_comments.py | 1 + tests/utils/fixture_schemas.py | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageComments.vue b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageComments.vue index b7c6c1946..8c528d43a 100644 --- a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageComments.vue +++ b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageComments.vue @@ -34,7 +34,7 @@ -

{{ comment.user.username }} • {{ $d(Date.parse(comment.createdAt), "medium") }}

+

{{ comment.user.fullName }} • {{ $d(Date.parse(comment.createdAt), "medium") }}

diff --git a/mealie/schema/recipe/recipe_comments.py b/mealie/schema/recipe/recipe_comments.py index c02883437..0694af921 100644 --- a/mealie/schema/recipe/recipe_comments.py +++ b/mealie/schema/recipe/recipe_comments.py @@ -15,6 +15,7 @@ class UserBase(MealieModel): id: UUID4 username: str | None = None admin: bool + full_name: str | None = None model_config = ConfigDict(from_attributes=True) diff --git a/tests/fixtures/fixture_admin.py b/tests/fixtures/fixture_admin.py index 372fa38b7..661dde9d5 100644 --- a/tests/fixtures/fixture_admin.py +++ b/tests/fixtures/fixture_admin.py @@ -48,6 +48,7 @@ def admin_user(session: Session, api_client: TestClient): user_id=user_id, password=settings._DEFAULT_PASSWORD, username=user_data.get("username"), + full_name=user_data.get("fullName"), email=user_data.get("email"), token=token, repos=get_repositories(session, group_id=group_id, household_id=household_id), diff --git a/tests/fixtures/fixture_users.py b/tests/fixtures/fixture_users.py index 86cae118e..79283c5c6 100644 --- a/tests/fixtures/fixture_users.py +++ b/tests/fixtures/fixture_users.py @@ -45,6 +45,7 @@ def build_unique_user(session: Session, group: str, api_client: TestClient) -> u user_id=user_id, email=user_data.get("email"), username=user_data.get("username"), + full_name=user_data.get("fullName"), password=registration.password, token=token, repos=get_repositories(session, group_id=group_id, household_id=household_id), @@ -108,6 +109,7 @@ def h2_user(session: Session, admin_token, api_client: TestClient, unique_user: token=token, email=user_data["email"], username=user_data["username"], + full_name=user_data["fullName"], password=user_data["password"], repos=get_repositories(session, group_id=group_id, household_id=household_id), ) @@ -165,6 +167,7 @@ def g2_user(session: Session, admin_token, api_client: TestClient): token=token, email=create_data["email"], # type: ignore username=create_data.get("username"), # type: ignore + full_name=create_data.get("fullName"), # type: ignore password=create_data.get("password"), # type: ignore repos=get_repositories(session, group_id=group_id, household_id=household_id), ) @@ -203,6 +206,7 @@ def _unique_user(session: Session, api_client: TestClient): user_id=user_id, email=user_data.get("email"), username=user_data.get("username"), + full_name=user_data.get("fullName"), password=registration.password, token=token, repos=get_repositories(session, group_id=group_id, household_id=household_id), @@ -281,6 +285,7 @@ def user_tuple(session: Session, admin_token, api_client: TestClient) -> Generat _household_id=household_id, user_id=user_id, username=user_data.get("username"), + full_name=user_data.get("fullName"), email=user_data.get("email"), password="useruser", token=token, diff --git a/tests/integration_tests/user_recipe_tests/test_recipe_comments.py b/tests/integration_tests/user_recipe_tests/test_recipe_comments.py index ce9b1b7d6..f3b8720ad 100644 --- a/tests/integration_tests/user_recipe_tests/test_recipe_comments.py +++ b/tests/integration_tests/user_recipe_tests/test_recipe_comments.py @@ -43,6 +43,7 @@ def test_create_comment(api_client: TestClient, unique_recipe: Recipe, unique_us assert response_data["recipeId"] == str(unique_recipe.id) assert response_data["text"] == create_data["text"] assert response_data["userId"] == str(unique_user.user_id) + assert response_data["user"]["fullName"] == unique_user.full_name # Check for Proper Association response = api_client.get(api_routes.recipes_slug_comments(unique_recipe.slug), headers=unique_user.token) diff --git a/tests/utils/fixture_schemas.py b/tests/utils/fixture_schemas.py index 0e6323b33..ed3056fa3 100644 --- a/tests/utils/fixture_schemas.py +++ b/tests/utils/fixture_schemas.py @@ -11,6 +11,7 @@ class TestUser: email: str user_id: UUID username: str + full_name: str password: str _group_id: UUID _household_id: UUID