feat: 完善模板内容后台配置能力
This commit is contained in:
1 parent
2bc2193b44
commit
9266ec824a
37 files changed
+2273
-63
No files matched your search
@@ -1206,6 +1206,125 @@ test("public workspace exposes declared brand and trust presentation data", asyn
|
||||
}
|
||||
});
|
||||
|
||||
test("edited template facts reach public workspace only after publication", async () => {
|
||||
const doorsBrand = await prisma.brandProfile.findUniqueOrThrow({
|
||||
where: { slug: "linjing-doors" },
|
||||
});
|
||||
const trust = await prisma.trustContent.findFirstOrThrow({
|
||||
where: { brandId: doorsBrand.id, type: "credential", isPublished: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
const offering = await prisma.offering.findFirstOrThrow({
|
||||
where: { brandId: doorsBrand.id, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
});
|
||||
const adminUser = await prisma.adminUser.findUniqueOrThrow({
|
||||
where: { username: "admin" },
|
||||
select: { id: true },
|
||||
});
|
||||
const token = signIdentity({ subject: adminUser.id, brandId: doorsBrand.id, role: "admin" });
|
||||
const headers = { authorization: `Bearer ${token}` };
|
||||
const originalBrandConfig = doorsBrand.config;
|
||||
const originalTrustConfig = trust.config;
|
||||
const originalOfferingConfig = offering.config;
|
||||
const before = JSON.parse((await request("/public/workspace?brandSlug=linjing-doors")).body);
|
||||
const changedTitle = "集成测试定制首页标题";
|
||||
const changedArea = "集成测试项目地点";
|
||||
const changedIntro = "集成测试发布后联系说明";
|
||||
const changedHint = "集成测试咨询后处理说明";
|
||||
const changedDetailHero = "https://example.com/integration-detail.jpg";
|
||||
const changedStats = [{ value: "42", label: "测试成果" }];
|
||||
try {
|
||||
const brandConfig = originalBrandConfig ?? {};
|
||||
const presentation = brandConfig.visualPresentation ?? {};
|
||||
const brandUpdate = await request("/admin/config/brand", {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: {
|
||||
config: {
|
||||
homeHero: { ...brandConfig.homeHero, title: changedTitle },
|
||||
visualPresentation: {
|
||||
...presentation,
|
||||
success: { ...presentation.success, intro: changedIntro },
|
||||
detail: { ...presentation.detail, inquiryHint: changedHint },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
assert.equal(brandUpdate.statusCode, 200);
|
||||
const trustUpdate = await request(`/admin/config/trust-content/${trust.id}`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { config: { ...(trust.config ?? {}), stats: changedStats } },
|
||||
});
|
||||
assert.equal(trustUpdate.statusCode, 200);
|
||||
const offeringUpdate = await request(`/admin/workspace/offerings/${offering.id}`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: {
|
||||
config: {
|
||||
...(offering.config ?? {}),
|
||||
area: changedArea,
|
||||
detailHero: changedDetailHero,
|
||||
},
|
||||
},
|
||||
});
|
||||
assert.equal(offeringUpdate.statusCode, 200);
|
||||
|
||||
const draftView = JSON.parse((await request("/public/workspace?brandSlug=linjing-doors")).body);
|
||||
assert.deepEqual(draftView.brand.homeHero, before.brand.homeHero);
|
||||
assert.equal(
|
||||
draftView.brand.visualPresentation.success.intro,
|
||||
before.brand.visualPresentation.success.intro,
|
||||
);
|
||||
assert.equal(
|
||||
draftView.brand.visualPresentation.detail.inquiryHint,
|
||||
before.brand.visualPresentation.detail.inquiryHint,
|
||||
);
|
||||
assert.deepEqual(draftView.trustPresentation.stats, before.trustPresentation.stats);
|
||||
assert.equal(draftView.offerings[0].presentation.area, before.offerings[0].presentation.area);
|
||||
assert.equal(
|
||||
draftView.offerings[0].presentation.heroImage,
|
||||
before.offerings[0].presentation.heroImage,
|
||||
);
|
||||
|
||||
const publish = await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: { note: "集成测试模板内容编辑" },
|
||||
});
|
||||
assert.equal(publish.statusCode, 201);
|
||||
const afterPublish = JSON.parse(
|
||||
(await request("/public/workspace?brandSlug=linjing-doors")).body,
|
||||
);
|
||||
assert.equal(afterPublish.brand.homeHero.title, changedTitle);
|
||||
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.offerings[0].presentation.area, changedArea);
|
||||
assert.equal(afterPublish.offerings[0].presentation.heroImage, changedDetailHero);
|
||||
} finally {
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
data: { config: originalBrandConfig },
|
||||
});
|
||||
await prisma.trustContent.update({
|
||||
where: { id: trust.id },
|
||||
data: { config: originalTrustConfig },
|
||||
});
|
||||
await prisma.offering.update({
|
||||
where: { id: offering.id },
|
||||
data: { config: originalOfferingConfig },
|
||||
});
|
||||
const restored = await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: { note: "恢复集成测试模板基线" },
|
||||
});
|
||||
assert.equal(restored.statusCode, 201);
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can create and version an inquiry form", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
|
||||
Reference in new issue
Block a user