@open-mercato/core 0.4.5-develop-2e9903a57a → 0.4.5-develop-eeccf7adf4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/modules/auth/__integration__/TC-AUTH-001.spec.js +0 -9
- package/dist/modules/auth/__integration__/TC-AUTH-001.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-002.spec.js +0 -22
- package/dist/modules/auth/__integration__/TC-AUTH-002.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-003.spec.js +0 -21
- package/dist/modules/auth/__integration__/TC-AUTH-003.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-004.spec.js +0 -15
- package/dist/modules/auth/__integration__/TC-AUTH-004.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-005.spec.js +0 -11
- package/dist/modules/auth/__integration__/TC-AUTH-005.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-006.spec.js +0 -11
- package/dist/modules/auth/__integration__/TC-AUTH-006.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-007.spec.js +0 -14
- package/dist/modules/auth/__integration__/TC-AUTH-007.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-008.spec.js +0 -26
- package/dist/modules/auth/__integration__/TC-AUTH-008.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-009.spec.js +0 -16
- package/dist/modules/auth/__integration__/TC-AUTH-009.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-010.spec.js +0 -32
- package/dist/modules/auth/__integration__/TC-AUTH-010.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-011.spec.js +0 -26
- package/dist/modules/auth/__integration__/TC-AUTH-011.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-012.spec.js +0 -30
- package/dist/modules/auth/__integration__/TC-AUTH-012.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-013.spec.js +0 -41
- package/dist/modules/auth/__integration__/TC-AUTH-013.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-014.spec.js +0 -25
- package/dist/modules/auth/__integration__/TC-AUTH-014.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-015.spec.js +0 -20
- package/dist/modules/auth/__integration__/TC-AUTH-015.spec.js.map +0 -7
- package/dist/modules/auth/__integration__/TC-AUTH-016.spec.js +0 -76
- package/dist/modules/auth/__integration__/TC-AUTH-016.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-001.spec.js +0 -20
- package/dist/modules/catalog/__integration__/TC-CAT-001.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-002.spec.js +0 -12
- package/dist/modules/catalog/__integration__/TC-CAT-002.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-003.spec.js +0 -28
- package/dist/modules/catalog/__integration__/TC-CAT-003.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-004.spec.js +0 -33
- package/dist/modules/catalog/__integration__/TC-CAT-004.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-005.spec.js +0 -30
- package/dist/modules/catalog/__integration__/TC-CAT-005.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-006.spec.js +0 -31
- package/dist/modules/catalog/__integration__/TC-CAT-006.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-007.spec.js +0 -31
- package/dist/modules/catalog/__integration__/TC-CAT-007.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-008.spec.js +0 -65
- package/dist/modules/catalog/__integration__/TC-CAT-008.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-009.spec.js +0 -31
- package/dist/modules/catalog/__integration__/TC-CAT-009.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-010.spec.js +0 -28
- package/dist/modules/catalog/__integration__/TC-CAT-010.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-011.spec.js +0 -34
- package/dist/modules/catalog/__integration__/TC-CAT-011.spec.js.map +0 -7
- package/dist/modules/catalog/__integration__/TC-CAT-012.spec.js +0 -27
- package/dist/modules/catalog/__integration__/TC-CAT-012.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-001.spec.js +0 -44
- package/dist/modules/core/__integration__/admin/TC-ADMIN-001.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-002.spec.js +0 -53
- package/dist/modules/core/__integration__/admin/TC-ADMIN-002.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-003.spec.js +0 -26
- package/dist/modules/core/__integration__/admin/TC-ADMIN-003.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-004.spec.js +0 -47
- package/dist/modules/core/__integration__/admin/TC-ADMIN-004.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-005.spec.js +0 -33
- package/dist/modules/core/__integration__/admin/TC-ADMIN-005.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-006.spec.js +0 -30
- package/dist/modules/core/__integration__/admin/TC-ADMIN-006.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-007.spec.js +0 -36
- package/dist/modules/core/__integration__/admin/TC-ADMIN-007.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-008.spec.js +0 -113
- package/dist/modules/core/__integration__/admin/TC-ADMIN-008.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-009.spec.js +0 -25
- package/dist/modules/core/__integration__/admin/TC-ADMIN-009.spec.js.map +0 -7
- package/dist/modules/core/__integration__/admin/TC-ADMIN-010.spec.js +0 -35
- package/dist/modules/core/__integration__/admin/TC-ADMIN-010.spec.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/api.js +0 -64
- package/dist/modules/core/__integration__/helpers/api.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/auth.js +0 -98
- package/dist/modules/core/__integration__/helpers/auth.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/authUi.js +0 -31
- package/dist/modules/core/__integration__/helpers/authUi.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/catalogFixtures.js +0 -49
- package/dist/modules/core/__integration__/helpers/catalogFixtures.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/crmFixtures.js +0 -73
- package/dist/modules/core/__integration__/helpers/crmFixtures.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/salesFixtures.js +0 -63
- package/dist/modules/core/__integration__/helpers/salesFixtures.js.map +0 -7
- package/dist/modules/core/__integration__/helpers/salesUi.js +0 -464
- package/dist/modules/core/__integration__/helpers/salesUi.js.map +0 -7
- package/dist/modules/core/__integration__/integration/TC-INT-001.spec.js +0 -26
- package/dist/modules/core/__integration__/integration/TC-INT-001.spec.js.map +0 -7
- package/dist/modules/core/__integration__/integration/TC-INT-002.spec.js +0 -60
- package/dist/modules/core/__integration__/integration/TC-INT-002.spec.js.map +0 -7
- package/dist/modules/core/__integration__/integration/TC-INT-003.spec.js +0 -36
- package/dist/modules/core/__integration__/integration/TC-INT-003.spec.js.map +0 -7
- package/dist/modules/core/__integration__/integration/TC-INT-004.spec.js +0 -74
- package/dist/modules/core/__integration__/integration/TC-INT-004.spec.js.map +0 -7
- package/dist/modules/core/__integration__/integration/TC-INT-005.spec.js +0 -21
- package/dist/modules/core/__integration__/integration/TC-INT-005.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-001.spec.js +0 -32
- package/dist/modules/customers/__integration__/TC-CRM-001.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-002.spec.js +0 -35
- package/dist/modules/customers/__integration__/TC-CRM-002.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-003.spec.js +0 -40
- package/dist/modules/customers/__integration__/TC-CRM-003.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-004.spec.js +0 -40
- package/dist/modules/customers/__integration__/TC-CRM-004.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-005.spec.js +0 -37
- package/dist/modules/customers/__integration__/TC-CRM-005.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-006.spec.js +0 -42
- package/dist/modules/customers/__integration__/TC-CRM-006.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-007.spec.js +0 -44
- package/dist/modules/customers/__integration__/TC-CRM-007.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-008.spec.js +0 -50
- package/dist/modules/customers/__integration__/TC-CRM-008.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-009.spec.js +0 -33
- package/dist/modules/customers/__integration__/TC-CRM-009.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-010.spec.js +0 -39
- package/dist/modules/customers/__integration__/TC-CRM-010.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-011.spec.js +0 -37
- package/dist/modules/customers/__integration__/TC-CRM-011.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-012.spec.js +0 -38
- package/dist/modules/customers/__integration__/TC-CRM-012.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-013.spec.js +0 -43
- package/dist/modules/customers/__integration__/TC-CRM-013.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-014.spec.js +0 -23
- package/dist/modules/customers/__integration__/TC-CRM-014.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-015.spec.js +0 -63
- package/dist/modules/customers/__integration__/TC-CRM-015.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-016.spec.js +0 -46
- package/dist/modules/customers/__integration__/TC-CRM-016.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-017.spec.js +0 -29
- package/dist/modules/customers/__integration__/TC-CRM-017.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-018.spec.js +0 -52
- package/dist/modules/customers/__integration__/TC-CRM-018.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-019.spec.js +0 -37
- package/dist/modules/customers/__integration__/TC-CRM-019.spec.js.map +0 -7
- package/dist/modules/customers/__integration__/TC-CRM-020.spec.js +0 -65
- package/dist/modules/customers/__integration__/TC-CRM-020.spec.js.map +0 -7
- package/dist/modules/progress/__integration__/TC-PROG-001.spec.js +0 -51
- package/dist/modules/progress/__integration__/TC-PROG-001.spec.js.map +0 -7
- package/dist/modules/resources/__integration__/TC-INT-007.spec.js +0 -88
- package/dist/modules/resources/__integration__/TC-INT-007.spec.js.map +0 -7
- package/dist/modules/resources/__integration__/helpers/resourcesFixtures.js +0 -45
- package/dist/modules/resources/__integration__/helpers/resourcesFixtures.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-001.spec.js +0 -20
- package/dist/modules/sales/__integration__/TC-SALES-001.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-002.spec.js +0 -31
- package/dist/modules/sales/__integration__/TC-SALES-002.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-003.spec.js +0 -13
- package/dist/modules/sales/__integration__/TC-SALES-003.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-004.spec.js +0 -14
- package/dist/modules/sales/__integration__/TC-SALES-004.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-005.spec.js +0 -15
- package/dist/modules/sales/__integration__/TC-SALES-005.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-006.spec.js +0 -20
- package/dist/modules/sales/__integration__/TC-SALES-006.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-007.spec.js +0 -19
- package/dist/modules/sales/__integration__/TC-SALES-007.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-008.spec.js +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-008.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-009.spec.js +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-009.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-010.spec.js +0 -16
- package/dist/modules/sales/__integration__/TC-SALES-010.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-011.spec.js +0 -20
- package/dist/modules/sales/__integration__/TC-SALES-011.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-012.spec.js +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-012.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-013.spec.js +0 -66
- package/dist/modules/sales/__integration__/TC-SALES-013.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-014.spec.js +0 -13
- package/dist/modules/sales/__integration__/TC-SALES-014.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-015.spec.js +0 -13
- package/dist/modules/sales/__integration__/TC-SALES-015.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-016.spec.js +0 -13
- package/dist/modules/sales/__integration__/TC-SALES-016.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-017.spec.js +0 -44
- package/dist/modules/sales/__integration__/TC-SALES-017.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-018.spec.js +0 -18
- package/dist/modules/sales/__integration__/TC-SALES-018.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-019.spec.js +0 -16
- package/dist/modules/sales/__integration__/TC-SALES-019.spec.js.map +0 -7
- package/dist/modules/sales/__integration__/TC-SALES-020.spec.js +0 -75
- package/dist/modules/sales/__integration__/TC-SALES-020.spec.js.map +0 -7
- package/dist/modules/staff/__integration__/TC-INT-006.spec.js +0 -64
- package/dist/modules/staff/__integration__/TC-INT-006.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-001.spec.js +0 -48
- package/dist/modules/translations/__integration__/TC-TRANS-001.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-002.spec.js +0 -94
- package/dist/modules/translations/__integration__/TC-TRANS-002.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-003.spec.js +0 -61
- package/dist/modules/translations/__integration__/TC-TRANS-003.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-004.spec.js +0 -52
- package/dist/modules/translations/__integration__/TC-TRANS-004.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-005.spec.js +0 -106
- package/dist/modules/translations/__integration__/TC-TRANS-005.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-006.spec.js +0 -94
- package/dist/modules/translations/__integration__/TC-TRANS-006.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-007.spec.js +0 -62
- package/dist/modules/translations/__integration__/TC-TRANS-007.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/TC-TRANS-008.spec.js +0 -168
- package/dist/modules/translations/__integration__/TC-TRANS-008.spec.js.map +0 -7
- package/dist/modules/translations/__integration__/helpers/translationFixtures.js +0 -63
- package/dist/modules/translations/__integration__/helpers/translationFixtures.js.map +0 -7
- package/dist/modules/workflows/__integration__/TC-WF-001.spec.js +0 -73
- package/dist/modules/workflows/__integration__/TC-WF-001.spec.js.map +0 -7
- package/src/__tests__/module-decoupling.test.ts +0 -356
- package/src/modules/api_keys/api/__tests__/keys.route.test.ts +0 -244
- package/src/modules/attachments/api/__tests__/attachments.api.test.ts +0 -240
- package/src/modules/attachments/components/__tests__/AttachmentContentPreview.test.tsx +0 -45
- package/src/modules/attachments/data/__tests__/entities-ocr.test.ts +0 -15
- package/src/modules/attachments/lib/__tests__/ocr-config.test.ts +0 -27
- package/src/modules/attachments/lib/__tests__/textExtraction.test.ts +0 -64
- package/src/modules/audit_logs/api/__tests__/access.route.test.ts +0 -118
- package/src/modules/audit_logs/api/__tests__/redo.route.test.ts +0 -131
- package/src/modules/audit_logs/api/__tests__/undo.route.test.ts +0 -103
- package/src/modules/audit_logs/services/__tests__/actionLogService.test.ts +0 -26
- package/src/modules/auth/__integration__/TC-AUTH-001.spec.ts +0 -13
- package/src/modules/auth/__integration__/TC-AUTH-002.spec.ts +0 -30
- package/src/modules/auth/__integration__/TC-AUTH-003.spec.ts +0 -28
- package/src/modules/auth/__integration__/TC-AUTH-004.spec.ts +0 -21
- package/src/modules/auth/__integration__/TC-AUTH-005.spec.ts +0 -17
- package/src/modules/auth/__integration__/TC-AUTH-006.spec.ts +0 -17
- package/src/modules/auth/__integration__/TC-AUTH-007.spec.ts +0 -19
- package/src/modules/auth/__integration__/TC-AUTH-008.spec.ts +0 -31
- package/src/modules/auth/__integration__/TC-AUTH-009.spec.ts +0 -22
- package/src/modules/auth/__integration__/TC-AUTH-010.spec.ts +0 -39
- package/src/modules/auth/__integration__/TC-AUTH-011.spec.ts +0 -35
- package/src/modules/auth/__integration__/TC-AUTH-012.spec.ts +0 -36
- package/src/modules/auth/__integration__/TC-AUTH-013.spec.ts +0 -48
- package/src/modules/auth/__integration__/TC-AUTH-014.spec.ts +0 -31
- package/src/modules/auth/__integration__/TC-AUTH-015.spec.ts +0 -28
- package/src/modules/auth/__integration__/TC-AUTH-016.spec.ts +0 -109
- package/src/modules/auth/__tests__/cli-rotate-encryption.test.ts +0 -97
- package/src/modules/auth/__tests__/cli-setup-acl.test.ts +0 -148
- package/src/modules/auth/api/__tests__/feature-check.test.ts +0 -65
- package/src/modules/auth/api/__tests__/login.test.ts +0 -47
- package/src/modules/auth/commands/__tests__/roles.custom-fields.test.ts +0 -126
- package/src/modules/auth/commands/__tests__/users.custom-fields.test.ts +0 -147
- package/src/modules/auth/lib/__tests__/rateLimitCheck.test.ts +0 -224
- package/src/modules/auth/services/__tests__/authService.test.ts +0 -32
- package/src/modules/auth/services/__tests__/rbacService.test.ts +0 -814
- package/src/modules/business_rules/api/__tests__/execute.route.test.ts +0 -311
- package/src/modules/business_rules/api/__tests__/logs-detail.route.test.ts +0 -181
- package/src/modules/business_rules/api/__tests__/logs.route.test.ts +0 -261
- package/src/modules/business_rules/api/__tests__/rules-detail.route.test.ts +0 -115
- package/src/modules/business_rules/api/__tests__/rules.route.test.ts +0 -746
- package/src/modules/business_rules/api/__tests__/sets-detail.route.test.ts +0 -169
- package/src/modules/business_rules/api/__tests__/sets-members.route.test.ts +0 -367
- package/src/modules/business_rules/api/__tests__/sets.route.test.ts +0 -361
- package/src/modules/business_rules/api/__tests__/test-helpers.ts +0 -42
- package/src/modules/business_rules/components/utils/__tests__/formHelpers.test.ts +0 -69
- package/src/modules/business_rules/data/__tests__/validators.test.ts +0 -637
- package/src/modules/business_rules/lib/__tests__/action-executor.test.ts +0 -728
- package/src/modules/business_rules/lib/__tests__/expression-evaluator.test.ts +0 -592
- package/src/modules/business_rules/lib/__tests__/rule-engine.test.ts +0 -805
- package/src/modules/business_rules/lib/__tests__/rule-evaluator.test.ts +0 -436
- package/src/modules/catalog/__integration__/TC-CAT-001.spec.ts +0 -32
- package/src/modules/catalog/__integration__/TC-CAT-002.spec.ts +0 -19
- package/src/modules/catalog/__integration__/TC-CAT-003.spec.ts +0 -39
- package/src/modules/catalog/__integration__/TC-CAT-004.spec.ts +0 -41
- package/src/modules/catalog/__integration__/TC-CAT-005.spec.ts +0 -37
- package/src/modules/catalog/__integration__/TC-CAT-006.spec.ts +0 -40
- package/src/modules/catalog/__integration__/TC-CAT-007.spec.ts +0 -37
- package/src/modules/catalog/__integration__/TC-CAT-008.spec.ts +0 -76
- package/src/modules/catalog/__integration__/TC-CAT-009.spec.ts +0 -39
- package/src/modules/catalog/__integration__/TC-CAT-010.spec.ts +0 -36
- package/src/modules/catalog/__integration__/TC-CAT-011.spec.ts +0 -44
- package/src/modules/catalog/__integration__/TC-CAT-012.spec.ts +0 -35
- package/src/modules/catalog/api/__tests__/offers.route.test.ts +0 -161
- package/src/modules/catalog/api/__tests__/prices.route.test.ts +0 -39
- package/src/modules/catalog/api/__tests__/products.route.test.ts +0 -91
- package/src/modules/catalog/api/__tests__/utils.test.ts +0 -36
- package/src/modules/catalog/api/__tests__/variants.route.test.ts +0 -44
- package/src/modules/catalog/backend/catalog/products/__tests__/ProductsDataTable.test.tsx +0 -172
- package/src/modules/catalog/commands/__tests__/products.delete.test.ts +0 -146
- package/src/modules/catalog/commands/__tests__/products.update.test.ts +0 -142
- package/src/modules/catalog/commands/__tests__/registration.test.ts +0 -54
- package/src/modules/catalog/commands/__tests__/shared.test.ts +0 -129
- package/src/modules/catalog/components/__tests__/catalogComponentsRender.test.tsx +0 -373
- package/src/modules/catalog/components/products/__tests__/ProductImageCell.test.tsx +0 -51
- package/src/modules/catalog/components/products/__tests__/productForm.test.ts +0 -32
- package/src/modules/catalog/lib/__tests__/pricing.test.ts +0 -150
- package/src/modules/catalog/services/__tests__/catalogPricingService.test.ts +0 -21
- package/src/modules/configs/components/__tests__/CachePanel.test.tsx +0 -134
- package/src/modules/configs/components/__tests__/SystemStatusPanel.test.tsx +0 -93
- package/src/modules/configs/lib/__tests__/system-status.test.ts +0 -55
- package/src/modules/configs/lib/__tests__/upgrade-actions.test.ts +0 -135
- package/src/modules/core/__integration__/admin/TC-ADMIN-001.spec.ts +0 -70
- package/src/modules/core/__integration__/admin/TC-ADMIN-002.spec.ts +0 -83
- package/src/modules/core/__integration__/admin/TC-ADMIN-003.spec.ts +0 -50
- package/src/modules/core/__integration__/admin/TC-ADMIN-004.spec.ts +0 -77
- package/src/modules/core/__integration__/admin/TC-ADMIN-005.spec.ts +0 -49
- package/src/modules/core/__integration__/admin/TC-ADMIN-006.spec.ts +0 -59
- package/src/modules/core/__integration__/admin/TC-ADMIN-007.spec.ts +0 -68
- package/src/modules/core/__integration__/admin/TC-ADMIN-008.spec.ts +0 -127
- package/src/modules/core/__integration__/admin/TC-ADMIN-009.spec.ts +0 -48
- package/src/modules/core/__integration__/admin/TC-ADMIN-010.spec.ts +0 -57
- package/src/modules/core/__integration__/helpers/api.ts +0 -84
- package/src/modules/core/__integration__/helpers/auth.ts +0 -110
- package/src/modules/core/__integration__/helpers/authUi.ts +0 -33
- package/src/modules/core/__integration__/helpers/catalogFixtures.ts +0 -73
- package/src/modules/core/__integration__/helpers/crmFixtures.ts +0 -101
- package/src/modules/core/__integration__/helpers/salesFixtures.ts +0 -89
- package/src/modules/core/__integration__/helpers/salesUi.ts +0 -528
- package/src/modules/core/__integration__/integration/TC-INT-001.spec.ts +0 -34
- package/src/modules/core/__integration__/integration/TC-INT-002.spec.ts +0 -74
- package/src/modules/core/__integration__/integration/TC-INT-003.spec.ts +0 -43
- package/src/modules/core/__integration__/integration/TC-INT-004.spec.ts +0 -82
- package/src/modules/core/__integration__/integration/TC-INT-005.spec.ts +0 -29
- package/src/modules/currencies/backend/exchange-rates/__tests__/formatDateTimeLocal.test.ts +0 -78
- package/src/modules/currencies/data/__tests__/validators.test.ts +0 -100
- package/src/modules/currencies/services/__tests__/exchangeRateService.test.ts +0 -666
- package/src/modules/currencies/services/__tests__/rateFetchingService.basic.test.ts +0 -398
- package/src/modules/currencies/services/__tests__/rateFetchingService.errors.test.ts +0 -296
- package/src/modules/currencies/services/__tests__/rateFetchingService.providers.test.ts +0 -350
- package/src/modules/currencies/services/__tests__/rateFetchingService.setup.ts +0 -188
- package/src/modules/customers/__integration__/TC-CRM-001.spec.ts +0 -42
- package/src/modules/customers/__integration__/TC-CRM-002.spec.ts +0 -47
- package/src/modules/customers/__integration__/TC-CRM-003.spec.ts +0 -55
- package/src/modules/customers/__integration__/TC-CRM-004.spec.ts +0 -57
- package/src/modules/customers/__integration__/TC-CRM-005.spec.ts +0 -50
- package/src/modules/customers/__integration__/TC-CRM-006.spec.ts +0 -60
- package/src/modules/customers/__integration__/TC-CRM-007.spec.ts +0 -57
- package/src/modules/customers/__integration__/TC-CRM-008.spec.ts +0 -62
- package/src/modules/customers/__integration__/TC-CRM-009.spec.ts +0 -46
- package/src/modules/customers/__integration__/TC-CRM-010.spec.ts +0 -49
- package/src/modules/customers/__integration__/TC-CRM-011.spec.ts +0 -47
- package/src/modules/customers/__integration__/TC-CRM-012.spec.ts +0 -49
- package/src/modules/customers/__integration__/TC-CRM-013.spec.ts +0 -61
- package/src/modules/customers/__integration__/TC-CRM-014.spec.ts +0 -31
- package/src/modules/customers/__integration__/TC-CRM-015.spec.ts +0 -89
- package/src/modules/customers/__integration__/TC-CRM-016.spec.ts +0 -55
- package/src/modules/customers/__integration__/TC-CRM-017.spec.ts +0 -37
- package/src/modules/customers/__integration__/TC-CRM-018.spec.ts +0 -62
- package/src/modules/customers/__integration__/TC-CRM-019.spec.ts +0 -44
- package/src/modules/customers/__integration__/TC-CRM-020.spec.ts +0 -73
- package/src/modules/customers/api/__tests__/utils.test.ts +0 -61
- package/src/modules/customers/api/dashboard/widgets/new-deals/__tests__/route.test.ts +0 -54
- package/src/modules/customers/commands/__tests__/shared.test.ts +0 -263
- package/src/modules/customers/commands/__tests__/undo.custom-fields.test.ts +0 -1184
- package/src/modules/customers/components/detail/__tests__/ActivityForm.validation.test.ts +0 -37
- package/src/modules/customers/components/detail/__tests__/DealForm.validation.test.ts +0 -45
- package/src/modules/customers/components/detail/__tests__/InlineEditors.test.tsx +0 -166
- package/src/modules/customers/components/detail/__tests__/TaskForm.submit.test.ts +0 -21
- package/src/modules/customers/components/detail/hooks/__tests__/useCustomerDictionary.test.ts +0 -97
- package/src/modules/customers/lib/__tests__/customFieldRouting.test.ts +0 -107
- package/src/modules/customers/utils/__tests__/addressFormat.test.ts +0 -105
- package/src/modules/customers/utils/__tests__/phoneDuplicates.test.ts +0 -98
- package/src/modules/dashboards/__tests__/widgets.test.ts +0 -70
- package/src/modules/dashboards/lib/__tests__/aggregations.test.ts +0 -328
- package/src/modules/dashboards/lib/__tests__/formatters.test.ts +0 -128
- package/src/modules/directory/backend/directory/organizations/__tests__/create-submit.test.ts +0 -46
- package/src/modules/directory/backend/directory/organizations/__tests__/edit-submit.test.ts +0 -49
- package/src/modules/directory/components/__tests__/OrganizationSelect.test.tsx +0 -71
- package/src/modules/directory/components/__tests__/TenantSelect.test.tsx +0 -75
- package/src/modules/entities/__tests__/cli-decrypt-database.test.ts +0 -534
- package/src/modules/entities/__tests__/cli-rotate-encryption.test.ts +0 -123
- package/src/modules/entities/api/__tests__/encryption.api.test.ts +0 -57
- package/src/modules/entities/api/__tests__/records.get.custom-entity.test.ts +0 -43
- package/src/modules/entities/api/__tests__/records.validation.test.ts +0 -53
- package/src/modules/entities/backend/entities/user/__tests__/create-entity-submit.test.ts +0 -47
- package/src/modules/entities/backend/entities/user/__tests__/records-submit.test.ts +0 -104
- package/src/modules/feature_toggles/commands/__tests__/global.test.ts +0 -325
- package/src/modules/feature_toggles/commands/__tests__/overrides.test.ts +0 -186
- package/src/modules/feature_toggles/lib/__tests__/feature-flag-check.test.ts +0 -365
- package/src/modules/feature_toggles/lib/__tests__/queries.test.ts +0 -130
- package/src/modules/inbox_ops/api/emails/[id]/reprocess/__tests__/route.test.ts +0 -194
- package/src/modules/inbox_ops/api/proposals/[id]/__tests__/route.test.ts +0 -124
- package/src/modules/inbox_ops/api/proposals/[id]/accept-all/__tests__/route.test.ts +0 -154
- package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/__tests__/route.test.ts +0 -200
- package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/accept/__tests__/route.test.ts +0 -261
- package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/reject/__tests__/route.test.ts +0 -201
- package/src/modules/inbox_ops/api/proposals/[id]/reject/__tests__/route.test.ts +0 -123
- package/src/modules/inbox_ops/api/proposals/[id]/replies/[replyId]/send/__tests__/route.test.ts +0 -232
- package/src/modules/inbox_ops/api/proposals/[id]/translate/__tests__/route.test.ts +0 -173
- package/src/modules/inbox_ops/api/proposals/__tests__/route.test.ts +0 -185
- package/src/modules/inbox_ops/api/webhook/__tests__/inbound.test.ts +0 -317
- package/src/modules/inbox_ops/data/__tests__/validators.test.ts +0 -463
- package/src/modules/inbox_ops/lib/__tests__/catalogLookup.test.ts +0 -143
- package/src/modules/inbox_ops/lib/__tests__/contactMatcher.test.ts +0 -158
- package/src/modules/inbox_ops/lib/__tests__/emailParser.test.ts +0 -191
- package/src/modules/inbox_ops/lib/__tests__/executionEngine.test.ts +0 -1419
- package/src/modules/inbox_ops/lib/__tests__/extractionPrompt.test.ts +0 -151
- package/src/modules/inbox_ops/lib/__tests__/priceValidator.test.ts +0 -259
- package/src/modules/inbox_ops/lib/__tests__/translationProvider.test.ts +0 -99
- package/src/modules/inbox_ops/subscribers/__tests__/extractionWorker.test.ts +0 -803
- package/src/modules/notifications/__tests__/deliver-notification.test.ts +0 -285
- package/src/modules/notifications/__tests__/deliveryStrategies.test.ts +0 -19
- package/src/modules/notifications/__tests__/notificationService.test.ts +0 -248
- package/src/modules/planner/__tests__/availabilityMerge.test.ts +0 -99
- package/src/modules/planner/__tests__/plannerAvailabilityService.test.ts +0 -89
- package/src/modules/planner/data/__tests__/validators.test.ts +0 -78
- package/src/modules/progress/__integration__/TC-PROG-001.spec.ts +0 -67
- package/src/modules/progress/__tests__/progressService.test.ts +0 -377
- package/src/modules/query_index/__tests__/hybrid-engine.test.ts +0 -365
- package/src/modules/query_index/__tests__/indexer.test.ts +0 -175
- package/src/modules/resources/__integration__/TC-INT-007.spec.ts +0 -110
- package/src/modules/resources/__integration__/helpers/resourcesFixtures.ts +0 -50
- package/src/modules/resources/data/__tests__/validators.test.ts +0 -65
- package/src/modules/sales/__integration__/TC-SALES-001.spec.ts +0 -26
- package/src/modules/sales/__integration__/TC-SALES-002.spec.ts +0 -38
- package/src/modules/sales/__integration__/TC-SALES-003.spec.ts +0 -18
- package/src/modules/sales/__integration__/TC-SALES-004.spec.ts +0 -19
- package/src/modules/sales/__integration__/TC-SALES-005.spec.ts +0 -21
- package/src/modules/sales/__integration__/TC-SALES-006.spec.ts +0 -26
- package/src/modules/sales/__integration__/TC-SALES-007.spec.ts +0 -23
- package/src/modules/sales/__integration__/TC-SALES-008.spec.ts +0 -11
- package/src/modules/sales/__integration__/TC-SALES-009.spec.ts +0 -12
- package/src/modules/sales/__integration__/TC-SALES-010.spec.ts +0 -20
- package/src/modules/sales/__integration__/TC-SALES-011.spec.ts +0 -26
- package/src/modules/sales/__integration__/TC-SALES-012.spec.ts +0 -12
- package/src/modules/sales/__integration__/TC-SALES-013.spec.ts +0 -73
- package/src/modules/sales/__integration__/TC-SALES-014.spec.ts +0 -17
- package/src/modules/sales/__integration__/TC-SALES-015.spec.ts +0 -17
- package/src/modules/sales/__integration__/TC-SALES-016.spec.ts +0 -17
- package/src/modules/sales/__integration__/TC-SALES-017.spec.ts +0 -60
- package/src/modules/sales/__integration__/TC-SALES-018.spec.ts +0 -25
- package/src/modules/sales/__integration__/TC-SALES-019.spec.ts +0 -22
- package/src/modules/sales/__integration__/TC-SALES-020.spec.ts +0 -107
- package/src/modules/sales/api/__tests__/channels.route.test.ts +0 -50
- package/src/modules/sales/api/__tests__/document-history.test.ts +0 -146
- package/src/modules/sales/api/__tests__/documents.factory.test.ts +0 -98
- package/src/modules/sales/api/__tests__/documents.routes.test.ts +0 -149
- package/src/modules/sales/api/__tests__/quotes.acceptance.test.ts +0 -209
- package/src/modules/sales/api/__tests__/timeline.test.tsx +0 -165
- package/src/modules/sales/api/dashboard/widgets/new-orders/__tests__/route.test.ts +0 -112
- package/src/modules/sales/api/dashboard/widgets/new-quotes/__tests__/route.test.ts +0 -116
- package/src/modules/sales/commands/__tests__/documents.cache.test.ts +0 -126
- package/src/modules/sales/commands/__tests__/documents.undo.test.ts +0 -170
- package/src/modules/sales/commands/__tests__/registration.test.ts +0 -141
- package/src/modules/sales/components/__tests__/salesComponentsRender.test.tsx +0 -456
- package/src/modules/sales/lib/__tests__/calculations.test.ts +0 -210
- package/src/modules/sales/services/__tests__/salesCalculationService.test.ts +0 -181
- package/src/modules/sales/services/__tests__/taxCalculationService.test.ts +0 -79
- package/src/modules/sales/widgets/dashboard/new-orders/__tests__/config.test.ts +0 -47
- package/src/modules/sales/widgets/dashboard/new-quotes/__tests__/config.test.ts +0 -47
- package/src/modules/staff/__integration__/TC-INT-006.spec.ts +0 -71
- package/src/modules/staff/data/__tests__/validators.test.ts +0 -60
- package/src/modules/translations/__integration__/TC-TRANS-001.spec.ts +0 -57
- package/src/modules/translations/__integration__/TC-TRANS-002.spec.ts +0 -114
- package/src/modules/translations/__integration__/TC-TRANS-003.spec.ts +0 -71
- package/src/modules/translations/__integration__/TC-TRANS-004.spec.ts +0 -66
- package/src/modules/translations/__integration__/TC-TRANS-005.spec.ts +0 -135
- package/src/modules/translations/__integration__/TC-TRANS-006.spec.ts +0 -113
- package/src/modules/translations/__integration__/TC-TRANS-007.spec.ts +0 -80
- package/src/modules/translations/__integration__/TC-TRANS-008.spec.ts +0 -209
- package/src/modules/translations/__integration__/helpers/translationFixtures.ts +0 -95
- package/src/modules/translations/api/__tests__/locales.test.ts +0 -67
- package/src/modules/translations/data/__tests__/validators.test.ts +0 -143
- package/src/modules/translations/lib/__tests__/extract-record-id.test.ts +0 -75
- package/src/modules/translations/lib/__tests__/helpers.test.ts +0 -215
- package/src/modules/translations/lib/__tests__/locale.test.ts +0 -115
- package/src/modules/translations/lib/__tests__/resolve-field-list.test.ts +0 -176
- package/src/modules/translations/lib/__tests__/translatable-fields.test.ts +0 -79
- package/src/modules/translations/widgets/__tests__/injection-table.test.ts +0 -83
- package/src/modules/workflows/__integration__/TC-WF-001.spec.ts +0 -114
- package/src/modules/workflows/api/__tests__/definitions.route.test.ts +0 -762
- package/src/modules/workflows/api/__tests__/instances.route.test.ts +0 -869
- package/src/modules/workflows/data/__tests__/validators.test.ts +0 -707
- package/src/modules/workflows/lib/__tests__/activity-executor.test.ts +0 -1230
- package/src/modules/workflows/lib/__tests__/call-api.test.ts +0 -421
- package/src/modules/workflows/lib/__tests__/compensation.test.ts +0 -713
- package/src/modules/workflows/lib/__tests__/event-logger.test.ts +0 -615
- package/src/modules/workflows/lib/__tests__/integration.test.ts +0 -693
- package/src/modules/workflows/lib/__tests__/signals.test.ts +0 -566
- package/src/modules/workflows/lib/__tests__/step-handler.test.ts +0 -670
- package/src/modules/workflows/lib/__tests__/sub-workflow.test.ts +0 -934
- package/src/modules/workflows/lib/__tests__/transition-handler.test.ts +0 -925
- package/src/modules/workflows/lib/__tests__/workflow-executor.test.ts +0 -684
|
@@ -1,746 +0,0 @@
|
|
|
1
|
-
/** @jest-environment node */
|
|
2
|
-
|
|
3
|
-
import { describe, test, expect, beforeEach, jest } from '@jest/globals'
|
|
4
|
-
import { createAuthMock, createMockContainer, createMockEntityManager } from './test-helpers'
|
|
5
|
-
|
|
6
|
-
const mockGetAuthFromRequest = createAuthMock()
|
|
7
|
-
const mockEm = createMockEntityManager()
|
|
8
|
-
const mockContainer = createMockContainer(mockEm)
|
|
9
|
-
|
|
10
|
-
jest.mock('@open-mercato/shared/lib/di/container', () => ({
|
|
11
|
-
createRequestContainer: jest.fn(async () => mockContainer),
|
|
12
|
-
}))
|
|
13
|
-
|
|
14
|
-
jest.mock('@open-mercato/shared/lib/auth/server', () => ({
|
|
15
|
-
getAuthFromRequest: jest.fn((request: Request) => mockGetAuthFromRequest(request)),
|
|
16
|
-
}))
|
|
17
|
-
|
|
18
|
-
const enStrings: Record<string, string> = require('../../i18n/en.json')
|
|
19
|
-
const mockTranslator = (key: string, fallbackOrParams?: string | Record<string, any>, params?: Record<string, any>) => {
|
|
20
|
-
const resolvedParams = typeof fallbackOrParams === 'object' ? fallbackOrParams : params
|
|
21
|
-
let text = enStrings[key] || (typeof fallbackOrParams === 'string' ? fallbackOrParams : key)
|
|
22
|
-
if (resolvedParams) {
|
|
23
|
-
for (const [k, v] of Object.entries(resolvedParams)) {
|
|
24
|
-
text = text.replace(new RegExp(`\\{\\{${k}\\}\\}`, 'g'), String(v))
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return text
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
jest.mock('@open-mercato/shared/lib/i18n/server', () => ({
|
|
31
|
-
resolveTranslations: jest.fn(async () => ({
|
|
32
|
-
locale: 'en',
|
|
33
|
-
dict: enStrings,
|
|
34
|
-
t: mockTranslator,
|
|
35
|
-
translate: mockTranslator,
|
|
36
|
-
})),
|
|
37
|
-
}))
|
|
38
|
-
|
|
39
|
-
type RouteModule = typeof import('../rules/route')
|
|
40
|
-
let GET: RouteModule['GET']
|
|
41
|
-
let POST: RouteModule['POST']
|
|
42
|
-
let PUT: RouteModule['PUT']
|
|
43
|
-
let DELETE: RouteModule['DELETE']
|
|
44
|
-
let metadata: RouteModule['metadata']
|
|
45
|
-
|
|
46
|
-
beforeAll(async () => {
|
|
47
|
-
const routeModule = await import('../rules/route')
|
|
48
|
-
GET = routeModule.GET
|
|
49
|
-
POST = routeModule.POST
|
|
50
|
-
PUT = routeModule.PUT
|
|
51
|
-
DELETE = routeModule.DELETE
|
|
52
|
-
metadata = routeModule.metadata
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
describe('Business Rules API - /api/business_rules/rules', () => {
|
|
56
|
-
const validTenantId = '123e4567-e89b-12d3-a456-426614174000'
|
|
57
|
-
const validOrgId = '223e4567-e89b-12d3-a456-426614174000'
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
jest.clearAllMocks()
|
|
61
|
-
mockGetAuthFromRequest.mockResolvedValue({
|
|
62
|
-
sub: 'user-1',
|
|
63
|
-
email: 'user@example.com',
|
|
64
|
-
tenantId: validTenantId,
|
|
65
|
-
orgId: validOrgId,
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
describe('Metadata', () => {
|
|
70
|
-
test('should have correct RBAC requirements', () => {
|
|
71
|
-
expect(metadata.GET).toEqual({ requireAuth: true, requireFeatures: ['business_rules.view'] })
|
|
72
|
-
expect(metadata.POST).toEqual({ requireAuth: true, requireFeatures: ['business_rules.manage'] })
|
|
73
|
-
expect(metadata.PUT).toEqual({ requireAuth: true, requireFeatures: ['business_rules.manage'] })
|
|
74
|
-
expect(metadata.DELETE).toEqual({ requireAuth: true, requireFeatures: ['business_rules.manage'] })
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
describe('GET - List rules', () => {
|
|
79
|
-
test('should return 401 when not authenticated', async () => {
|
|
80
|
-
mockGetAuthFromRequest.mockResolvedValue(null)
|
|
81
|
-
|
|
82
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules')
|
|
83
|
-
const response = await GET(request)
|
|
84
|
-
|
|
85
|
-
expect(response.status).toBe(401)
|
|
86
|
-
const body = await response.json()
|
|
87
|
-
expect(body.error).toBe('Unauthorized')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test('should return paginated list of rules', async () => {
|
|
91
|
-
const mockRules = [
|
|
92
|
-
{
|
|
93
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
94
|
-
ruleId: 'RULE-001',
|
|
95
|
-
ruleName: 'Test Rule 1',
|
|
96
|
-
description: 'Description 1',
|
|
97
|
-
ruleType: 'GUARD',
|
|
98
|
-
ruleCategory: 'validation',
|
|
99
|
-
entityType: 'WorkOrder',
|
|
100
|
-
eventType: 'beforeSave',
|
|
101
|
-
enabled: true,
|
|
102
|
-
priority: 100,
|
|
103
|
-
version: 1,
|
|
104
|
-
effectiveFrom: new Date('2024-01-01'),
|
|
105
|
-
effectiveTo: null,
|
|
106
|
-
tenantId: 'tenant-123',
|
|
107
|
-
organizationId: 'org-456',
|
|
108
|
-
createdAt: new Date('2024-01-01'),
|
|
109
|
-
updatedAt: new Date('2024-01-01'),
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
mockEm.findAndCount.mockResolvedValue([mockRules, 1])
|
|
114
|
-
|
|
115
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?page=1&pageSize=50')
|
|
116
|
-
const response = await GET(request)
|
|
117
|
-
|
|
118
|
-
expect(response.status).toBe(200)
|
|
119
|
-
const body = await response.json()
|
|
120
|
-
expect(body.items).toHaveLength(1)
|
|
121
|
-
expect(body.total).toBe(1)
|
|
122
|
-
expect(body.totalPages).toBe(1)
|
|
123
|
-
expect(body.items[0].ruleId).toBe('RULE-001')
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test('should filter by enabled status', async () => {
|
|
127
|
-
mockEm.findAndCount.mockResolvedValue([[], 0])
|
|
128
|
-
|
|
129
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?enabled=true')
|
|
130
|
-
await GET(request)
|
|
131
|
-
|
|
132
|
-
expect(mockEm.findAndCount).toHaveBeenCalledWith(
|
|
133
|
-
expect.anything(),
|
|
134
|
-
expect.objectContaining({ enabled: true }),
|
|
135
|
-
expect.anything()
|
|
136
|
-
)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test('should filter by entityType', async () => {
|
|
140
|
-
mockEm.findAndCount.mockResolvedValue([[], 0])
|
|
141
|
-
|
|
142
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?entityType=WorkOrder')
|
|
143
|
-
await GET(request)
|
|
144
|
-
|
|
145
|
-
expect(mockEm.findAndCount).toHaveBeenCalledWith(
|
|
146
|
-
expect.anything(),
|
|
147
|
-
expect.objectContaining({ entityType: 'WorkOrder' }),
|
|
148
|
-
expect.anything()
|
|
149
|
-
)
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test('should search by rule name', async () => {
|
|
153
|
-
mockEm.findAndCount.mockResolvedValue([[], 0])
|
|
154
|
-
|
|
155
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?search=validation')
|
|
156
|
-
await GET(request)
|
|
157
|
-
|
|
158
|
-
expect(mockEm.findAndCount).toHaveBeenCalledWith(
|
|
159
|
-
expect.anything(),
|
|
160
|
-
expect.objectContaining({ ruleName: { $ilike: '%validation%' } }),
|
|
161
|
-
expect.anything()
|
|
162
|
-
)
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
describe('POST - Create rule', () => {
|
|
167
|
-
test('should return 401 when not authenticated', async () => {
|
|
168
|
-
mockGetAuthFromRequest.mockResolvedValue(null)
|
|
169
|
-
|
|
170
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
171
|
-
method: 'POST',
|
|
172
|
-
body: JSON.stringify({ ruleId: 'TEST-001', ruleName: 'Test' }),
|
|
173
|
-
})
|
|
174
|
-
const response = await POST(request)
|
|
175
|
-
|
|
176
|
-
expect(response.status).toBe(401)
|
|
177
|
-
const body = await response.json()
|
|
178
|
-
expect(body.error).toBe('Unauthorized')
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
test('should create a new rule', async () => {
|
|
182
|
-
const newRule = {
|
|
183
|
-
ruleId: 'RULE-NEW',
|
|
184
|
-
ruleName: 'New Rule',
|
|
185
|
-
ruleType: 'GUARD',
|
|
186
|
-
entityType: 'WorkOrder',
|
|
187
|
-
conditionExpression: { field: 'status', operator: '=', value: 'ACTIVE' },
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
mockEm.create.mockReturnValue({ id: '223e4567-e89b-12d3-a456-426614174002', ...newRule })
|
|
191
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
192
|
-
|
|
193
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
194
|
-
method: 'POST',
|
|
195
|
-
body: JSON.stringify(newRule),
|
|
196
|
-
})
|
|
197
|
-
const response = await POST(request)
|
|
198
|
-
|
|
199
|
-
expect(response.status).toBe(201)
|
|
200
|
-
const body = await response.json()
|
|
201
|
-
expect(body.id).toBe('223e4567-e89b-12d3-a456-426614174002')
|
|
202
|
-
expect(mockEm.create).toHaveBeenCalled()
|
|
203
|
-
expect(mockEm.persistAndFlush).toHaveBeenCalled()
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
test('should return 400 for invalid rule data', async () => {
|
|
207
|
-
const invalidRule = {
|
|
208
|
-
ruleId: '',
|
|
209
|
-
ruleName: 'Test',
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
213
|
-
method: 'POST',
|
|
214
|
-
body: JSON.stringify(invalidRule),
|
|
215
|
-
})
|
|
216
|
-
const response = await POST(request)
|
|
217
|
-
|
|
218
|
-
expect(response.status).toBe(400)
|
|
219
|
-
const body = await response.json()
|
|
220
|
-
expect(body.error).toContain('Validation failed')
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
test('should inject tenantId and organizationId from auth', async () => {
|
|
224
|
-
const newRule = {
|
|
225
|
-
ruleId: 'RULE-NEW',
|
|
226
|
-
ruleName: 'New Rule',
|
|
227
|
-
ruleType: 'GUARD',
|
|
228
|
-
entityType: 'WorkOrder',
|
|
229
|
-
conditionExpression: { field: 'status', operator: '=', value: 'ACTIVE' },
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
mockEm.create.mockReturnValue({ id: '223e4567-e89b-12d3-a456-426614174002', ...newRule })
|
|
233
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
234
|
-
|
|
235
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
236
|
-
method: 'POST',
|
|
237
|
-
body: JSON.stringify(newRule),
|
|
238
|
-
})
|
|
239
|
-
await POST(request)
|
|
240
|
-
|
|
241
|
-
expect(mockEm.create).toHaveBeenCalledWith(
|
|
242
|
-
expect.anything(),
|
|
243
|
-
expect.objectContaining({
|
|
244
|
-
tenantId: validTenantId,
|
|
245
|
-
organizationId: validOrgId,
|
|
246
|
-
createdBy: 'user-1',
|
|
247
|
-
})
|
|
248
|
-
)
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
describe('PUT - Update rule', () => {
|
|
253
|
-
test('should return 401 when not authenticated', async () => {
|
|
254
|
-
mockGetAuthFromRequest.mockResolvedValue(null)
|
|
255
|
-
|
|
256
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
257
|
-
method: 'PUT',
|
|
258
|
-
body: JSON.stringify({ id: 'rule-1', ruleName: 'Updated' }),
|
|
259
|
-
})
|
|
260
|
-
const response = await PUT(request)
|
|
261
|
-
|
|
262
|
-
expect(response.status).toBe(401)
|
|
263
|
-
const body = await response.json()
|
|
264
|
-
expect(body.error).toBe('Unauthorized')
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
test('should update an existing rule', async () => {
|
|
268
|
-
const existingRule = {
|
|
269
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
270
|
-
ruleId: 'RULE-001',
|
|
271
|
-
ruleName: 'Original Name',
|
|
272
|
-
ruleType: 'GUARD',
|
|
273
|
-
entityType: 'WorkOrder',
|
|
274
|
-
tenantId: validTenantId,
|
|
275
|
-
organizationId: validOrgId,
|
|
276
|
-
deletedAt: null,
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
mockEm.findOne.mockResolvedValue(existingRule)
|
|
280
|
-
mockEm.assign.mockImplementation((target: any, data: any) => Object.assign(target, data))
|
|
281
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
282
|
-
|
|
283
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
284
|
-
method: 'PUT',
|
|
285
|
-
body: JSON.stringify({
|
|
286
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
287
|
-
ruleName: 'Updated Name',
|
|
288
|
-
}),
|
|
289
|
-
})
|
|
290
|
-
const response = await PUT(request)
|
|
291
|
-
|
|
292
|
-
expect(response.status).toBe(200)
|
|
293
|
-
const body = await response.json()
|
|
294
|
-
expect(body.ok).toBe(true)
|
|
295
|
-
expect(mockEm.findOne).toHaveBeenCalledWith(
|
|
296
|
-
expect.anything(),
|
|
297
|
-
expect.objectContaining({
|
|
298
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
299
|
-
tenantId: validTenantId,
|
|
300
|
-
organizationId: validOrgId,
|
|
301
|
-
})
|
|
302
|
-
)
|
|
303
|
-
expect(mockEm.assign).toHaveBeenCalled()
|
|
304
|
-
expect(mockEm.persistAndFlush).toHaveBeenCalled()
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
test('should return 404 if rule not found', async () => {
|
|
308
|
-
mockEm.findOne.mockResolvedValue(null)
|
|
309
|
-
|
|
310
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
311
|
-
method: 'PUT',
|
|
312
|
-
body: JSON.stringify({
|
|
313
|
-
id: '999e4567-e89b-12d3-a456-999999999999',
|
|
314
|
-
ruleName: 'Updated',
|
|
315
|
-
}),
|
|
316
|
-
})
|
|
317
|
-
const response = await PUT(request)
|
|
318
|
-
|
|
319
|
-
expect(response.status).toBe(404)
|
|
320
|
-
const body = await response.json()
|
|
321
|
-
expect(body.error).toBe('Rule not found')
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
test('should return 400 if id is missing', async () => {
|
|
325
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
326
|
-
method: 'PUT',
|
|
327
|
-
body: JSON.stringify({
|
|
328
|
-
ruleName: 'Updated',
|
|
329
|
-
}),
|
|
330
|
-
})
|
|
331
|
-
const response = await PUT(request)
|
|
332
|
-
|
|
333
|
-
expect(response.status).toBe(400)
|
|
334
|
-
const body = await response.json()
|
|
335
|
-
expect(body.error).toBe('Rule id is required')
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
test('should toggle enabled state via PUT', async () => {
|
|
339
|
-
const existingRule = {
|
|
340
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
341
|
-
ruleId: 'RULE-001',
|
|
342
|
-
enabled: true,
|
|
343
|
-
tenantId: validTenantId,
|
|
344
|
-
organizationId: validOrgId,
|
|
345
|
-
deletedAt: null,
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
mockEm.findOne.mockResolvedValue(existingRule)
|
|
349
|
-
mockEm.assign.mockImplementation((target: any, data: any) => Object.assign(target, data))
|
|
350
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
351
|
-
|
|
352
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
353
|
-
method: 'PUT',
|
|
354
|
-
body: JSON.stringify({
|
|
355
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
356
|
-
enabled: false,
|
|
357
|
-
}),
|
|
358
|
-
})
|
|
359
|
-
const response = await PUT(request)
|
|
360
|
-
|
|
361
|
-
expect(response.status).toBe(200)
|
|
362
|
-
const body = await response.json()
|
|
363
|
-
expect(body.ok).toBe(true)
|
|
364
|
-
expect(existingRule.enabled).toBe(false)
|
|
365
|
-
expect(mockEm.persistAndFlush).toHaveBeenCalled()
|
|
366
|
-
})
|
|
367
|
-
})
|
|
368
|
-
|
|
369
|
-
describe('DELETE - Delete rule', () => {
|
|
370
|
-
test('should return 401 when not authenticated', async () => {
|
|
371
|
-
mockGetAuthFromRequest.mockResolvedValue(null)
|
|
372
|
-
|
|
373
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?id=rule-1', {
|
|
374
|
-
method: 'DELETE',
|
|
375
|
-
})
|
|
376
|
-
const response = await DELETE(request)
|
|
377
|
-
|
|
378
|
-
expect(response.status).toBe(401)
|
|
379
|
-
const body = await response.json()
|
|
380
|
-
expect(body.error).toBe('Unauthorized')
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
test('should soft delete a rule', async () => {
|
|
384
|
-
const existingRule = {
|
|
385
|
-
id: '123e4567-e89b-12d3-a456-426614174001',
|
|
386
|
-
ruleId: 'RULE-001',
|
|
387
|
-
tenantId: validTenantId,
|
|
388
|
-
organizationId: validOrgId,
|
|
389
|
-
deletedAt: null,
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
mockEm.findOne.mockResolvedValue(existingRule)
|
|
393
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
394
|
-
|
|
395
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?id=rule-1', {
|
|
396
|
-
method: 'DELETE',
|
|
397
|
-
})
|
|
398
|
-
const response = await DELETE(request)
|
|
399
|
-
|
|
400
|
-
expect(response.status).toBe(200)
|
|
401
|
-
const body = await response.json()
|
|
402
|
-
expect(body.ok).toBe(true)
|
|
403
|
-
expect(existingRule.deletedAt).toBeInstanceOf(Date)
|
|
404
|
-
expect(mockEm.persistAndFlush).toHaveBeenCalled()
|
|
405
|
-
})
|
|
406
|
-
|
|
407
|
-
test('should return 404 if rule not found', async () => {
|
|
408
|
-
mockEm.findOne.mockResolvedValue(null)
|
|
409
|
-
|
|
410
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules?id=nonexistent', {
|
|
411
|
-
method: 'DELETE',
|
|
412
|
-
})
|
|
413
|
-
const response = await DELETE(request)
|
|
414
|
-
|
|
415
|
-
expect(response.status).toBe(404)
|
|
416
|
-
const body = await response.json()
|
|
417
|
-
expect(body.error).toBe('Rule not found')
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
test('should return 400 if id is missing', async () => {
|
|
421
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
422
|
-
method: 'DELETE',
|
|
423
|
-
})
|
|
424
|
-
const response = await DELETE(request)
|
|
425
|
-
|
|
426
|
-
expect(response.status).toBe(400)
|
|
427
|
-
const body = await response.json()
|
|
428
|
-
expect(body.error).toBe('Rule id is required')
|
|
429
|
-
})
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
describe('Validation - Condition Expressions', () => {
|
|
433
|
-
test('should reject deeply nested condition expressions (depth > 10)', async () => {
|
|
434
|
-
const deeplyNested = {
|
|
435
|
-
operator: 'AND',
|
|
436
|
-
rules: [{
|
|
437
|
-
operator: 'AND',
|
|
438
|
-
rules: [{
|
|
439
|
-
operator: 'AND',
|
|
440
|
-
rules: [{
|
|
441
|
-
operator: 'AND',
|
|
442
|
-
rules: [{
|
|
443
|
-
operator: 'AND',
|
|
444
|
-
rules: [{
|
|
445
|
-
operator: 'AND',
|
|
446
|
-
rules: [{
|
|
447
|
-
operator: 'AND',
|
|
448
|
-
rules: [{
|
|
449
|
-
operator: 'AND',
|
|
450
|
-
rules: [{
|
|
451
|
-
operator: 'AND',
|
|
452
|
-
rules: [{
|
|
453
|
-
operator: 'AND',
|
|
454
|
-
rules: [{
|
|
455
|
-
operator: 'AND',
|
|
456
|
-
rules: [{ field: 'test', operator: '=', value: 'test' }]
|
|
457
|
-
}]
|
|
458
|
-
}]
|
|
459
|
-
}]
|
|
460
|
-
}]
|
|
461
|
-
}]
|
|
462
|
-
}]
|
|
463
|
-
}]
|
|
464
|
-
}]
|
|
465
|
-
}]
|
|
466
|
-
}]
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const newRule = {
|
|
470
|
-
ruleId: 'RULE-DEEP',
|
|
471
|
-
ruleName: 'Deep Rule',
|
|
472
|
-
ruleType: 'GUARD',
|
|
473
|
-
entityType: 'WorkOrder',
|
|
474
|
-
conditionExpression: deeplyNested,
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
478
|
-
method: 'POST',
|
|
479
|
-
body: JSON.stringify(newRule),
|
|
480
|
-
})
|
|
481
|
-
const response = await POST(request)
|
|
482
|
-
|
|
483
|
-
expect(response.status).toBe(400)
|
|
484
|
-
const body = await response.json()
|
|
485
|
-
expect(body.error).toContain('safety limits')
|
|
486
|
-
})
|
|
487
|
-
|
|
488
|
-
test('should reject condition with invalid field path', async () => {
|
|
489
|
-
const invalidCondition = {
|
|
490
|
-
field: '123invalid', // Field paths cannot start with numbers
|
|
491
|
-
operator: '=',
|
|
492
|
-
value: 'test'
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const newRule = {
|
|
496
|
-
ruleId: 'RULE-INVALID-FIELD',
|
|
497
|
-
ruleName: 'Invalid Field Rule',
|
|
498
|
-
ruleType: 'GUARD',
|
|
499
|
-
entityType: 'WorkOrder',
|
|
500
|
-
conditionExpression: invalidCondition,
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
504
|
-
method: 'POST',
|
|
505
|
-
body: JSON.stringify(newRule),
|
|
506
|
-
})
|
|
507
|
-
const response = await POST(request)
|
|
508
|
-
|
|
509
|
-
expect(response.status).toBe(400)
|
|
510
|
-
const body = await response.json()
|
|
511
|
-
expect(body.error).toContain('Invalid')
|
|
512
|
-
})
|
|
513
|
-
|
|
514
|
-
test('should reject condition with invalid operator', async () => {
|
|
515
|
-
const invalidCondition = {
|
|
516
|
-
field: 'status',
|
|
517
|
-
operator: 'IdasdaN', // Invalid operator
|
|
518
|
-
value: ['ACTIVE', 'PENDING']
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
const newRule = {
|
|
522
|
-
ruleId: 'RULE-INVALID-OPERATOR',
|
|
523
|
-
ruleName: 'Invalid Operator Rule',
|
|
524
|
-
ruleType: 'GUARD',
|
|
525
|
-
entityType: 'WorkOrder',
|
|
526
|
-
conditionExpression: invalidCondition,
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
530
|
-
method: 'POST',
|
|
531
|
-
body: JSON.stringify(newRule),
|
|
532
|
-
})
|
|
533
|
-
const response = await POST(request)
|
|
534
|
-
|
|
535
|
-
expect(response.status).toBe(400)
|
|
536
|
-
const body = await response.json()
|
|
537
|
-
expect(body.error).toContain('Invalid comparison operator')
|
|
538
|
-
expect(body.error).toContain('IdasdaN')
|
|
539
|
-
})
|
|
540
|
-
|
|
541
|
-
test('should reject condition group without rules', async () => {
|
|
542
|
-
const emptyGroup = {
|
|
543
|
-
operator: 'AND',
|
|
544
|
-
rules: []
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
const newRule = {
|
|
548
|
-
ruleId: 'RULE-EMPTY',
|
|
549
|
-
ruleName: 'Empty Rule',
|
|
550
|
-
ruleType: 'GUARD',
|
|
551
|
-
entityType: 'WorkOrder',
|
|
552
|
-
conditionExpression: emptyGroup,
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
556
|
-
method: 'POST',
|
|
557
|
-
body: JSON.stringify(newRule),
|
|
558
|
-
})
|
|
559
|
-
const response = await POST(request)
|
|
560
|
-
|
|
561
|
-
expect(response.status).toBe(400)
|
|
562
|
-
const body = await response.json()
|
|
563
|
-
expect(body.error).toContain('at least one rule')
|
|
564
|
-
})
|
|
565
|
-
|
|
566
|
-
test('should accept valid condition expression', async () => {
|
|
567
|
-
const validCondition = {
|
|
568
|
-
operator: 'AND',
|
|
569
|
-
rules: [
|
|
570
|
-
{ field: 'status', operator: '=', value: 'ACTIVE' },
|
|
571
|
-
{ field: 'priority', operator: '>', value: 5 }
|
|
572
|
-
]
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
const newRule = {
|
|
576
|
-
ruleId: 'RULE-VALID',
|
|
577
|
-
ruleName: 'Valid Rule',
|
|
578
|
-
ruleType: 'GUARD',
|
|
579
|
-
entityType: 'WorkOrder',
|
|
580
|
-
conditionExpression: validCondition,
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
mockEm.create.mockReturnValue({ id: '223e4567-e89b-12d3-a456-426614174003', ...newRule })
|
|
584
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
585
|
-
|
|
586
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
587
|
-
method: 'POST',
|
|
588
|
-
body: JSON.stringify(newRule),
|
|
589
|
-
})
|
|
590
|
-
const response = await POST(request)
|
|
591
|
-
|
|
592
|
-
expect(response.status).toBe(201)
|
|
593
|
-
})
|
|
594
|
-
})
|
|
595
|
-
|
|
596
|
-
describe('Validation - Actions', () => {
|
|
597
|
-
test('should reject action with missing required config fields', async () => {
|
|
598
|
-
const invalidActions = [
|
|
599
|
-
{ type: 'NOTIFY', config: {} } // Missing 'message' and 'recipients'
|
|
600
|
-
]
|
|
601
|
-
|
|
602
|
-
const newRule = {
|
|
603
|
-
ruleId: 'RULE-INVALID-ACTION',
|
|
604
|
-
ruleName: 'Invalid Action Rule',
|
|
605
|
-
ruleType: 'GUARD',
|
|
606
|
-
entityType: 'WorkOrder',
|
|
607
|
-
conditionExpression: { field: 'status', operator: '=', value: 'ACTIVE' },
|
|
608
|
-
successActions: invalidActions,
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
612
|
-
method: 'POST',
|
|
613
|
-
body: JSON.stringify(newRule),
|
|
614
|
-
})
|
|
615
|
-
const response = await POST(request)
|
|
616
|
-
|
|
617
|
-
expect(response.status).toBe(400)
|
|
618
|
-
const body = await response.json()
|
|
619
|
-
expect(body.error).toContain('message')
|
|
620
|
-
})
|
|
621
|
-
|
|
622
|
-
test('should reject action with invalid type', async () => {
|
|
623
|
-
const invalidActions = [
|
|
624
|
-
{ type: 'INVALID_ACTION_TYPE', config: {} }
|
|
625
|
-
]
|
|
626
|
-
|
|
627
|
-
const newRule = {
|
|
628
|
-
ruleId: 'RULE-INVALID-TYPE',
|
|
629
|
-
ruleName: 'Invalid Type Rule',
|
|
630
|
-
ruleType: 'GUARD',
|
|
631
|
-
entityType: 'WorkOrder',
|
|
632
|
-
conditionExpression: { field: 'status', operator: '=', value: 'ACTIVE' },
|
|
633
|
-
successActions: invalidActions,
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
637
|
-
method: 'POST',
|
|
638
|
-
body: JSON.stringify(newRule),
|
|
639
|
-
})
|
|
640
|
-
const response = await POST(request)
|
|
641
|
-
|
|
642
|
-
expect(response.status).toBe(400)
|
|
643
|
-
const body = await response.json()
|
|
644
|
-
expect(body.error).toContain('Unknown action type')
|
|
645
|
-
})
|
|
646
|
-
|
|
647
|
-
test('should accept valid actions', async () => {
|
|
648
|
-
const validActions = [
|
|
649
|
-
{ type: 'LOG', config: { message: 'Rule triggered' } },
|
|
650
|
-
{ type: 'SET_FIELD', config: { field: 'status', value: 'APPROVED' } }
|
|
651
|
-
]
|
|
652
|
-
|
|
653
|
-
const newRule = {
|
|
654
|
-
ruleId: 'RULE-VALID-ACTIONS',
|
|
655
|
-
ruleName: 'Valid Actions Rule',
|
|
656
|
-
ruleType: 'ACTION',
|
|
657
|
-
entityType: 'WorkOrder',
|
|
658
|
-
conditionExpression: { field: 'status', operator: '=', value: 'PENDING' },
|
|
659
|
-
successActions: validActions,
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
mockEm.create.mockReturnValue({ id: '223e4567-e89b-12d3-a456-426614174004', ...newRule })
|
|
663
|
-
mockEm.persistAndFlush.mockResolvedValue(undefined)
|
|
664
|
-
|
|
665
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
666
|
-
method: 'POST',
|
|
667
|
-
body: JSON.stringify(newRule),
|
|
668
|
-
})
|
|
669
|
-
const response = await POST(request)
|
|
670
|
-
|
|
671
|
-
expect(response.status).toBe(201)
|
|
672
|
-
})
|
|
673
|
-
|
|
674
|
-
test('should validate failureActions separately', async () => {
|
|
675
|
-
const invalidFailureActions = [
|
|
676
|
-
{ type: 'CALL_WEBHOOK', config: {} } // Missing 'url'
|
|
677
|
-
]
|
|
678
|
-
|
|
679
|
-
const newRule = {
|
|
680
|
-
ruleId: 'RULE-INVALID-FAILURE',
|
|
681
|
-
ruleName: 'Invalid Failure Actions',
|
|
682
|
-
ruleType: 'ACTION',
|
|
683
|
-
entityType: 'WorkOrder',
|
|
684
|
-
conditionExpression: { field: 'status', operator: '=', value: 'PENDING' },
|
|
685
|
-
successActions: [{ type: 'LOG', config: { message: 'Success' } }],
|
|
686
|
-
failureActions: invalidFailureActions,
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
690
|
-
method: 'POST',
|
|
691
|
-
body: JSON.stringify(newRule),
|
|
692
|
-
})
|
|
693
|
-
const response = await POST(request)
|
|
694
|
-
|
|
695
|
-
expect(response.status).toBe(400)
|
|
696
|
-
const body = await response.json()
|
|
697
|
-
expect(body.error).toContain('url')
|
|
698
|
-
})
|
|
699
|
-
})
|
|
700
|
-
|
|
701
|
-
describe('Validation - PUT/Update', () => {
|
|
702
|
-
test('should validate condition expression on update', async () => {
|
|
703
|
-
const invalidCondition = {
|
|
704
|
-
field: '', // Empty field path
|
|
705
|
-
operator: '=',
|
|
706
|
-
value: 'test'
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
const updateData = {
|
|
710
|
-
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
711
|
-
conditionExpression: invalidCondition,
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
715
|
-
method: 'PUT',
|
|
716
|
-
body: JSON.stringify(updateData),
|
|
717
|
-
})
|
|
718
|
-
const response = await PUT(request)
|
|
719
|
-
|
|
720
|
-
expect(response.status).toBe(400)
|
|
721
|
-
const body = await response.json()
|
|
722
|
-
expect(body.error).toContain('Invalid')
|
|
723
|
-
})
|
|
724
|
-
|
|
725
|
-
test('should validate actions on update', async () => {
|
|
726
|
-
const invalidActions = [
|
|
727
|
-
{ type: 'EMIT_EVENT', config: {} } // Missing 'eventName'
|
|
728
|
-
]
|
|
729
|
-
|
|
730
|
-
const updateData = {
|
|
731
|
-
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
732
|
-
successActions: invalidActions,
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
const request = new Request('http://localhost:3000/api/business_rules/rules', {
|
|
736
|
-
method: 'PUT',
|
|
737
|
-
body: JSON.stringify(updateData),
|
|
738
|
-
})
|
|
739
|
-
const response = await PUT(request)
|
|
740
|
-
|
|
741
|
-
expect(response.status).toBe(400)
|
|
742
|
-
const body = await response.json()
|
|
743
|
-
expect(body.error).toContain('eventName')
|
|
744
|
-
})
|
|
745
|
-
})
|
|
746
|
-
})
|