fix: 修复后台配置接口与管理后台高优先级问题
This commit is contained in:
1 parent
69bbeb1b1b
commit
c393a5231e
6 files changed
+53
-14
No files matched your search
@@ -45,7 +45,7 @@ test("health and public content are available without authentication", async ()
|
||||
|
||||
test("admin booking endpoints reject missing or customer credentials", async () => {
|
||||
const missing = await request("/admin/bookings");
|
||||
assert.equal(missing.statusCode, 400);
|
||||
assert.equal(missing.statusCode, 401);
|
||||
|
||||
const customer = await request("/admin/bookings", {
|
||||
headers: { authorization: "Bearer invalid-token" },
|
||||
@@ -92,7 +92,7 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
assert.ok(adminToken);
|
||||
|
||||
const unauthorized = await request("/admin/config/brand");
|
||||
assert.equal(unauthorized.statusCode, 400);
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
|
||||
const brandBefore = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
assert.ok(brandBefore);
|
||||
@@ -145,10 +145,17 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
test("admin can manage trust content", 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;
|
||||
assert.equal((await request("/admin/config/trust-content")).statusCode, 400);
|
||||
assert.equal((await request("/admin/config/trust-content")).statusCode, 401);
|
||||
const created = await request("/admin/config/trust-content", { method: "POST", headers: { authorization: `Bearer ${token}` }, payload: { type: "profile", title: "关于我", content: "集成测试内容", summary: "测试摘要" } });
|
||||
assert.equal(created.statusCode, 201);
|
||||
const id = JSON.parse(created.body).id;
|
||||
const draft = await request("/admin/config/trust-content", { method: "POST", headers: { authorization: `Bearer ${token}` }, payload: { type: "experience", title: "草稿", content: "不应公开", isPublished: false } });
|
||||
assert.equal(draft.statusCode, 201);
|
||||
const publicContent = await request("/public/trust-content");
|
||||
assert.equal(publicContent.statusCode, 200);
|
||||
const publicItems = JSON.parse(publicContent.body);
|
||||
assert.ok(publicItems.some((item) => item.id === id));
|
||||
assert.ok(!publicItems.some((item) => item.id === JSON.parse(draft.body).id));
|
||||
try {
|
||||
const list = await request("/admin/config/trust-content", { headers: { authorization: `Bearer ${token}` } });
|
||||
assert.equal(list.statusCode, 200);
|
||||
@@ -158,6 +165,7 @@ test("admin can manage trust content", async () => {
|
||||
} finally {
|
||||
const deleted = await request(`/admin/config/trust-content/${id}`, { method: "DELETE", headers: { authorization: `Bearer ${token}` } });
|
||||
assert.equal(deleted.statusCode, 200);
|
||||
await prisma.trustContent.delete({ where: { id: JSON.parse(draft.body).id } });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user