feat: 完成模板示例内容导入闭环
This commit is contained in:
1 parent
d451c93398
commit
9b1c500c5f
3 files changed
+46
-1
No files matched your search
@@ -237,7 +237,7 @@ class AdminWorkspaceController {
|
||||
kind: sortOrder === 3 ? "service" : "product",
|
||||
name: item[0]!,
|
||||
summary: item[1]!,
|
||||
categoryKey: item[2]!,
|
||||
config: { categoryKey: item[2]! } as Prisma.InputJsonValue,
|
||||
sortOrder,
|
||||
isEnabled: true,
|
||||
})),
|
||||
|
||||
@@ -187,6 +187,39 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can preview and import sample content idempotently", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const preview = await request("/admin/workspace/sample-content/preview", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(preview.statusCode, 200);
|
||||
const imported = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(imported.statusCode, 201);
|
||||
const duplicate = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(duplicate.statusCode, 400);
|
||||
await prisma.offering.deleteMany({
|
||||
where: {
|
||||
brandId,
|
||||
categoryKey: { in: ["entrance-door", "garden-door", "interior-door", "custom"] },
|
||||
},
|
||||
});
|
||||
await prisma.trustContent.deleteMany({
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
||||
});
|
||||
|
||||
test("admin can install a template and public workspace exposes enabled configuration", async () => {
|
||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||
|
||||
Reference in new issue
Block a user