feat(backend): match __initiator__ contains in condition groups
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a37bfac213
commit
3d88f52e2e
2 files changed
+87
-9
No files matched your search
@@ -112,6 +112,51 @@ class TestOaEngineHelpers(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(g["name"], "hit")
|
||||
|
||||
def test_condition_contains_initiator(self):
|
||||
groups = [
|
||||
{
|
||||
"name": "hit",
|
||||
"rules": [
|
||||
{
|
||||
"field": "__initiator__",
|
||||
"op": "contains",
|
||||
"value": ["u1", "u2"],
|
||||
}
|
||||
],
|
||||
"child": {"id": "n1", "type": "end"},
|
||||
},
|
||||
{"name": "default", "rules": [], "child": {"id": "n2", "type": "end"}},
|
||||
]
|
||||
g = _match_condition_group(groups, {}, initiator_user_id="u2")
|
||||
self.assertEqual(g["name"], "hit")
|
||||
g2 = _match_condition_group(groups, {}, initiator_user_id="u9")
|
||||
self.assertEqual(g2["name"], "default")
|
||||
|
||||
def test_condition_initiator_and_form_field(self):
|
||||
groups = [
|
||||
{
|
||||
"name": "both",
|
||||
"rules": [
|
||||
{"field": "__initiator__", "op": "contains", "value": ["u1"]},
|
||||
{"field": "days", "op": ">", "value": 3},
|
||||
],
|
||||
"child": {"id": "n1", "type": "end"},
|
||||
},
|
||||
{"name": "default", "isDefault": True, "child": {"id": "n2", "type": "end"}},
|
||||
]
|
||||
self.assertEqual(
|
||||
_match_condition_group(
|
||||
groups, {"days": 5}, initiator_user_id="u1"
|
||||
)["name"],
|
||||
"both",
|
||||
)
|
||||
self.assertEqual(
|
||||
_match_condition_group(
|
||||
groups, {"days": 5}, initiator_user_id="u9"
|
||||
)["name"],
|
||||
"default",
|
||||
)
|
||||
|
||||
def test_flow_node_key_order_cc_before_approval(self):
|
||||
root = {
|
||||
"id": "s",
|
||||
|
||||
Reference in new issue
Block a user