- Implemented canonical URL strategies for city-specific domains and entities. - Added helper functions for domain and city resolution. - Created tests for canonical URL generation and domain resolution. - Introduced entity quality checks for doctors and clinics to ensure meaningful content. - Developed unique introductory texts for listing pages to avoid duplicate content. - Established robots.txt policies for listing pages to manage indexing based on user filters. - Enhanced specialty content with dynamic introductions and FAQs to improve SEO.
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildCanonicalQuery,
|
|
getEntityCanonical,
|
|
} from "@/lib/getCanonicalUrl";
|
|
|
|
const YASUJ_CITY_ID = 123;
|
|
const ROOT_CITY_ID = 600;
|
|
|
|
describe("buildCanonicalQuery — تصمیم M3-B", () => {
|
|
it("صفحهٔ ۲+ در canonical میماند تا ایندکسپذیر بماند", () => {
|
|
expect(buildCanonicalQuery("?page=2")).toBe("?page=2");
|
|
expect(buildCanonicalQuery("?page=38")).toBe("?page=38");
|
|
});
|
|
|
|
it("صفحهٔ ۱ حذف میشود (URL متعارف بدون page)", () => {
|
|
expect(buildCanonicalQuery("?page=1")).toBe("");
|
|
expect(buildCanonicalQuery("")).toBe("");
|
|
});
|
|
|
|
it("فیلتر و sort و جستجو از canonical حذف میشوند", () => {
|
|
expect(buildCanonicalQuery("?specialty=x&gender=woman&sort=point&name=a")).toBe("");
|
|
});
|
|
|
|
it("page در کنار فیلترها فقط page را نگه میدارد", () => {
|
|
expect(buildCanonicalQuery("?specialty=x&page=3")).toBe("?page=3");
|
|
});
|
|
});
|
|
|
|
describe("getEntityCanonical — C1-b", () => {
|
|
it("موجودیت به دامنهٔ شهر خودش canonical میشود، نه دامنهٔ سروکننده", () => {
|
|
expect(getEntityCanonical(YASUJ_CITY_ID, "/doctor/abc", "nobat724.com")).toBe(
|
|
"https://yasuj-nobat.ir/doctor/abc"
|
|
);
|
|
});
|
|
|
|
it("روی دامنهٔ خودِ شهر self-canonical است", () => {
|
|
expect(getEntityCanonical(YASUJ_CITY_ID, "/clinic/abc", "yasuj-nobat.ir")).toBe(
|
|
"https://yasuj-nobat.ir/clinic/abc"
|
|
);
|
|
});
|
|
|
|
it("شهر بدون دامنه → self-canonical (هرگز canonical شکسته)", () => {
|
|
expect(getEntityCanonical(999999, "/doctor/abc", "nobat724.com")).toBe(
|
|
"https://nobat724.com/doctor/abc"
|
|
);
|
|
expect(getEntityCanonical(null, "/doctor/abc", "tehran-nobat.ir")).toBe(
|
|
"https://tehran-nobat.ir/doctor/abc"
|
|
);
|
|
});
|
|
|
|
it("رکورد ریشه شهر نیست → self-canonical", () => {
|
|
expect(getEntityCanonical(ROOT_CITY_ID, "/doctor/abc", "yazd-nobat.ir")).toBe(
|
|
"https://yazd-nobat.ir/doctor/abc"
|
|
);
|
|
});
|
|
});
|