fix: 收敛模板编辑发布契约并还原餐饮页面视觉
This commit is contained in:
1 parent
20bcb43534
commit
f4061a24bd
102 files changed
+4510
-870
No files matched your search
@@ -28,6 +28,211 @@ after(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
test("food structured edits survive publication and reach the generated page slots", async () => {
|
||||
const { readFileSync } = await import("node:fs");
|
||||
const { runInNewContext } = await import("node:vm");
|
||||
const user = await prisma.adminUser.findUniqueOrThrow({ where: { username: "admin" } });
|
||||
const headers = {
|
||||
authorization: `Bearer ${signIdentity({ subject: user.id, brandId, role: "admin" })}`,
|
||||
};
|
||||
const records = await prisma.trustContent.findMany({
|
||||
where: {
|
||||
brandId,
|
||||
type: { in: ["schedule", "coverage", "process", "credential", "case", "promise"] },
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
const latest = await prisma.brandRelease.findFirstOrThrow({
|
||||
where: { brandId },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
const before = JSON.parse((await request("/public/workspace")).body);
|
||||
try {
|
||||
for (const item of records) {
|
||||
const url = `/admin/config/trust-content/${item.id}`;
|
||||
assert.equal(
|
||||
(await request(url, { method: "PATCH", payload: { config: {} } })).statusCode,
|
||||
401,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request(url, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { config: {} },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
assert.equal(
|
||||
(await request(url, { method: "PATCH", headers, payload: { config: "invalid" } }))
|
||||
.statusCode,
|
||||
400,
|
||||
);
|
||||
const config = { ...item.config };
|
||||
if (item.type === "schedule") {
|
||||
config.weekdayDetail = "测试工作日地点";
|
||||
config.weekendDetail = "测试周末地点";
|
||||
}
|
||||
if (item.type === "coverage") {
|
||||
config.pickupDetail = "测试自取说明";
|
||||
config.deliveryDetail = "测试配送说明";
|
||||
}
|
||||
if (item.type === "process")
|
||||
config.steps = [{ title: "测试第一步", detail: "测试步骤说明" }, ...config.steps.slice(1)];
|
||||
if (item.type === "credential")
|
||||
config.standards = [{ title: "编辑后的卫生标准", detail: "编辑后的说明" }];
|
||||
if (item.type === "case")
|
||||
config.entries = [
|
||||
{ badge: "测", title: "编辑后的合作案例", detail: "编辑后的交付", result: "完成" },
|
||||
];
|
||||
if (item.type === "promise")
|
||||
config.commitments = [
|
||||
{ label: "测试时段", detail: "编辑后的回复说明", highlight: "30 分钟内" },
|
||||
];
|
||||
assert.equal(
|
||||
(
|
||||
await request(url, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: {
|
||||
content: ["schedule", "coverage", "process"].includes(item.type) ? "" : item.content,
|
||||
config,
|
||||
},
|
||||
})
|
||||
).statusCode,
|
||||
200,
|
||||
);
|
||||
}
|
||||
assert.deepEqual(
|
||||
JSON.parse((await request("/public/workspace")).body).trustItems,
|
||||
before.trustItems,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: { note: "结构化页面集成测试" },
|
||||
})
|
||||
).statusCode,
|
||||
201,
|
||||
);
|
||||
const workspace = JSON.parse((await request("/public/workspace")).body);
|
||||
let page;
|
||||
runInNewContext(
|
||||
readFileSync(
|
||||
new URL(
|
||||
"../../../packages/template-acheng-campus-food/miniapp/pages/stall-service/index.js",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
{
|
||||
Page(value) {
|
||||
page = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: { openPage() {} };
|
||||
},
|
||||
},
|
||||
);
|
||||
page.setData = (data) => Object.assign(page.data, data);
|
||||
await page.load();
|
||||
assert.equal(page.data.schedule.rows.length, 2);
|
||||
assert.equal(page.data.schedule.rows[0].detail, "测试工作日地点");
|
||||
assert.equal(page.data.schedule.rows[1].detail, "测试周末地点");
|
||||
assert.equal(page.data.coverage.config.pickupDetail, "测试自取说明");
|
||||
assert.equal(page.data.coverage.config.deliveryDetail, "测试配送说明");
|
||||
assert.equal(page.data.process.steps.length, 4);
|
||||
assert.equal(page.data.process.steps[0].detail, "测试步骤说明");
|
||||
let owner;
|
||||
runInNewContext(
|
||||
readFileSync(
|
||||
new URL(
|
||||
"../../../packages/template-acheng-campus-food/miniapp/pages/bookings/index.js",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
{
|
||||
Page(value) {
|
||||
owner = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: {};
|
||||
},
|
||||
},
|
||||
);
|
||||
owner.setData = (data) => Object.assign(owner.data, data);
|
||||
owner.onLoad();
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(owner.data.credentials[0].config.standards[0].title, "编辑后的卫生标准");
|
||||
assert.equal(owner.data.cases[0].entries[0].result, "完成");
|
||||
assert.equal(owner.data.promises[0].config.commitments[0].highlight, "30 分钟内");
|
||||
assert.ok(workspace.trustItems.every((item) => typeof item.summary === "string"));
|
||||
assert.ok(workspace.trustItems.every((item) => typeof item.id === "string"));
|
||||
assert.equal(
|
||||
new Set(workspace.trustItems.map((item) => item.id)).size,
|
||||
workspace.trustItems.length,
|
||||
);
|
||||
const schedule = records.find((item) => item.type === "schedule");
|
||||
await request(`/admin/config/trust-content/${schedule.id}`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { config: {} },
|
||||
});
|
||||
const blocked = await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: {},
|
||||
});
|
||||
assert.equal(blocked.statusCode, 400);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: schedule.id },
|
||||
data: { config: schedule.config },
|
||||
});
|
||||
const duplicate = await prisma.trustContent.create({
|
||||
data: {
|
||||
brandId,
|
||||
type: "schedule",
|
||||
title: "重复公开日程",
|
||||
content: "",
|
||||
config: schedule.config,
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const duplicateReadiness = JSON.parse(
|
||||
(await request("/admin/releases/readiness", { headers })).body,
|
||||
);
|
||||
assert.equal(
|
||||
duplicateReadiness.checks.find((check) => check.key === "trust:schedule").passed,
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
(await request("/admin/releases/publish", { method: "POST", headers, payload: {} }))
|
||||
.statusCode,
|
||||
400,
|
||||
);
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: duplicate.id } });
|
||||
}
|
||||
} finally {
|
||||
for (const item of records)
|
||||
await prisma.trustContent.update({
|
||||
where: { id: item.id },
|
||||
data: { config: item.config, content: item.content },
|
||||
});
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId, version: { gt: latest.version } } });
|
||||
await prisma.brandRelease.update({ where: { id: latest.id }, data: { status: latest.status } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin release lifecycle is authorized, brand-scoped, and versioned", async () => {
|
||||
const missing = await request("/admin/releases");
|
||||
assert.equal(missing.statusCode, 401);
|
||||
@@ -241,6 +446,7 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
isPublished: scheduleTrust.isPublished,
|
||||
title: scheduleTrust.title,
|
||||
content: scheduleTrust.content,
|
||||
config: scheduleTrust.config,
|
||||
};
|
||||
try {
|
||||
await prisma.trustContent.update({
|
||||
@@ -274,7 +480,7 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { title: originalScheduleTrust.title, content: " \n " },
|
||||
data: { title: originalScheduleTrust.title, content: " \n ", config: {} },
|
||||
});
|
||||
const missingContent = JSON.parse(
|
||||
(
|
||||
@@ -920,6 +1126,7 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
|
||||
test("admin can preview and import sample content idempotently", async () => {
|
||||
const originalBrand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
const originalForms = await prisma.inquiryForm.findMany({ where: { brandId } });
|
||||
const originalSampleTrust = await prisma.trustContent.findMany({
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
@@ -934,6 +1141,15 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
if (!originalForms.some((item) => item.isEnabled)) {
|
||||
await prisma.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: "现有客户表单",
|
||||
fieldsSnapshot: [{ key: "phone", label: "联系电话", type: "tel", required: true }],
|
||||
},
|
||||
});
|
||||
}
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
@@ -943,11 +1159,35 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(preview.statusCode, 200);
|
||||
assert.equal(JSON.parse(preview.body).willCreateInquiryForm, false);
|
||||
const imported = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(imported.statusCode, 201);
|
||||
assert.equal(JSON.parse(imported.body).counts.inquiryForms, 0);
|
||||
assert.ok(await prisma.inquiryForm.findFirst({ where: { brandId, name: "现有客户表单" } }));
|
||||
await prisma.offering.deleteMany({
|
||||
where: {
|
||||
brandId,
|
||||
name: { in: ["序章·入户门", "庭院·边界门", "室内·静谧门", "一对一门系统设计咨询"] },
|
||||
},
|
||||
});
|
||||
await prisma.trustContent.deleteMany({
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||
const importedWithoutForm = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(importedWithoutForm.statusCode, 201);
|
||||
assert.equal(JSON.parse(importedWithoutForm.body).counts.inquiryForms, 1);
|
||||
const importedForm = await prisma.inquiryForm.findFirstOrThrow({
|
||||
where: { brandId, name: "门系统咨询表单" },
|
||||
});
|
||||
assert.ok(Array.isArray(importedForm.fieldsSnapshot) && importedForm.fieldsSnapshot.length > 0);
|
||||
const duplicate = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -970,6 +1210,14 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
});
|
||||
}
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId, name: "门系统咨询表单" } });
|
||||
if (originalForms.length) {
|
||||
await prisma.inquiryForm.createMany({
|
||||
data: originalForms.map(
|
||||
({ id: _id, createdAt: _createdAt, updatedAt: _updatedAt, ...item }) => item,
|
||||
),
|
||||
});
|
||||
}
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
@@ -1039,8 +1287,14 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
const templateContent = JSON.parse(workspace.body).templateContent;
|
||||
assert.equal(templateContent.displayName, "阿成校园餐");
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.type === "schedule"));
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.label === "出摊与营业安排"));
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.label === "每周出摊安排"));
|
||||
assert.ok(templateContent.admin.sections.some((section) => section.title === "首页出摊信息"));
|
||||
assert.ok(
|
||||
templateContent.admin.sections
|
||||
.filter((section) => section.title === "首页出摊信息")
|
||||
.every((section) => section.page === "home"),
|
||||
);
|
||||
assert.ok(templateContent.navigation.some((item) => item.page === "home" && item.label));
|
||||
assert.ok(
|
||||
templateContent.admin.sections
|
||||
.flatMap((section) => section.fields)
|
||||
@@ -1197,7 +1451,14 @@ test("public workspace exposes declared brand and trust presentation data", asyn
|
||||
);
|
||||
const doorType = body.inquiryForms[0].fields.find((field) => field.key === "doorType");
|
||||
assert.equal(doorType.options.length, 5);
|
||||
assert.equal(doorType.options[0].value, "入户大门(防暴铸铜 / 实木)");
|
||||
assert.equal(doorType.options[0].value, "entry");
|
||||
const phone = body.inquiryForms[0].fields.find((field) => field.key === "contactPhone");
|
||||
assert.equal(phone.type, "tel");
|
||||
const foodWorkspace = await request("/public/workspace?brandSlug=default-brand");
|
||||
const foodPhone = JSON.parse(foodWorkspace.body).inquiryForms[0].fields.find(
|
||||
(field) => field.key === "phone",
|
||||
);
|
||||
assert.equal(foodPhone.type, "tel");
|
||||
} finally {
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
@@ -1233,7 +1494,20 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
const changedIntro = "集成测试发布后联系说明";
|
||||
const changedHint = "集成测试咨询后处理说明";
|
||||
const changedDetailHero = "https://example.com/integration-detail.jpg";
|
||||
const changedDetailBackground = "集成测试案例详情正文";
|
||||
const changedTemplateData = "集成测试设计理念";
|
||||
const changedStats = [{ value: "42", label: "测试成果" }];
|
||||
const obsolete = await prisma.trustContent.create({
|
||||
data: {
|
||||
brandId: doorsBrand.id,
|
||||
type: "profile",
|
||||
title: "旧类型不得覆盖模板配置",
|
||||
content: "旧简介",
|
||||
config: { stats: [{ value: "旧值", label: "不得显示" }], internalOnly: "不得公开" },
|
||||
isPublished: true,
|
||||
sortOrder: -100,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const brandConfig = originalBrandConfig ?? {};
|
||||
const presentation = brandConfig.visualPresentation ?? {};
|
||||
@@ -1248,6 +1522,11 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
success: { ...presentation.success, intro: changedIntro },
|
||||
detail: { ...presentation.detail, inquiryHint: changedHint },
|
||||
},
|
||||
templateData: {
|
||||
...(brandConfig.templateData ?? {}),
|
||||
designPhilosophy: changedTemplateData,
|
||||
internalOnly: "不得公开",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1266,6 +1545,10 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
...(offering.config ?? {}),
|
||||
area: changedArea,
|
||||
detailHero: changedDetailHero,
|
||||
details: {
|
||||
...((offering.config ?? {}).details ?? {}),
|
||||
background: changedDetailBackground,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1298,12 +1581,24 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
(await request("/public/workspace?brandSlug=linjing-doors")).body,
|
||||
);
|
||||
assert.equal(afterPublish.brand.homeHero.title, changedTitle);
|
||||
assert.equal(afterPublish.templateData.designPhilosophy, changedTemplateData);
|
||||
assert.equal(Object.hasOwn(afterPublish.templateData, "internalOnly"), false);
|
||||
assert.equal(afterPublish.brand.visualPresentation.success.intro, changedIntro);
|
||||
assert.equal(afterPublish.brand.visualPresentation.detail.inquiryHint, changedHint);
|
||||
assert.deepEqual(afterPublish.trustPresentation.stats, changedStats);
|
||||
assert.equal(
|
||||
afterPublish.trustItems.some((item) => item.type === "profile"),
|
||||
false,
|
||||
);
|
||||
assert.equal(Object.hasOwn(afterPublish.trustPresentation, "internalOnly"), false);
|
||||
assert.equal(afterPublish.offerings[0].presentation.area, changedArea);
|
||||
assert.equal(afterPublish.offerings[0].presentation.heroImage, changedDetailHero);
|
||||
assert.equal(
|
||||
afterPublish.offerings[0].presentation.details.background,
|
||||
changedDetailBackground,
|
||||
);
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: obsolete.id } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
data: { config: originalBrandConfig },
|
||||
@@ -1377,6 +1672,15 @@ test("admin can create and version an inquiry form", async () => {
|
||||
label: "联系渠道",
|
||||
options: [{ label: "微信", value: "wechat" }],
|
||||
},
|
||||
{
|
||||
key: "topics",
|
||||
type: "multi-select",
|
||||
label: "关注方向",
|
||||
options: [
|
||||
{ label: "咨询", value: "consulting" },
|
||||
{ label: "设计", value: "design" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1425,20 +1729,25 @@ test("admin can create and version an inquiry form", async () => {
|
||||
assert.equal((await publishReleaseForTests()).statusCode, 201);
|
||||
const publicForm = await request(`/public/inquiry-forms/${id}`);
|
||||
assert.equal(publicForm.statusCode, 200);
|
||||
assert.equal(
|
||||
JSON.parse(publicForm.body).fieldsSnapshot.find((field) => field.key === "topics").type,
|
||||
"multi-select",
|
||||
);
|
||||
const publicOffering = await request(`/public/offerings/${offering.id}`);
|
||||
assert.equal(publicOffering.statusCode, 200);
|
||||
assert.equal(JSON.parse(publicOffering.body).inquiryForms[0].id, id);
|
||||
const publicWorkspace = await request("/public/workspace");
|
||||
assert.equal(publicWorkspace.statusCode, 200);
|
||||
assert.ok(JSON.parse(publicWorkspace.body).inquiryForms.some((form) => form.key === id));
|
||||
const runtimeForm = JSON.parse(publicWorkspace.body).inquiryForms.find(
|
||||
(form) => form.key === id,
|
||||
);
|
||||
assert.ok(runtimeForm);
|
||||
assert.equal(runtimeForm.fields.find((field) => field.key === "topics").type, "checkbox");
|
||||
assert.ok(
|
||||
JSON.parse(publicWorkspace.body).inquiryForms.some(
|
||||
(form) => form.key === id && form.targetId === offering.id,
|
||||
),
|
||||
);
|
||||
const runtimeForm = JSON.parse(publicWorkspace.body).inquiryForms.find(
|
||||
(form) => form.key === id,
|
||||
);
|
||||
assert.deepEqual(runtimeForm.fields[1].options, [{ label: "微信", value: "wechat" }]);
|
||||
await prisma.inquiryForm.update({
|
||||
where: { id },
|
||||
@@ -1833,6 +2142,8 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
assert.equal(updatedBrand.statusCode, 200);
|
||||
assert.equal(JSON.parse(updatedBrand.body).description, "集成测试品牌简介");
|
||||
assert.equal(JSON.parse(updatedBrand.body).templateKey, "personal");
|
||||
const updatedConfig = JSON.parse(updatedBrand.body).config;
|
||||
assert.equal(updatedConfig.slogan, "集成测试品牌简介");
|
||||
|
||||
const updatedService = await request(`/admin/workspace/offerings/${serviceBefore.id}`, {
|
||||
method: "PATCH",
|
||||
@@ -1950,6 +2261,26 @@ test("admin can manage trust content", async () => {
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
assert.equal((await request("/admin/config/trust-content")).statusCode, 401);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: "Bearer invalid" },
|
||||
payload: { type: "schedule", title: "安排", content: "时间" },
|
||||
})
|
||||
).statusCode,
|
||||
401,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { type: "schedule", title: "安排", content: "时间" },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
const created = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1957,6 +2288,25 @@ test("admin can manage trust content", async () => {
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const id = JSON.parse(created.body).id;
|
||||
const schedule = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
type: "schedule",
|
||||
title: "每周营业安排",
|
||||
summary: "周一至周五 17:00 - 22:30",
|
||||
content: "周六、周日承接团体单",
|
||||
},
|
||||
});
|
||||
assert.equal(schedule.statusCode, 201);
|
||||
assert.equal(JSON.parse(schedule.body).summary, "周一至周五 17:00 - 22:30");
|
||||
assert.equal(JSON.parse(schedule.body).content, "周六、周日承接团体单");
|
||||
const unsupported = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { type: "unregistered-template-type", title: "不支持", content: "不应保存" },
|
||||
});
|
||||
assert.equal(unsupported.statusCode, 400);
|
||||
const draft = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1981,6 +2331,7 @@ test("admin can manage trust content", async () => {
|
||||
assert.equal(updated.statusCode, 200);
|
||||
assert.equal(JSON.parse(updated.body).content, "更新后的内容");
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: JSON.parse(schedule.body).id } });
|
||||
const deleted = await request(`/admin/config/trust-content/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
|
||||
Reference in new issue
Block a user