fix(blog): keep attribution rows on one line
Deploy Canina / deploy (push) Successful in 2m20s

This commit is contained in:
devops committed 2026-10-20 09:01:32 +00:00
1 parent 28485d51f7
commit 2f178db2c6
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -435,8 +435,8 @@ export default function BlogPage({
<div className="px-4 sm:px-7 pb-4 sm:pb-6 pt-2.5 border-t border-medical-gray-100 flex items-end justify-between gap-3">
<div data-testid={`regular-attribution-${post.id}`} className="min-w-0 text-[11px] font-bold text-medical-gray-500 flex flex-col gap-1">
<div className="flex min-w-0 items-center gap-1.5"><User className="w-3.5 h-3.5 shrink-0 text-medical-gray-400" /><span className="truncate">نویسنده: {post.author}</span></div>
<div className="truncate pr-5">تیم: {post.authorTeam || BLOG_TEAM_FALLBACK}</div>
<div className="flex min-w-0 items-center gap-1.5 whitespace-nowrap"><User className="w-3.5 h-3.5 shrink-0 text-medical-gray-400" /><span className="truncate">نویسنده: {post.author}</span></div>
<div className="truncate whitespace-nowrap pr-5">تیم: {post.authorTeam || BLOG_TEAM_FALLBACK}</div>
</div>
<div className="flex shrink-0 items-center gap-1 text-canina-blue font-black text-xs whitespace-nowrap group-hover:underline">
<span>مطالعه</span>
@@ -22,7 +22,7 @@ beforeEach(()=>vi.clearAllMocks());
describe('BlogPage',()=>{
it('renders featured and regular posts as semantic links',()=>{render(<BlogPage blogs={blogs} categories={categories}/>);expect(screen.getAllByRole('heading',{level:2})[0]).toHaveTextContent('Skin article');expect(screen.getByRole('link',{name:/Skin article/})).toHaveAttribute('href','/blog/skin');expect(screen.getByRole('link',{name:/Joint article/})).toHaveAttribute('href','/blog/joint');});
it('labels publication, including a same-day material update, author and stable team on featured and regular cards',()=>{const fresh=[{...blogs[0],publishedAt:'2026-01-01T08:00:00Z',contentUpdatedAt:'2026-01-02T08:00:00Z',authorTeam:'Clinical'}, {...blogs[1],publishedAt:'2026-01-02T08:00:00Z',contentUpdatedAt:'2026-01-02T12:00:00Z'}];render(<BlogPage blogs={fresh} categories={categories}/>);expect(screen.getAllByText(/تاریخ انتشار/)).toHaveLength(2);expect(screen.getAllByText(/آخرین به‌روزرسانی/)).toHaveLength(2);expect(screen.getAllByText(/نویسنده:/)).toHaveLength(2);expect(screen.getByText(/تیم: Clinical/)).toBeInTheDocument();expect(screen.getByText(/تیم: پژوهش و محتوای علمی کنینا/)).toBeInTheDocument();expect(document.querySelectorAll('time[datetime]').length).toBeGreaterThanOrEqual(4);});
it('stacks author and team on separate rows and keeps featured action on one line',()=>{render(<BlogPage blogs={blogs} categories={categories}/>);const featuredMeta=screen.getByTestId('featured-attribution');expect(featuredMeta).toHaveClass('flex-col');expect(screen.getByTestId('featured-read-more')).toHaveClass('whitespace-nowrap');const regularMeta=screen.getByTestId('regular-attribution-1');expect(regularMeta).toHaveClass('flex-col');expect(regularMeta.children).toHaveLength(2);});
it('stacks author and team on separate non-wrapping rows and keeps featured action on one line',()=>{render(<BlogPage blogs={blogs} categories={categories}/>);const featuredMeta=screen.getByTestId('featured-attribution');expect(featuredMeta).toHaveClass('flex-col');expect(screen.getByTestId('featured-read-more')).toHaveClass('whitespace-nowrap');const regularMeta=screen.getByTestId('regular-attribution-1');expect(regularMeta).toHaveClass('flex-col');expect(regularMeta.children).toHaveLength(2);expect(regularMeta.children[0]).toHaveClass('whitespace-nowrap');expect(regularMeta.children[1]).toHaveClass('whitespace-nowrap');});
it('keeps the featured footer responsive without forcing attribution or action to wrap',()=>{render(<BlogPage blogs={blogs} categories={categories}/>);expect(screen.getByTestId('featured-footer')).toHaveClass('flex-col','sm:flex-row');expect(screen.getByTestId('featured-author-name')).toHaveClass('whitespace-nowrap');expect(screen.getByTestId('featured-team-name')).toHaveClass('whitespace-nowrap');});
it('combines category, excerpt search and tags then resets empty intersection',()=>{render(<BlogPage blogs={blogs} categories={categories}/>);fireEvent.click(screen.getByRole('button',{name:'Joints'}));expect(h.replace).toHaveBeenCalledWith('/blog?categoryId=joints',{scroll:false});expect(screen.queryByText('Skin article')).not.toBeInTheDocument();fireEvent.change(screen.getByPlaceholderText('جستجو در موضوعات، بیماری‌ها، ویتامین‌ها...'),{target:{value:'MOBILITY'}});expect(screen.getByText('Joint article')).toBeInTheDocument();fireEvent.click(screen.getByRole('button',{name:'#coat'}));expect(screen.getByText('هیچ مقاله‌ای با معیارهای جستجوی شما یافت نشد.')).toBeInTheDocument();fireEvent.click(screen.getByRole('button',{name:'پاکسازی همه فیلترها'}));expect(screen.getByText('Skin article')).toBeInTheDocument();expect(screen.getByText('Joint article')).toBeInTheDocument();});
it('syncs category with route props',()=>{const view=render(<BlogPage blogs={blogs} categories={categories} initialCategoryId="joints"/>);expect(screen.queryByText('Skin article')).not.toBeInTheDocument();view.rerender(<BlogPage blogs={blogs} categories={categories} initialCategoryId="skin"/>);expect(screen.queryByText('Joint article')).not.toBeInTheDocument();});