54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { describe, expect, test, vi } from "vitest";
|
|
|
|
vi.mock("./db/appConfiguration.db.server", () => ({
|
|
getAppConfiguration: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("~/locale/i18n", () => ({
|
|
i18nConfig: { supportedLngs: ["en"], fallbackLng: "en" },
|
|
}));
|
|
|
|
vi.mock("~/modules/knowledgeBase/service/KnowledgeBaseService.server", () => ({
|
|
default: {
|
|
getAll: vi.fn(),
|
|
getCategories: vi.fn(),
|
|
getArticles: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
vi.mock("~/modules/knowledgeBase/utils/KnowledgeBaseUtils", () => ({
|
|
default: {
|
|
getKbUrl: vi.fn(),
|
|
getCategoryUrl: vi.fn(),
|
|
getArticleUrl: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
import { getSitemapDomainUrl, isAdminHostSitemapRoute, shouldSkipSitemapRouteId } from "./sitemap.server";
|
|
|
|
describe("getSitemapDomainUrl", () => {
|
|
test("uses canonical routing config instead of request hosts", () => {
|
|
expect(
|
|
getSitemapDomainUrl({
|
|
appBaseDomain: "example.test",
|
|
webAppHost: "app.example.test",
|
|
adminAppHost: "admin.example.test",
|
|
apiHost: "api.example.test",
|
|
protocol: "https",
|
|
})
|
|
).toBe("https://app.example.test");
|
|
});
|
|
|
|
test("skips host clone route ids", () => {
|
|
expect(shouldSkipSitemapRouteId("routes/admin/settings.__host")).toBe(true);
|
|
expect(shouldSkipSitemapRouteId("routes/admin/settings")).toBe(true);
|
|
});
|
|
|
|
test("detects admin-host sitemap routes that must not be emitted on the app host", () => {
|
|
expect(isAdminHostSitemapRoute("/dashboard")).toBe(true);
|
|
expect(isAdminHostSitemapRoute("/settings")).toBe(true);
|
|
expect(isAdminHostSitemapRoute("/acme/dashboard")).toBe(false);
|
|
expect(isAdminHostSitemapRoute("/login")).toBe(false);
|
|
});
|
|
});
|