feat: 接入配置驱动的动态咨询表单
This commit is contained in:
1 parent
8872316ad3
commit
02966cf65c
9 files changed
+232
-3
No files matched your search
@@ -134,7 +134,7 @@ export class PublicWorkspaceController {
|
||||
@Get()
|
||||
async get(): Promise<unknown> {
|
||||
const brandId = process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001";
|
||||
const [brand, modules, fields, offerings] = await Promise.all([
|
||||
const [brand, modules, fields, offerings, inquiryForm] = await Promise.all([
|
||||
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
||||
this.prisma.brandModule.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
@@ -148,8 +148,12 @@ export class PublicWorkspaceController {
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
}),
|
||||
this.prisma.inquiryForm.findFirst({
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
}),
|
||||
]);
|
||||
return { brand, modules, fields, offerings };
|
||||
return { brand, modules, fields, offerings, inquiryForm };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ test("health and public content are available without authentication", async ()
|
||||
});
|
||||
|
||||
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 } });
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||
@@ -74,6 +76,7 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
const publicWorkspace = await request("/public/workspace");
|
||||
assert.equal(publicWorkspace.statusCode, 200);
|
||||
assert.equal(JSON.parse(publicWorkspace.body).modules.length, 4);
|
||||
assert.equal(JSON.parse(publicWorkspace.body).inquiryForm, null);
|
||||
const conflict = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -176,6 +179,9 @@ test("admin can create and version an inquiry form", async () => {
|
||||
assert.equal(JSON.parse(updated.body).version, 2);
|
||||
const publicForm = await request(`/public/inquiry-forms/${id}`);
|
||||
assert.equal(publicForm.statusCode, 200);
|
||||
const publicWorkspace = await request("/public/workspace");
|
||||
assert.equal(publicWorkspace.statusCode, 200);
|
||||
assert.equal(JSON.parse(publicWorkspace.body).inquiryForm.id, id);
|
||||
const submission = await request("/customer/inquiry-submissions", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
|
||||
Reference in new issue
Block a user