提交
This commit is contained in:
1 parent
417d6c9c51
commit
c8fe0cdc20
102 files changed
+19847
-12224
No files matched your search
@@ -510,6 +510,134 @@ class TestBuildProgress(unittest.TestCase):
|
||||
pending = [x for x in items if x["kind"] == "pending_node"]
|
||||
self.assertTrue(any(p["nodeKey"] == "a2" for p in pending))
|
||||
|
||||
def test_running_shows_all_subsequent_pending_nodes(self):
|
||||
"""进行中应挂出路径上全部后续节点,而非只露一个空壳。"""
|
||||
from app.services.oa_engine import build_progress_items
|
||||
|
||||
root = {
|
||||
"id": "s",
|
||||
"type": "start",
|
||||
"child": {
|
||||
"id": "a1",
|
||||
"type": "approval",
|
||||
"name": "一级审批",
|
||||
"child": {
|
||||
"id": "a2",
|
||||
"type": "approval",
|
||||
"name": "二级审批",
|
||||
"child": {
|
||||
"id": "a3",
|
||||
"type": "approval",
|
||||
"name": "三级审批",
|
||||
"child": {"id": "e1", "type": "end"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ts = datetime(2026, 7, 17, 11, 0, 0)
|
||||
t1 = MagicMock(
|
||||
id="t1",
|
||||
node_key="a1",
|
||||
node_name="一级审批",
|
||||
task_type="approval",
|
||||
status="pending",
|
||||
assignee_user_id="u1",
|
||||
order_num=0,
|
||||
round_no=1,
|
||||
create_time=ts,
|
||||
update_time=ts,
|
||||
comment_text=None,
|
||||
resolve_source="users",
|
||||
sign_mode="or",
|
||||
)
|
||||
inst = MagicMock(
|
||||
status="running",
|
||||
initiator_user_id="u0",
|
||||
current_round=1,
|
||||
create_time=ts,
|
||||
update_time=ts,
|
||||
form_data_json="{}",
|
||||
tenant_no="t1",
|
||||
initiator_dept_id="",
|
||||
)
|
||||
items = build_progress_items(
|
||||
inst=inst,
|
||||
flow_root=root,
|
||||
tasks=[t1],
|
||||
name_map={"u0": "发起人", "u1": "甲"},
|
||||
events=[],
|
||||
)
|
||||
pending = [x for x in items if x["kind"] == "pending_node"]
|
||||
self.assertEqual([p["nodeKey"] for p in pending], ["a2", "a3", "e1"])
|
||||
self.assertEqual([p["title"] for p in pending], ["二级审批", "三级审批", "结束"])
|
||||
self.assertEqual(pending[-1]["taskType"], "end")
|
||||
|
||||
def test_or_sign_same_node_merged_into_one_card(self):
|
||||
"""或签同节点三人只投影一张进度卡片,people 含各人状态。"""
|
||||
from app.services.oa_engine import build_progress_items
|
||||
|
||||
root = {
|
||||
"id": "s",
|
||||
"type": "start",
|
||||
"child": {
|
||||
"id": "a1",
|
||||
"type": "approval",
|
||||
"name": "部门审批",
|
||||
"child": {"id": "e1", "type": "end"},
|
||||
},
|
||||
}
|
||||
ts = datetime(2026, 7, 17, 10, 0, 0)
|
||||
ts2 = datetime(2026, 7, 17, 10, 5, 0)
|
||||
|
||||
def mk(tid, uid, status, comment=None, update=None):
|
||||
return MagicMock(
|
||||
id=tid,
|
||||
node_key="a1",
|
||||
node_name="部门审批",
|
||||
task_type="approval",
|
||||
status=status,
|
||||
assignee_user_id=uid,
|
||||
order_num=0,
|
||||
round_no=1,
|
||||
create_time=ts,
|
||||
update_time=update or ts,
|
||||
comment_text=comment,
|
||||
resolve_source="users",
|
||||
sign_mode="or",
|
||||
)
|
||||
|
||||
tasks = [
|
||||
mk("t1", "u1", "approved", "同意", ts2),
|
||||
mk("t2", "u2", "done"),
|
||||
mk("t3", "u3", "done"),
|
||||
]
|
||||
inst = MagicMock(
|
||||
status="completed",
|
||||
initiator_user_id="u0",
|
||||
current_round=1,
|
||||
create_time=ts,
|
||||
update_time=ts2,
|
||||
)
|
||||
items = build_progress_items(
|
||||
inst=inst,
|
||||
flow_root=root,
|
||||
tasks=tasks,
|
||||
name_map={"u0": "发起人", "u1": "甲", "u2": "乙", "u3": "丙"},
|
||||
events=[],
|
||||
)
|
||||
task_items = [x for x in items if x["kind"] == "task"]
|
||||
self.assertEqual(len(task_items), 1)
|
||||
card = task_items[0]
|
||||
self.assertEqual(card["nodeKey"], "a1")
|
||||
self.assertEqual(card["status"], "approved")
|
||||
self.assertEqual(card["signMode"], "or")
|
||||
self.assertEqual(len(card["people"]), 3)
|
||||
self.assertEqual(
|
||||
[(p["nickName"], p["status"]) for p in card["people"]],
|
||||
[("甲", "approved"), ("乙", "done"), ("丙", "done")],
|
||||
)
|
||||
self.assertIn("甲:同意", card["commentText"])
|
||||
|
||||
def test_terminal_status_excludes_pending_nodes(self):
|
||||
from app.services.oa_engine import build_progress_items
|
||||
|
||||
|
||||
Reference in new issue
Block a user