feat: 增加模板安装与品牌工作空间接口

This commit is contained in:
que01 committed 2026-09-20 00:11:44 +08:00
1 parent 8795086ece
commit a73e377f91
3 files changed
+154

No files matched your search

+32
View File
@@ -46,6 +46,38 @@ test("health and public content are available without authentication", async ()
assert.ok(JSON.parse(services.body).length >= 3);
});
test("admin can install a template and public workspace exposes enabled configuration", 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 before = await request("/admin/workspace");
assert.equal(before.statusCode, 401);
const installed = await request("/admin/workspace/install", {
method: "POST",
headers: { authorization: `Bearer ${token}` },
payload: { templateKey: "personal" },
});
assert.equal(installed.statusCode, 201);
assert.equal(JSON.parse(installed.body).template.key, "personal");
try {
const workspace = await request("/admin/workspace", {
headers: { authorization: `Bearer ${token}` },
});
assert.equal(workspace.statusCode, 200);
assert.equal(JSON.parse(workspace.body).installations.length, 1);
assert.equal(JSON.parse(workspace.body).fields.length, 5);
const publicWorkspace = await request("/public/workspace");
assert.equal(publicWorkspace.statusCode, 200);
assert.equal(JSON.parse(publicWorkspace.body).modules.length, 4);
} finally {
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
await prisma.brandModule.deleteMany({ where: { brandId } });
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
}
});
test("admin booking endpoints reject missing or customer credentials", async () => {
const missing = await request("/admin/bookings");
assert.equal(missing.statusCode, 401);