Files
zen/test-data/graphs/partner-revenue-sharing.json
T
bcrevar-gorulesandStefan 4a59f222db feat: add snapshot tests (#385)
* first draft

* mock time; update snapshots

* fix

* Node.js test fix

---------

Co-authored-by: Stefan <stefan@gorules.io>
2025-08-20 16:30:28 +02:00

244 lines
6.6 KiB
JSON

{
"tests": [
{
"input": {
"partnerType": "content",
"revenueGenerated": 1500000,
"serviceCategory": "streaming",
"customerSegment": "enterprise",
"contractDuration": 24,
"exclusivity": true
},
"output": {
"baseCommission": 525000,
"bonusCommission": 37950,
"durationMultiplier": 1.1,
"segmentMultiplier": 1.15,
"telcoRevenue": 937050,
"totalCommission": 562950
}
}
],
"nodes": [
{
"type": "inputNode",
"content": {
"schema": "{\n \"type\": \"object\",\n \"properties\": {\n \"partnerType\": {\n \"type\": \"string\",\n \"description\": \"Type of partner (content, service, technology, etc.)\"\n },\n \"revenueGenerated\": {\n \"type\": \"number\",\n \"description\": \"Total revenue generated by the partner\"\n },\n \"serviceCategory\": {\n \"type\": \"string\",\n \"description\": \"Category of service (streaming, voice, IoT, etc.)\"\n },\n \"customerSegment\": {\n \"type\": \"string\",\n \"description\": \"Segment of customers (consumer, business, enterprise)\"\n },\n \"contractDuration\": {\n \"type\": \"number\",\n \"description\": \"Duration of partnership contract in months\"\n },\n \"exclusivity\": {\n \"type\": \"boolean\",\n \"description\": \"Whether the partnership is exclusive\"\n }\n }\n}\n"
},
"id": "ip1",
"name": "request",
"position": {
"x": 110,
"y": 114
}
},
{
"type": "decisionTableNode",
"content": {
"hitPolicy": "first",
"rules": [
{
"_id": "r1",
"i1-1": "'content'",
"i1-2": "'streaming'",
"i1-3": "> 1000000",
"i1-4": "true",
"o1-1": "0.35",
"o1-2": "0.02",
"o1-3": "'premium'"
},
{
"_id": "r2",
"i1-1": "'content'",
"i1-2": "'streaming'",
"i1-3": "> 500000",
"i1-4": "",
"o1-1": "0.30",
"o1-2": "0.015",
"o1-3": "'standard'"
},
{
"_id": "r3",
"i1-1": "'content'",
"i1-2": "'streaming'",
"i1-3": "",
"i1-4": "",
"o1-1": "0.25",
"o1-2": "0.01",
"o1-3": "'basic'"
},
{
"_id": "r4",
"i1-1": "'service'",
"i1-2": "'voice'",
"i1-3": "> 750000",
"i1-4": "",
"o1-1": "0.28",
"o1-2": "0.02",
"o1-3": "'premium'"
},
{
"_id": "r5",
"i1-1": "'service'",
"i1-2": "'voice'",
"i1-3": "",
"i1-4": "",
"o1-1": "0.22",
"o1-2": "0.01",
"o1-3": "'standard'"
},
{
"_id": "r6",
"i1-1": "'service'",
"i1-2": "'IoT'",
"i1-3": "",
"i1-4": "",
"o1-1": "0.32",
"o1-2": "0.025",
"o1-3": "'technological'"
},
{
"_id": "r7",
"i1-1": "'technology'",
"i1-2": "",
"i1-3": "> 1000000",
"i1-4": "",
"o1-1": "0.40",
"o1-2": "0.03",
"o1-3": "'strategic'"
},
{
"_id": "r8",
"i1-1": "'technology'",
"i1-2": "",
"i1-3": "",
"i1-4": "",
"o1-1": "0.35",
"o1-2": "0.02",
"o1-3": "'standard'"
},
{
"_id": "r9",
"i1-1": "",
"i1-2": "",
"i1-3": "",
"i1-4": "",
"o1-1": "0.20",
"o1-2": "0.01",
"o1-3": "'default'"
}
],
"inputs": [
{
"id": "i1-1",
"name": "Partner Type",
"field": "partnerType"
},
{
"id": "i1-2",
"name": "Service Category",
"field": "serviceCategory"
},
{
"id": "i1-3",
"name": "Revenue",
"field": "revenueGenerated"
},
{
"id": "i1-4",
"name": "Exclusivity",
"field": "exclusivity"
}
],
"outputs": [
{
"id": "o1-1",
"name": "Base Commission Rate",
"field": "baseCommissionRate"
},
{
"id": "o1-2",
"name": "Performance Bonus Rate",
"field": "bonusRate"
},
{
"id": "o1-3",
"name": "Partner Tier",
"field": "partnerTier"
}
],
"passThrough": true,
"inputField": null,
"outputPath": null,
"executionMode": "single"
},
"id": "dt1",
"name": "partnerCommissionRates",
"position": {
"x": 430,
"y": 114
}
},
{
"type": "expressionNode",
"content": {
"expressions": [
{
"id": "e1",
"key": "durationMultiplier",
"value": "contractDuration <= 12 ? 1 : (contractDuration <= 36 ? 1.1 : 1.2)"
},
{
"id": "e2",
"key": "segmentMultiplier",
"value": "customerSegment == 'enterprise' ? 1.15 : (customerSegment == 'business' ? 1.1 : 1)"
},
{
"id": "e3",
"key": "baseCommission",
"value": "revenueGenerated * baseCommissionRate"
},
{
"id": "e4",
"key": "bonusCommission",
"value": "revenueGenerated * bonusRate * $.durationMultiplier * $.segmentMultiplier"
},
{
"id": "e5",
"key": "totalCommission",
"value": "$.baseCommission + $.bonusCommission"
},
{
"id": "e6",
"key": "telcoRevenue",
"value": "revenueGenerated - $.totalCommission"
}
],
"passThrough": false,
"inputField": null,
"outputPath": null,
"executionMode": "single"
},
"id": "ex1",
"name": "calculateCommission",
"position": {
"x": 750,
"y": 114
}
}
],
"edges": [
{
"id": "e1",
"sourceId": "ip1",
"targetId": "dt1",
"type": "edge"
},
{
"id": "e2",
"sourceId": "dt1",
"targetId": "ex1",
"type": "edge"
}
]
}