From 085cc604cdcbec52c566e97d5317da39be501605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wr=C3=B3bel?= Date: Tue, 10 Nov 2026 20:25:09 +0000 Subject: [PATCH] fix: ignore case when checking for an existing alias (#9025) --- .../use-parse-ingredients-dialog.test.ts | 24 +++++++++++++++++++ .../recipes/use-parse-ingredients-dialog.ts | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/app/composables/recipes/__tests__/use-parse-ingredients-dialog.test.ts b/frontend/app/composables/recipes/__tests__/use-parse-ingredients-dialog.test.ts index 6b9437b60..da859dd3a 100644 --- a/frontend/app/composables/recipes/__tests__/use-parse-ingredients-dialog.test.ts +++ b/frontend/app/composables/recipes/__tests__/use-parse-ingredients-dialog.test.ts @@ -594,6 +594,18 @@ describe("useParseIngredientsDialog", () => { await addMissingUnitAsAlias(); expect(updateUnit).not.toHaveBeenCalled(); }); + test("addMissingUnitAsAlias ignores case when checking for the alias", async () => { + const wrapped = wrapper(); + const { addMissingUnitAsAlias, setCurrentUnit, setCurrentIng } = wrapped.vm; + setCurrentIng({ + ingredient: { + unit: { name: "2uwunit", id: "unit_id_2", aliases: [{ name: "uwunit" }] }, + }, + }); + setCurrentUnit("UwUnit"); + await addMissingUnitAsAlias(); + expect(updateUnit).not.toHaveBeenCalled(); + }); test("addMissingUnitAsAlias fails gracefully", async () => { updateUnit.mockResolvedValue(undefined); const wrapped = wrapper(); @@ -644,6 +656,18 @@ describe("useParseIngredientsDialog", () => { await addMissingFoodAsAlias(); expect(updateFood).not.toHaveBeenCalled(); }); + test("addMissingFoodAsAlias ignores case when checking for the alias", async () => { + const wrapped = wrapper(); + const { addMissingFoodAsAlias, setCurrentFood, setCurrentIng } = wrapped.vm; + setCurrentIng({ + ingredient: { + food: { name: "f2uwud", id: "food_id_2", aliases: [{ name: "fuwud" }] }, + }, + }); + setCurrentFood("FuWud"); + await addMissingFoodAsAlias(); + expect(updateFood).not.toHaveBeenCalled(); + }); test("addMissingFoodAsAlias fails gracefully", async () => { updateFood.mockResolvedValue(undefined); const wrapped = wrapper(); diff --git a/frontend/app/composables/recipes/use-parse-ingredients-dialog.ts b/frontend/app/composables/recipes/use-parse-ingredients-dialog.ts index b6bb4d777..c886cf6cc 100644 --- a/frontend/app/composables/recipes/use-parse-ingredients-dialog.ts +++ b/frontend/app/composables/recipes/use-parse-ingredients-dialog.ts @@ -338,7 +338,8 @@ export function useParseIngredientsDialog( } unit.aliases = unit.aliases || []; - if (unit.aliases.map(a => a.name).includes(currentMissingUnit.value)) { + const missingUnit = currentMissingUnit.value.toLowerCase(); + if (unit.aliases.some(a => a.name.toLowerCase() === missingUnit)) { return; } @@ -367,7 +368,8 @@ export function useParseIngredientsDialog( } food.aliases = food.aliases || []; - if (food.aliases.map(a => a.name).includes(currentMissingFood.value)) { + const missingFood = currentMissingFood.value.toLowerCase(); + if (food.aliases.some(a => a.name.toLowerCase() === missingFood)) { return; }