feat: 强化动态表单字段校验

This commit is contained in:
que01 committed 2026-09-23 10:38:05 +08:00
1 parent ef0aa169a6
commit d6c47ce143
7 files changed
+94 -4

No files matched your search

+18 -1
View File
@@ -486,7 +486,7 @@ test("admin can create and version an inquiry form", async () => {
fieldsSnapshot: [
{ key: "budget", type: "number", label: "预算", required: true },
{
key: "contactMethod",
key: "contact_method",
type: "select",
label: "联系渠道",
options: [{ label: "微信", value: "wechat" }],
@@ -615,6 +615,23 @@ test("admin can create and version an inquiry form", async () => {
}
});
test("admin rejects invalid dynamic inquiry field definitions", 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 invalid = await request("/admin/workspace/forms", {
method: "POST",
headers: { authorization: `Bearer ${token}` },
payload: {
name: "非法字段表单",
fieldsSnapshot: [{ key: "ContactMethod", type: "select", label: "渠道", options: [] }],
},
});
assert.equal(invalid.statusCode, 400);
});
test("admin can manage offerings and public endpoint hides disabled offerings", async () => {
const login = await request("/admin/session/login", {
method: "POST",