OA 评论选人列表改为请求 users/options 时按当前登录用户部门优先排序,Web 与移动 OA 共用后端稳定排序,便于先选到同部门同事。 Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
"""用户下拉选项:同部门优先排序。"""
|
|
from app.services.user_select_options import prioritize_caller_dept_options
|
|
|
|
|
|
def test_prioritize_caller_dept_keeps_relative_order():
|
|
options = [
|
|
{"label": "外1", "value": "a", "deptId": "d2"},
|
|
{"label": "同1", "value": "b", "deptId": "d1"},
|
|
{"label": "外2", "value": "c", "deptId": "d3"},
|
|
{"label": "同2", "value": "d", "deptId": "d1"},
|
|
{"label": "无部门", "value": "e", "deptId": ""},
|
|
]
|
|
out = prioritize_caller_dept_options(options, "d1")
|
|
assert [x["value"] for x in out] == ["b", "d", "a", "c", "e"]
|
|
|
|
|
|
def test_prioritize_caller_dept_noop_without_caller_dept():
|
|
options = [
|
|
{"label": "a", "value": "a", "deptId": "d1"},
|
|
{"label": "b", "value": "b", "deptId": "d2"},
|
|
]
|
|
assert prioritize_caller_dept_options(options, "") == options
|
|
assert prioritize_caller_dept_options(options, " ") == options
|
|
|
|
|
|
def test_prioritize_caller_dept_empty_list():
|
|
assert prioritize_caller_dept_options([], "d1") == []
|