test: 验证门窗模板运行时契约
This commit is contained in:
1 parent
041a6a7f02
commit
286aad2955
2 files changed
+39
No files matched your search
@@ -151,6 +151,42 @@ test("admin capability list includes template defaults and brand overrides", asy
|
||||
await prisma.capabilityInstallation.deleteMany({ where: { brandId } });
|
||||
});
|
||||
|
||||
test("admin can install doors industry template through the shared runtime contract", 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 } });
|
||||
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;
|
||||
try {
|
||||
const installed = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { templateKey: "doors" },
|
||||
});
|
||||
assert.equal(installed.statusCode, 201);
|
||||
assert.equal(JSON.parse(installed.body).template.key, "doors");
|
||||
const workspace = await request("/public/workspace");
|
||||
assert.equal(workspace.statusCode, 200);
|
||||
const body = JSON.parse(workspace.body);
|
||||
assert.equal(body.template.key, "doors");
|
||||
assert.ok(body.modules.some((item) => item.type === "offering"));
|
||||
assert.ok(body.modules.some((item) => item.type === "inquiry"));
|
||||
assert.deepEqual(
|
||||
body.runtimeCapabilities.map((item) => item.key),
|
||||
["offerings", "inquiry"],
|
||||
);
|
||||
} finally {
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||
}
|
||||
});
|
||||
|
||||
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