test: 收口预约工作流状态历史验证
This commit is contained in:
1 parent
e9d3f77639
commit
36f5415483
3 files changed
+42
-10
No files matched your search
@@ -517,6 +517,14 @@ test("customer can create and cancel a package booking", async () => {
|
||||
assert.equal(createdBody.estimatedAmount, service.priceAmount * 2);
|
||||
const booking = await prisma.booking.findUnique({ where: { bookingNo: createdBody.bookingNo } });
|
||||
assert.ok(booking);
|
||||
assert.equal(booking.workflowKey, "booking.basic");
|
||||
assert.equal(booking.currentState, "received");
|
||||
assert.equal(booking.offeringId, service.offeringId);
|
||||
const initialTransitions = await prisma.bookingStateTransition.findMany({
|
||||
where: { bookingId: booking.id },
|
||||
});
|
||||
assert.equal(initialTransitions.length, 1);
|
||||
assert.equal(initialTransitions[0].toState, "received");
|
||||
createdBookingIds.push(booking.id);
|
||||
|
||||
const cancelled = await request(`/customer/bookings/${booking.id}/cancel`, {
|
||||
@@ -525,6 +533,14 @@ test("customer can create and cancel a package booking", async () => {
|
||||
});
|
||||
assert.equal(cancelled.statusCode, 201);
|
||||
assert.equal(JSON.parse(cancelled.body).status, "cancelled");
|
||||
const transitions = await prisma.bookingStateTransition.findMany({
|
||||
where: { bookingId: booking.id },
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
assert.deepEqual(
|
||||
transitions.map((item) => item.toState),
|
||||
["received", "cancelled"],
|
||||
);
|
||||
});
|
||||
|
||||
test("admin can advance booking status but cannot skip the state machine", async () => {
|
||||
@@ -561,6 +577,8 @@ test("admin can advance booking status but cannot skip the state machine", async
|
||||
});
|
||||
assert.equal(contacting.statusCode, 201);
|
||||
assert.equal(JSON.parse(contacting.body).status, "contacting");
|
||||
const contactingState = await prisma.booking.findUnique({ where: { id: booking.id } });
|
||||
assert.equal(contactingState?.currentState, "contacting");
|
||||
|
||||
const skipped = await request(`/admin/bookings/${booking.id}/status`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in new issue
Block a user