feat: 实现小程序代码发布任务闭环
This commit is contained in:
1 parent
9b35b8e7a7
commit
526a9db789
14 files changed
+7242
-249
No files matched your search
@@ -23,11 +23,79 @@ before(async () => {
|
||||
after(async () => {
|
||||
await app.close();
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId } });
|
||||
await prisma.miniAppReleaseTask.deleteMany({ where: { brandId } });
|
||||
await prisma.booking.deleteMany({ where: { id: { in: createdBookingIds } } });
|
||||
await prisma.customerUser.deleteMany({ where: { openid } });
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
test("miniapp release tasks are authorized, idempotent, and state checked", async () => {
|
||||
const missing = await request("/admin/miniapp-releases");
|
||||
assert.equal(missing.statusCode, 401);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/miniapp-releases", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const headers = { authorization: `Bearer ${JSON.parse(login.body).token}` };
|
||||
const current = JSON.parse((await request("/admin/releases", { headers })).body).find(
|
||||
(item) => item.status === "published",
|
||||
);
|
||||
assert.ok(current);
|
||||
const created = await request("/admin/miniapp-releases", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: {},
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
assert.equal(JSON.parse(created.body).version, current.version);
|
||||
const repeated = await request("/admin/miniapp-releases", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: {},
|
||||
});
|
||||
assert.equal(JSON.parse(repeated.body).id, JSON.parse(created.body).id);
|
||||
const taskId = JSON.parse(created.body).id;
|
||||
const skipped = await request(`/admin/miniapp-releases/${taskId}/status`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { status: "published" },
|
||||
});
|
||||
assert.equal(skipped.statusCode, 409);
|
||||
const uploaded = await request(`/admin/miniapp-releases/${taskId}/status`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { status: "uploaded", weappUploadId: "test-upload" },
|
||||
});
|
||||
assert.equal(uploaded.statusCode, 200);
|
||||
assert.equal(JSON.parse(uploaded.body).status, "uploaded");
|
||||
const underReview = await request(`/admin/miniapp-releases/${taskId}/status`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { status: "under_review" },
|
||||
});
|
||||
assert.equal(JSON.parse(underReview.body).status, "under_review");
|
||||
const approved = await request(`/admin/miniapp-releases/${taskId}/status`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { status: "approved" },
|
||||
});
|
||||
assert.equal(JSON.parse(approved.body).status, "approved");
|
||||
const published = await request(`/admin/miniapp-releases/${taskId}/status`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { status: "published" },
|
||||
});
|
||||
assert.equal(JSON.parse(published.body).status, "published");
|
||||
});
|
||||
|
||||
test("real template declarations persist brand offering and trust bindings through draft and publication", async (context) => {
|
||||
const user = await prisma.adminUser.findUniqueOrThrow({ where: { username: "admin" } });
|
||||
const { runtimeContractForBinding } = await import("@personal-brand/types");
|
||||
|
||||
Reference in new issue
Block a user