fix: 校验必需信任内容完整性
This commit is contained in:
1 parent
5ed06b1abe
commit
0c5ff79b42
4 files changed
+71
-10
No files matched your search
@@ -98,11 +98,16 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
where: { brandId, type: "schedule", isPublished: true },
|
||||
});
|
||||
assert.ok(scheduleTrust);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { isPublished: false },
|
||||
});
|
||||
const originalScheduleTrust = {
|
||||
isPublished: scheduleTrust.isPublished,
|
||||
title: scheduleTrust.title,
|
||||
content: scheduleTrust.content,
|
||||
};
|
||||
try {
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { isPublished: false },
|
||||
});
|
||||
const missingTrust = await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
@@ -112,10 +117,54 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
missingTrustBody.checks.find((check) => check.key === "trust:schedule")?.passed,
|
||||
false,
|
||||
);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { isPublished: true, title: " " },
|
||||
});
|
||||
const missingTitle = JSON.parse(
|
||||
(
|
||||
await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
})
|
||||
).body,
|
||||
);
|
||||
assert.equal(missingTitle.ready, false);
|
||||
assert.equal(
|
||||
missingTitle.checks.find((check) => check.key === "trust:schedule")?.passed,
|
||||
false,
|
||||
);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { title: originalScheduleTrust.title, content: " \n " },
|
||||
});
|
||||
const missingContent = JSON.parse(
|
||||
(
|
||||
await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
})
|
||||
).body,
|
||||
);
|
||||
assert.equal(missingContent.ready, false);
|
||||
assert.equal(
|
||||
missingContent.checks.find((check) => check.key === "trust:schedule")?.passed,
|
||||
false,
|
||||
);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: originalScheduleTrust,
|
||||
});
|
||||
const validTrust = JSON.parse(
|
||||
(
|
||||
await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
})
|
||||
).body,
|
||||
);
|
||||
assert.equal(validTrust.checks.find((check) => check.key === "trust:schedule")?.passed, true);
|
||||
} finally {
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { isPublished: true },
|
||||
data: originalScheduleTrust,
|
||||
});
|
||||
}
|
||||
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||
|
||||
Reference in new issue
Block a user