feat(oa): add initiator system field to condition branches
Allow __initiator__ contains matching in publish validation and the flow designer candidate list, excluding it from form useInCondition locks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3d88f52e2e
commit
22be6d8b36
7 files changed
+103
-23
No files matched your search
@@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
from app.services.oa_publish import (
|
||||
count_fillable_fields,
|
||||
validate_condition_rules_against_form,
|
||||
validate_control_types,
|
||||
validate_draft_for_publish,
|
||||
validate_flow_tree,
|
||||
@@ -242,6 +243,51 @@ class TestConditionPublish(unittest.TestCase):
|
||||
)
|
||||
self.assertTrue(any("无效字段" in e or "参与" in e for e in errs))
|
||||
|
||||
def test_initiator_condition_field_allowed(self):
|
||||
errs = validate_condition_rules_against_form(
|
||||
{"rule": []},
|
||||
_condition_flow(
|
||||
rules=[
|
||||
{
|
||||
"field": "__initiator__",
|
||||
"op": "contains",
|
||||
"value": ["u1"],
|
||||
}
|
||||
]
|
||||
),
|
||||
)
|
||||
self.assertEqual(errs, [])
|
||||
|
||||
def test_initiator_condition_empty_value_rejected(self):
|
||||
errs = validate_condition_rules_against_form(
|
||||
{"rule": []},
|
||||
_condition_flow(
|
||||
rules=[
|
||||
{
|
||||
"field": "__initiator__",
|
||||
"op": "contains",
|
||||
"value": [],
|
||||
}
|
||||
]
|
||||
),
|
||||
)
|
||||
self.assertTrue(any("发起人" in e and ("包含" in e or "用户" in e) for e in errs))
|
||||
|
||||
def test_initiator_condition_bad_op_rejected(self):
|
||||
errs = validate_condition_rules_against_form(
|
||||
{"rule": []},
|
||||
_condition_flow(
|
||||
rules=[
|
||||
{
|
||||
"field": "__initiator__",
|
||||
"op": "==",
|
||||
"value": ["u1"],
|
||||
}
|
||||
]
|
||||
),
|
||||
)
|
||||
self.assertTrue(any("发起人" in e and "包含" in e for e in errs))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user