feat(blog): add material freshness and authorship

This commit is contained in:
devops committed 2026-10-20 05:36:03 +00:00
1 parent 3f5258a76c
commit 51ca8c7e34
24 files changed
+187 -52

No files matched your search

@@ -110,9 +110,9 @@ describe("BlogPreviewSection Component", () => {
});
// Author display
expect(screen.getByText("دکتر مریم اکبری")).toBeInTheDocument();
expect(screen.getByText("نویسنده: دکتر مریم اکبری")).toBeInTheDocument();
// Default fallback author
expect(screen.getByText("تحریریه کنینا")).toBeInTheDocument();
expect(screen.getByText("نویسنده: تحریریه کنینا")).toBeInTheDocument();
// Verify aria-label links with full title context
const link1 = screen.getByLabelText("مطالعه مقاله: اهمیت کلسیم و مفاصل در رشد توله سگ ژرمن شپرد");
@@ -122,6 +122,15 @@ describe("BlogPreviewSection Component", () => {
expect(link2).toHaveAttribute("href", "/blog/cat-hair-loss-solutions");
});
it("uses publication freshness and explicit byline labels on homepage cards", async () => {
vi.mocked(api.get).mockResolvedValueOnce({ data: { blogs: [{ id:"b",slug:"b",title:"B",content:"",viewCount:0,createdAt:"2026-01-01T00:00:00Z",publishedAt:"2026-01-01T00:00:00Z",contentUpdatedAt:"2026-01-02T00:00:00Z",authorTeam:"Science" }] } });
render(<BlogPreviewSection />);
expect(await screen.findByText(/تاریخ انتشار/)).toBeInTheDocument();
expect(screen.getByText(/آخرین به‌روزرسانی/)).toBeInTheDocument();
expect(screen.getByText(/نویسنده:/)).toBeInTheDocument();
expect(screen.getByText(/تیم: Science/)).toBeInTheDocument();
});
it("handles api errors gracefully and renders null", async () => {
vi.mocked(api.get).mockRejectedValueOnce(new Error("Failed to load"));
const { container } = render(<BlogPreviewSection />);