Files
hamed 9cfbd2e002 feat: Revert homepage changes, fix Persian slug 404, and make various article and about us adjustments
- Removed the newly added city-focused section from the homepage.
- Fixed 404 error for Persian slugs in specialties and blog pages by implementing a decode helper.
- Removed the "مخصوص شهر" label from article headers.
- Linked article tags to their respective filter pages.
- Adjusted related content images to prevent distortion.
- Added a section in the "About Us" page for physician registration guidance.
- Updated the logo in the "About Us" header to the correct version.
- Added tests for the new functionality and ensured existing tests are updated accordingly.
2026-08-08 21:06:48 +03:30

56 lines
2.2 KiB
JavaScript

import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import Head from "@/components/blog/head";
const BLOG = {
title: "آلرژی دارویی",
author: "دکتر رضایی",
created: 1750000000,
reading_time: 5,
tag: [{ name: "آلرژی" }, { name: "قلب و عروق" }],
};
describe("سربرگ مقاله", () => {
it("برچسب «مخصوص شهر» را نشان نمی‌دهد", () => {
render(<Head data={BLOG} />);
expect(screen.queryByText("مخصوص شهر:")).toBeNull();
});
it("نویسنده و تاریخ انتشار سر جایشان می‌مانند", () => {
render(<Head data={BLOG} />);
expect(screen.getByText("نویسنده:")).toBeInTheDocument();
expect(screen.getByText("تاریخ انتشار:")).toBeInTheDocument();
});
it("هر تگ به لیست مقاله‌های همان تگ لینک می‌شود", () => {
render(<Head data={BLOG} />);
const links = screen.getAllByRole("link", { name: "قلب و عروق" });
const url = new URL(links[0].getAttribute("href"), "https://yasuj-nobat.ir");
expect(links).toHaveLength(1);
expect(url.pathname).toBe("/blogs");
// قرارداد واقعی همان چیزی است که `searchParams.get("tag")` می‌خواند،
// نه شکل دقیق encode — شکل شیئیِ href فاصله را `+` می‌کند و بردکرامب `%20`.
expect(url.searchParams.get("tag")).toBe("قلب و عروق");
});
it("تگ حاوی & با پارامتر دوم اشتباه گرفته نمی‌شود", () => {
render(<Head data={{ ...BLOG, tag: [{ name: "قلب & عروق" }] }} />);
const links = screen.getAllByRole("link", { name: "قلب & عروق" });
const url = new URL(links[0].getAttribute("href"), "https://yasuj-nobat.ir");
expect(url.searchParams.get("tag")).toBe("قلب & عروق");
expect(Array.from(url.searchParams.keys())).toEqual(["tag"]);
});
it("مقالهٔ بدون تگ هیچ فهرست تگی رندر نمی‌کند", () => {
const { container } = render(<Head data={{ ...BLOG, tag: [] }} />);
expect(container.querySelector("ul")).toBeNull();
});
});