feat: 增加业务提供项管理与详情接口
This commit is contained in:
1 parent
a73e377f91
commit
066f6595e4
4 files changed
+152
No files matched your search
@@ -78,6 +78,45 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can manage offerings and public endpoint hides disabled offerings", 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 created = await request("/admin/workspace/offerings", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
kind: "product",
|
||||
name: `测试提供项-${Date.now()}`,
|
||||
summary: "测试摘要",
|
||||
isEnabled: true,
|
||||
},
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const id = JSON.parse(created.body).id;
|
||||
try {
|
||||
const listed = await request("/admin/workspace/offerings", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(listed.statusCode, 200);
|
||||
assert.ok(JSON.parse(listed.body).some((item) => item.id === id));
|
||||
const publicItem = await request(`/public/offerings/${id}`);
|
||||
assert.equal(publicItem.statusCode, 200);
|
||||
const updated = await request(`/admin/workspace/offerings/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { isEnabled: false },
|
||||
});
|
||||
assert.equal(updated.statusCode, 200);
|
||||
const hidden = await request(`/public/offerings/${id}`);
|
||||
assert.equal(hidden.statusCode, 400);
|
||||
} finally {
|
||||
await prisma.offering.delete({ where: { id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin booking endpoints reject missing or customer credentials", async () => {
|
||||
const missing = await request("/admin/bookings");
|
||||
assert.equal(missing.statusCode, 401);
|
||||
|
||||
Reference in new issue
Block a user