详细变更如下: - 更新 .gitignore 文件,添加 pnpm-store 忽略规则 - 新增数据库迁移脚本,为 DetailRecord 添加可空的 conciergeAdvisorId 字段用于关联管家顾问 - 完善 Admin 后台玩法详情编辑器,支持选择关联的管家顾问并校验合法性 - 公共 API 支持返回已启用的管家顾问完整数据,不在详情表中冗余存储管家资料 - 小程序端新增详情页联系管家入口、个人页最近浏览历史功能 - 更新所有相关文档与测试用例,修复下拉选择框的 z-index 样式问题
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import { normalizeConciergeAdvisor, normalizeConciergeAdvisors } from "@/pages/concierge/components/conciergeTypes";
|
||
|
||
describe("normalizeConciergeAdvisors", () => {
|
||
it("normalizes a single valid advisor and rejects incomplete data", () => {
|
||
expect(
|
||
normalizeConciergeAdvisor({
|
||
avatar: " https://example.test/amanda.jpg ",
|
||
name: " Amanda ",
|
||
role: " ADVISOR ",
|
||
details: [{ icon: " calendar ", label: " 服务经验:8年 " }],
|
||
qrImage: " https://example.test/amanda-qr.png ",
|
||
}),
|
||
).toEqual({
|
||
avatar: "https://example.test/amanda.jpg",
|
||
name: "Amanda",
|
||
role: "ADVISOR",
|
||
details: [{ icon: "calendar", label: "服务经验:8年" }],
|
||
qrImage: "https://example.test/amanda-qr.png",
|
||
});
|
||
expect(normalizeConciergeAdvisor({ name: "缺少头像" })).toBeNull();
|
||
});
|
||
|
||
it("normalizes public advisor data and filters incomplete records", () => {
|
||
expect(
|
||
normalizeConciergeAdvisors({
|
||
advisors: [
|
||
{
|
||
id: "advisor-amanda",
|
||
avatar: " https://example.test/amanda.jpg ",
|
||
name: " Amanda ",
|
||
role: "SENIOR TRAVEL ADVISOR",
|
||
details: [
|
||
{ icon: " calendar ", label: " 服务经验:8年 " },
|
||
{ icon: "navigate", label: "" },
|
||
],
|
||
qrImage: "https://example.test/amanda-qr.png",
|
||
},
|
||
{ id: "missing-qr", avatar: "https://example.test/avatar.jpg", name: "无效", role: "ADVISOR", details: [] },
|
||
],
|
||
}),
|
||
).toEqual([
|
||
{
|
||
avatar: "https://example.test/amanda.jpg",
|
||
name: "Amanda",
|
||
role: "SENIOR TRAVEL ADVISOR",
|
||
details: [{ icon: "calendar", label: "服务经验:8年" }],
|
||
qrImage: "https://example.test/amanda-qr.png",
|
||
},
|
||
]);
|
||
});
|
||
|
||
it("returns an empty list for an invalid response", () => {
|
||
expect(normalizeConciergeAdvisors(null)).toEqual([]);
|
||
expect(normalizeConciergeAdvisors({ advisors: null })).toEqual([]);
|
||
});
|
||
});
|