feat: 完善通用服务后台配置能力

This commit is contained in:
que01 committed 2026-09-19 16:50:32 +08:00
1 parent 60ca897574
commit d167b58a05
6 files changed
+46 -3

No files matched your search

+15
View File
@@ -98,6 +98,7 @@ test("admin can read and update brand and service configuration", async () => {
assert.ok(brandBefore);
const serviceBefore = await prisma.service.findFirst({ where: { brandId, isEnabled: true } });
assert.ok(serviceBefore);
let createdServiceId;
try {
const brand = await request("/admin/config/brand", { headers: { authorization: `Bearer ${adminToken}` } });
@@ -121,9 +122,23 @@ test("admin can read and update brand and service configuration", async () => {
assert.equal(updatedService.statusCode, 200);
assert.equal(JSON.parse(updatedService.body).priceText, "集成测试价格");
assert.equal(JSON.parse(updatedService.body).sortOrder, 99);
const listedServices = await request("/admin/config/services", { headers: { authorization: `Bearer ${adminToken}` } });
assert.equal(listedServices.statusCode, 200);
assert.ok(JSON.parse(listedServices.body).some((item) => item.id === serviceBefore.id));
const createdService = await request("/admin/config/services", {
method: "POST",
headers: { authorization: `Bearer ${adminToken}` },
payload: { name: "集成测试通用服务", description: "通用品牌服务", categoryKey: "consulting", config: { duration: 60 } },
});
assert.equal(createdService.statusCode, 201);
createdServiceId = JSON.parse(createdService.body).id;
assert.equal(JSON.parse(createdService.body).categoryKey, "consulting");
} finally {
await prisma.brandProfile.update({ where: { id: brandId }, data: { description: brandBefore.description, contactPhone: brandBefore.contactPhone, templateKey: brandBefore.templateKey } });
await prisma.service.update({ where: { id: serviceBefore.id }, data: { priceText: serviceBefore.priceText, sortOrder: serviceBefore.sortOrder } });
if (createdServiceId) await prisma.service.delete({ where: { id: createdServiceId } });
}
});