feat: 订单获取链路收尾:管理端指派、接单开关与用户指定陪诊师

This commit is contained in:
lik
2026-11-10 15:13:48 +08:00
parent 78138a417b
commit b160102f12
8 changed files with 725 additions and 32 deletions
+23 -12
View File
@@ -61,13 +61,15 @@ function createCtx({ body = {}, query = {}, user, params = { id: RECORD_ID } } =
};
}
function employeeFindOneStub(employee) {
function employeeFindOneStub(employee, overrides = {}) {
return {
findOne: () => ({
select: () => ({
lean: () => ({ exec: async () => employee }),
}),
}),
incrementOrderCount: async () => {},
...overrides,
};
}
@@ -186,6 +188,7 @@ test("实习陪诊师不能接单", async () => {
test("正式陪诊师接单写入陪诊师快照,不校验支付状态", async () => {
let payload = null;
let bumped = null;
const record = buildRecord();
const recordStub = {
findById: async () => record,
@@ -198,18 +201,26 @@ test("正式陪诊师接单写入陪诊师快照,不校验支付状态", async
},
};
await withModel("Employee", employeeFindOneStub(buildEmployee()), () =>
withModel("EscortRecord", recordStub, async () => {
const ctx = createCtx({ user: { _id: CERT_USER_ID } });
await new HandlerEscortRecord().acceptRecord(ctx);
await withModel(
"Employee",
employeeFindOneStub(buildEmployee(), {
incrementOrderCount: async (employeeId) => {
bumped = employeeId;
},
}),
() =>
withModel("EscortRecord", recordStub, async () => {
const ctx = createCtx({ user: { _id: CERT_USER_ID } });
await new HandlerEscortRecord().acceptRecord(ctx);
assert.equal(ctx.body.code, 0);
assert.equal(payload.id, CERT_USER_ID);
assert.equal(payload.name, "李四");
assert.equal(payload.sex, "male");
assert.equal(payload.mobile, "13700137000");
assert.equal(ctx.body.data.record.attendantAssignedToMe, true);
})
assert.equal(ctx.body.code, 0);
assert.equal(payload.id, CERT_USER_ID);
assert.equal(payload.name, "李四");
assert.equal(payload.sex, "male");
assert.equal(payload.mobile, "13700137000");
assert.equal(ctx.body.data.record.attendantAssignedToMe, true);
assert.equal(bumped, CERT_EMPLOYEE_ID);
})
);
});