fix(escort): 管理员下单也按员工档案回填陪诊师快照
下单指定陪诊师时不再按 isAdmin 跳过解析,避免客户端原始 employeeId 落库、姓名电话为空,导致详情页误显示待分配;补充管理员下单的回归用例。
This commit is contained in:
@@ -49,11 +49,11 @@ function buildBody(attendant) {
|
||||
};
|
||||
}
|
||||
|
||||
function createCtx(body) {
|
||||
function createCtx(body, user = { _id: USER_ID }) {
|
||||
return {
|
||||
request: { query: {}, body },
|
||||
params: {},
|
||||
state: { user: { _id: USER_ID } },
|
||||
state: { user },
|
||||
headers: {},
|
||||
status: 200,
|
||||
body: null,
|
||||
@@ -83,7 +83,7 @@ function employeeFindOneStub(employee, overrides = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
async function runCreate({ attendant, employee = buildEmployee() } = {}) {
|
||||
async function runCreate({ attendant, employee = buildEmployee(), user } = {}) {
|
||||
const calls = { payload: null, bumped: null };
|
||||
const recordStub = {
|
||||
findByIdempotencyKey: async () => null,
|
||||
@@ -99,7 +99,7 @@ async function runCreate({ attendant, employee = buildEmployee() } = {}) {
|
||||
},
|
||||
});
|
||||
|
||||
const ctx = createCtx(buildBody(attendant));
|
||||
const ctx = createCtx(buildBody(attendant), user);
|
||||
await withModel("HealthProfile", { findProfileById: async () => buildProfile() }, () =>
|
||||
withModel("EscortRecord", recordStub, () =>
|
||||
withModel("Employee", employeeStub, () => new HandlerEscortRecord().createRecord(ctx))
|
||||
@@ -125,6 +125,28 @@ test("用户下单指定陪诊师:服务端回填快照并累加接单数", as
|
||||
assert.equal(calls.bumped, EMPLOYEE_ID);
|
||||
});
|
||||
|
||||
test("管理员用用户端下单指定陪诊师:同样回填快照而不是落库 employeeId", async () => {
|
||||
const admin = {
|
||||
_id: USER_ID,
|
||||
apps: [{ appId: "web-escort-admin", roles: ["admin"], status: "active" }],
|
||||
};
|
||||
const { ctx, calls } = await runCreate({
|
||||
user: admin,
|
||||
attendant: { employeeId: EMPLOYEE_ID },
|
||||
});
|
||||
|
||||
assert.equal(ctx.body.code, 0);
|
||||
assert.deepEqual(calls.payload.attendant, {
|
||||
id: EMPLOYEE_USER_ID,
|
||||
name: "李四",
|
||||
sex: "female",
|
||||
mobile: "13700137000",
|
||||
sharedWith: [],
|
||||
});
|
||||
assert.equal(calls.payload.attendant.employeeId, undefined);
|
||||
assert.equal(calls.bumped, EMPLOYEE_ID);
|
||||
});
|
||||
|
||||
test("用户不指定陪诊师:订单进入公共池,不写陪诊师、不累加接单数", async () => {
|
||||
const { ctx, calls } = await runCreate({ attendant: null });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user