feat: 增加品牌工作空间模块与字段配置接口
This commit is contained in:
1 parent
02aa698fb9
commit
6e1aca3e27
3 files changed
+162
No files matched your search
@@ -78,6 +78,60 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can customize workspace modules and fields with brand isolation", 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 install = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { templateKey: "food" },
|
||||
});
|
||||
assert.equal(install.statusCode, 201);
|
||||
const workspace = await request("/admin/workspace", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
const moduleId = JSON.parse(workspace.body).modules[0].id;
|
||||
const updatedModule = await request(`/admin/workspace/modules/${moduleId}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { title: "我的品牌介绍", isEnabled: false },
|
||||
});
|
||||
assert.equal(updatedModule.statusCode, 200);
|
||||
const createdField = await request("/admin/workspace/fields", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
scope: "profile",
|
||||
key: `region-${Date.now()}`,
|
||||
label: "服务区域",
|
||||
type: "text",
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
assert.equal(createdField.statusCode, 201);
|
||||
const fieldId = JSON.parse(createdField.body).id;
|
||||
try {
|
||||
const updatedField = await request(`/admin/workspace/fields/${fieldId}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { label: "主要服务区域", visibleWhen: { mode: "all", rules: [] } },
|
||||
});
|
||||
assert.equal(updatedField.statusCode, 200);
|
||||
const deletedField = await request(`/admin/workspace/fields/${fieldId}`, {
|
||||
method: "DELETE",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(deletedField.statusCode, 200);
|
||||
} finally {
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
||||
await prisma.brandTemplateInstallation.deleteMany({ where: { brandId } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can manage offerings and public endpoint hides disabled offerings", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
|
||||
Reference in new issue
Block a user