- 新增客片案例全流程功能,包含前台页面、管理端配置、后端API、数据库迁移与文档 - 新增团队共创详情页面与对应接口 - 重构玩法模块:将静态playData替换为动态API获取,拆分类型定义到playTypes.ts - 优化vite构建配置与环境变量处理,调整详情页操作栏文案 - 更新全量相关文档与配图,新增客片案例、团队共创API文档 - 新增测试用例,完善数据归一化逻辑 - 调整路由配置与环境变量示例文件
132 lines
4.0 KiB
TypeScript
132 lines
4.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { homeExperienceMocks, normalizeHomeExperiences } from "@/pages/home/components/homeExperienceData";
|
|
import {
|
|
homeTeamBuildingMocks,
|
|
normalizeHomeTeamBuildingDetail,
|
|
normalizeHomeTeamBuildings,
|
|
} from "@/pages/home/components/homeTeamBuildingData";
|
|
import {
|
|
homeWildArchiveMocks,
|
|
normalizeHomeWildArchiveDetail,
|
|
normalizeHomeWildArchives,
|
|
} from "@/pages/home/components/homeWildArchivesData";
|
|
import { normalizeHomeWanfaRecommendations } from "@/pages/home/components/homeWanfaRecommendationData";
|
|
|
|
describe("home content normalizers", () => {
|
|
it("normalizes experiences and keeps the existing fallback for missing fields", () => {
|
|
expect(
|
|
normalizeHomeExperiences([
|
|
{
|
|
id: "api-experience",
|
|
title: " API 瀑降 ",
|
|
sortOrder: 0,
|
|
isActive: true,
|
|
},
|
|
{ id: "disabled", title: "不展示", isActive: false },
|
|
]),
|
|
).toEqual([
|
|
{
|
|
...homeExperienceMocks[0],
|
|
id: "api-experience",
|
|
title: "API 瀑降",
|
|
demandKeyword: "API 瀑降",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("normalizes team building and wild archive lists", () => {
|
|
expect(normalizeHomeTeamBuildings(null)).toEqual(homeTeamBuildingMocks);
|
|
expect(normalizeHomeWildArchives(undefined)).toEqual(homeWildArchiveMocks);
|
|
expect(
|
|
normalizeHomeTeamBuildings([
|
|
{
|
|
id: "team-api",
|
|
tag: "团队协作",
|
|
title: "API 团建",
|
|
description: "API 描述",
|
|
image: "https://example.test/team.jpg",
|
|
demandKeyword: "API 团建",
|
|
sortOrder: 0,
|
|
},
|
|
])[0],
|
|
).toMatchObject({ id: "team-api" });
|
|
});
|
|
|
|
it("normalizes a wild archive detail with a cover fallback", () => {
|
|
const detail = normalizeHomeWildArchiveDetail({
|
|
id: "archive-api",
|
|
title: " 石龙洞——客片案例 ",
|
|
image: "https://example.test/cover.jpg",
|
|
images: ["https://example.test/one.jpg", " https://example.test/two.jpg "],
|
|
demandKeyword: "地心探险",
|
|
});
|
|
|
|
expect(detail).toMatchObject({
|
|
id: "archive-api",
|
|
title: "石龙洞——客片案例",
|
|
image: "https://example.test/cover.jpg",
|
|
images: ["https://example.test/one.jpg", "https://example.test/two.jpg"],
|
|
});
|
|
});
|
|
|
|
it("normalizes a team building detail with paragraph content", () => {
|
|
const detail = normalizeHomeTeamBuildingDetail({
|
|
id: "team-api",
|
|
tag: "户外挑战",
|
|
title: " API 团建 ",
|
|
description: "卡片描述",
|
|
image: "https://example.test/team.jpg",
|
|
demandKeyword: "API 团建",
|
|
detailSubtitle: " 越过山丘,向来处去 ",
|
|
detailParagraphs: [" 第一段 ", "", " 第二段 "],
|
|
});
|
|
|
|
expect(detail).toMatchObject({
|
|
id: "team-api",
|
|
title: "API 团建",
|
|
detailSubtitle: "越过山丘,向来处去",
|
|
detailParagraphs: ["第一段", "第二段"],
|
|
});
|
|
});
|
|
|
|
it("normalizes homepage wanfa recommendations with their linked category routes", () => {
|
|
expect(
|
|
normalizeHomeWanfaRecommendations([
|
|
{
|
|
id: "recommendation-1",
|
|
categoryId: "family-route",
|
|
label: " 亲子路线 ",
|
|
routes: [
|
|
{
|
|
id: "family-water",
|
|
title: " 亲子玩水 ",
|
|
subtitle: "贵州·轻松节奏与自然课堂",
|
|
image: "https://example.test/family-water.jpg",
|
|
routeCount: 2,
|
|
demandKeyword: "亲子玩水",
|
|
},
|
|
],
|
|
},
|
|
]),
|
|
).toEqual([
|
|
{
|
|
id: "recommendation-1",
|
|
categoryId: "family-route",
|
|
label: "亲子路线",
|
|
routes: [
|
|
{
|
|
id: "family-water",
|
|
title: "亲子玩水",
|
|
subtitle: "贵州·轻松节奏与自然课堂",
|
|
image: "https://example.test/family-water.jpg",
|
|
routeCount: 2,
|
|
demandKeyword: "亲子玩水",
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
expect(normalizeHomeWanfaRecommendations(null)).toEqual([]);
|
|
});
|
|
});
|