Files
WonderQ-Project/WonderQ-MiniAPP/tests/home-data.test.ts
duanshuwen fbf2c772a8 refactor: 清理废弃模块并重构管理端与全端代码
- 移除所有废弃的旧首页配置模块,包括destinationHero、demand相关、HomeExperience、vehicleService等表结构与代码,新增数据库迁移删除遗留表
- 重构管理端后台布局为标准RuoYi风格,新增Sidebar、Navbar、SettingsDrawer等组件,替换旧的过渡菜单实现
- 调整移动端响应断点为768px,更新布局相关测试用例,新增布局组件测试
- 删除OperationsTools发布/重置页面,移除/tools菜单入口,清理对应的API调用与测试代码
- 重构玩法模块编辑器:替换旧的图片手动输入框为图片上传组件,移除冗余的取消按钮
- 新增线索查询offset参数支持,完善查询参数处理逻辑
- 优化rbac菜单构建逻辑,新增可见性控制参数
- 修正管家编辑器提示文案,优化系统资源编辑器表单初始化逻辑
- 清理小程序端废弃的体验推荐组件与相关测试代码
- 更新文档与种子脚本,匹配新的API契约与使用说明
2026-08-26 23:24:28 +08:00

110 lines
3.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
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 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([]);
});
});