From 9dec4fde4a7784e2d23e94efc325b76848820ecd Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Wed, 19 Aug 2026 23:34:43 +0330 Subject: [PATCH] fix(clinic): render the real insurer logo on the clinic page The component read item.logo[0].url, a shape the current API never sends, so every insurer rendered the same placeholder. It now reads logo_url and runs it through imageUrl(), since the API returns a path relative to its own host. The old shape is still accepted for records that carry it. Co-Authored-By: Claude Opus 5 (1M context) --- .../clinic/components/about/ListBime.js | 5 ++- .../clinic/components/about/ListBime.test.js | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 components/clinic/components/about/ListBime.test.js diff --git a/components/clinic/components/about/ListBime.js b/components/clinic/components/about/ListBime.js index d0fdf04..aafc192 100644 --- a/components/clinic/components/about/ListBime.js +++ b/components/clinic/components/about/ListBime.js @@ -1,6 +1,7 @@ "use client"; import CustomLoading from "@/app/component/loading/Custom"; import ArrowLeftList from "@/components/icons/ArrowLeftList"; +import { imageUrl } from "@/helper"; import { Button } from "@mui/material"; import Image from "next/image"; import { useRef, useEffect, useState } from "react"; @@ -64,8 +65,10 @@ function ListBime({ data }) { className="p-[16px] border border-[#EFEFEF] h-[175px] flex flex-col items-center justify-center gap-[20px]" style={{ minWidth: itemWidth }} > + {/* `logo_url` مسیر نسبی روی خودِ API است و باید با دامنهٔ API کامل شود. + شکل قدیمی `logo[0].url` برای رکوردهای قدیمی نگه داشته شده. */} bime ({ + default: ({ src, alt }) => {alt}, +})); + +const LOGO = '/uploads/insurances/logo/2026-08/tamin.png'; + +beforeEach(() => { + process.env.NEXT_PUBLIC_API_URL = 'https://api.example.ir'; +}); + +describe('ListBime', () => { + it('لوگوی بیمه را با دامنهٔ API کامل می‌کند', () => { + render(); + + expect(screen.getByAltText('bime')).toHaveAttribute('src', `https://api.example.ir${LOGO}`); + }); + + it('شکل قدیمی logo[0].url هنوز کار می‌کند', () => { + render(); + + expect(screen.getByAltText('bime')).toHaveAttribute('src', `https://api.example.ir${LOGO}`); + }); + + it('بیمهٔ بدون لوگو به تصویر پیش‌فرض می‌افتد', () => { + render(); + + expect(screen.getByAltText('bime')).toHaveAttribute('src', '/assets/images/logo.png'); + }); +});