@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.
Files changed (473) hide show
  1. package/package.json +2 -2
  2. package/dist/modules/auth/__integration__/TC-AUTH-001.spec.js +0 -9
  3. package/dist/modules/auth/__integration__/TC-AUTH-001.spec.js.map +0 -7
  4. package/dist/modules/auth/__integration__/TC-AUTH-002.spec.js +0 -22
  5. package/dist/modules/auth/__integration__/TC-AUTH-002.spec.js.map +0 -7
  6. package/dist/modules/auth/__integration__/TC-AUTH-003.spec.js +0 -21
  7. package/dist/modules/auth/__integration__/TC-AUTH-003.spec.js.map +0 -7
  8. package/dist/modules/auth/__integration__/TC-AUTH-004.spec.js +0 -15
  9. package/dist/modules/auth/__integration__/TC-AUTH-004.spec.js.map +0 -7
  10. package/dist/modules/auth/__integration__/TC-AUTH-005.spec.js +0 -11
  11. package/dist/modules/auth/__integration__/TC-AUTH-005.spec.js.map +0 -7
  12. package/dist/modules/auth/__integration__/TC-AUTH-006.spec.js +0 -11
  13. package/dist/modules/auth/__integration__/TC-AUTH-006.spec.js.map +0 -7
  14. package/dist/modules/auth/__integration__/TC-AUTH-007.spec.js +0 -14
  15. package/dist/modules/auth/__integration__/TC-AUTH-007.spec.js.map +0 -7
  16. package/dist/modules/auth/__integration__/TC-AUTH-008.spec.js +0 -26
  17. package/dist/modules/auth/__integration__/TC-AUTH-008.spec.js.map +0 -7
  18. package/dist/modules/auth/__integration__/TC-AUTH-009.spec.js +0 -16
  19. package/dist/modules/auth/__integration__/TC-AUTH-009.spec.js.map +0 -7
  20. package/dist/modules/auth/__integration__/TC-AUTH-010.spec.js +0 -32
  21. package/dist/modules/auth/__integration__/TC-AUTH-010.spec.js.map +0 -7
  22. package/dist/modules/auth/__integration__/TC-AUTH-011.spec.js +0 -26
  23. package/dist/modules/auth/__integration__/TC-AUTH-011.spec.js.map +0 -7
  24. package/dist/modules/auth/__integration__/TC-AUTH-012.spec.js +0 -30
  25. package/dist/modules/auth/__integration__/TC-AUTH-012.spec.js.map +0 -7
  26. package/dist/modules/auth/__integration__/TC-AUTH-013.spec.js +0 -41
  27. package/dist/modules/auth/__integration__/TC-AUTH-013.spec.js.map +0 -7
  28. package/dist/modules/auth/__integration__/TC-AUTH-014.spec.js +0 -25
  29. package/dist/modules/auth/__integration__/TC-AUTH-014.spec.js.map +0 -7
  30. package/dist/modules/auth/__integration__/TC-AUTH-015.spec.js +0 -20
  31. package/dist/modules/auth/__integration__/TC-AUTH-015.spec.js.map +0 -7
  32. package/dist/modules/auth/__integration__/TC-AUTH-016.spec.js +0 -76
  33. package/dist/modules/auth/__integration__/TC-AUTH-016.spec.js.map +0 -7
  34. package/dist/modules/catalog/__integration__/TC-CAT-001.spec.js +0 -20
  35. package/dist/modules/catalog/__integration__/TC-CAT-001.spec.js.map +0 -7
  36. package/dist/modules/catalog/__integration__/TC-CAT-002.spec.js +0 -12
  37. package/dist/modules/catalog/__integration__/TC-CAT-002.spec.js.map +0 -7
  38. package/dist/modules/catalog/__integration__/TC-CAT-003.spec.js +0 -28
  39. package/dist/modules/catalog/__integration__/TC-CAT-003.spec.js.map +0 -7
  40. package/dist/modules/catalog/__integration__/TC-CAT-004.spec.js +0 -33
  41. package/dist/modules/catalog/__integration__/TC-CAT-004.spec.js.map +0 -7
  42. package/dist/modules/catalog/__integration__/TC-CAT-005.spec.js +0 -30
  43. package/dist/modules/catalog/__integration__/TC-CAT-005.spec.js.map +0 -7
  44. package/dist/modules/catalog/__integration__/TC-CAT-006.spec.js +0 -31
  45. package/dist/modules/catalog/__integration__/TC-CAT-006.spec.js.map +0 -7
  46. package/dist/modules/catalog/__integration__/TC-CAT-007.spec.js +0 -31
  47. package/dist/modules/catalog/__integration__/TC-CAT-007.spec.js.map +0 -7
  48. package/dist/modules/catalog/__integration__/TC-CAT-008.spec.js +0 -65
  49. package/dist/modules/catalog/__integration__/TC-CAT-008.spec.js.map +0 -7
  50. package/dist/modules/catalog/__integration__/TC-CAT-009.spec.js +0 -31
  51. package/dist/modules/catalog/__integration__/TC-CAT-009.spec.js.map +0 -7
  52. package/dist/modules/catalog/__integration__/TC-CAT-010.spec.js +0 -28
  53. package/dist/modules/catalog/__integration__/TC-CAT-010.spec.js.map +0 -7
  54. package/dist/modules/catalog/__integration__/TC-CAT-011.spec.js +0 -34
  55. package/dist/modules/catalog/__integration__/TC-CAT-011.spec.js.map +0 -7
  56. package/dist/modules/catalog/__integration__/TC-CAT-012.spec.js +0 -27
  57. package/dist/modules/catalog/__integration__/TC-CAT-012.spec.js.map +0 -7
  58. package/dist/modules/core/__integration__/admin/TC-ADMIN-001.spec.js +0 -44
  59. package/dist/modules/core/__integration__/admin/TC-ADMIN-001.spec.js.map +0 -7
  60. package/dist/modules/core/__integration__/admin/TC-ADMIN-002.spec.js +0 -53
  61. package/dist/modules/core/__integration__/admin/TC-ADMIN-002.spec.js.map +0 -7
  62. package/dist/modules/core/__integration__/admin/TC-ADMIN-003.spec.js +0 -26
  63. package/dist/modules/core/__integration__/admin/TC-ADMIN-003.spec.js.map +0 -7
  64. package/dist/modules/core/__integration__/admin/TC-ADMIN-004.spec.js +0 -47
  65. package/dist/modules/core/__integration__/admin/TC-ADMIN-004.spec.js.map +0 -7
  66. package/dist/modules/core/__integration__/admin/TC-ADMIN-005.spec.js +0 -33
  67. package/dist/modules/core/__integration__/admin/TC-ADMIN-005.spec.js.map +0 -7
  68. package/dist/modules/core/__integration__/admin/TC-ADMIN-006.spec.js +0 -30
  69. package/dist/modules/core/__integration__/admin/TC-ADMIN-006.spec.js.map +0 -7
  70. package/dist/modules/core/__integration__/admin/TC-ADMIN-007.spec.js +0 -36
  71. package/dist/modules/core/__integration__/admin/TC-ADMIN-007.spec.js.map +0 -7
  72. package/dist/modules/core/__integration__/admin/TC-ADMIN-008.spec.js +0 -113
  73. package/dist/modules/core/__integration__/admin/TC-ADMIN-008.spec.js.map +0 -7
  74. package/dist/modules/core/__integration__/admin/TC-ADMIN-009.spec.js +0 -25
  75. package/dist/modules/core/__integration__/admin/TC-ADMIN-009.spec.js.map +0 -7
  76. package/dist/modules/core/__integration__/admin/TC-ADMIN-010.spec.js +0 -35
  77. package/dist/modules/core/__integration__/admin/TC-ADMIN-010.spec.js.map +0 -7
  78. package/dist/modules/core/__integration__/helpers/api.js +0 -64
  79. package/dist/modules/core/__integration__/helpers/api.js.map +0 -7
  80. package/dist/modules/core/__integration__/helpers/auth.js +0 -98
  81. package/dist/modules/core/__integration__/helpers/auth.js.map +0 -7
  82. package/dist/modules/core/__integration__/helpers/authUi.js +0 -31
  83. package/dist/modules/core/__integration__/helpers/authUi.js.map +0 -7
  84. package/dist/modules/core/__integration__/helpers/catalogFixtures.js +0 -49
  85. package/dist/modules/core/__integration__/helpers/catalogFixtures.js.map +0 -7
  86. package/dist/modules/core/__integration__/helpers/crmFixtures.js +0 -73
  87. package/dist/modules/core/__integration__/helpers/crmFixtures.js.map +0 -7
  88. package/dist/modules/core/__integration__/helpers/salesFixtures.js +0 -63
  89. package/dist/modules/core/__integration__/helpers/salesFixtures.js.map +0 -7
  90. package/dist/modules/core/__integration__/helpers/salesUi.js +0 -464
  91. package/dist/modules/core/__integration__/helpers/salesUi.js.map +0 -7
  92. package/dist/modules/core/__integration__/integration/TC-INT-001.spec.js +0 -26
  93. package/dist/modules/core/__integration__/integration/TC-INT-001.spec.js.map +0 -7
  94. package/dist/modules/core/__integration__/integration/TC-INT-002.spec.js +0 -60
  95. package/dist/modules/core/__integration__/integration/TC-INT-002.spec.js.map +0 -7
  96. package/dist/modules/core/__integration__/integration/TC-INT-003.spec.js +0 -36
  97. package/dist/modules/core/__integration__/integration/TC-INT-003.spec.js.map +0 -7
  98. package/dist/modules/core/__integration__/integration/TC-INT-004.spec.js +0 -74
  99. package/dist/modules/core/__integration__/integration/TC-INT-004.spec.js.map +0 -7
  100. package/dist/modules/core/__integration__/integration/TC-INT-005.spec.js +0 -21
  101. package/dist/modules/core/__integration__/integration/TC-INT-005.spec.js.map +0 -7
  102. package/dist/modules/customers/__integration__/TC-CRM-001.spec.js +0 -32
  103. package/dist/modules/customers/__integration__/TC-CRM-001.spec.js.map +0 -7
  104. package/dist/modules/customers/__integration__/TC-CRM-002.spec.js +0 -35
  105. package/dist/modules/customers/__integration__/TC-CRM-002.spec.js.map +0 -7
  106. package/dist/modules/customers/__integration__/TC-CRM-003.spec.js +0 -40
  107. package/dist/modules/customers/__integration__/TC-CRM-003.spec.js.map +0 -7
  108. package/dist/modules/customers/__integration__/TC-CRM-004.spec.js +0 -40
  109. package/dist/modules/customers/__integration__/TC-CRM-004.spec.js.map +0 -7
  110. package/dist/modules/customers/__integration__/TC-CRM-005.spec.js +0 -37
  111. package/dist/modules/customers/__integration__/TC-CRM-005.spec.js.map +0 -7
  112. package/dist/modules/customers/__integration__/TC-CRM-006.spec.js +0 -42
  113. package/dist/modules/customers/__integration__/TC-CRM-006.spec.js.map +0 -7
  114. package/dist/modules/customers/__integration__/TC-CRM-007.spec.js +0 -44
  115. package/dist/modules/customers/__integration__/TC-CRM-007.spec.js.map +0 -7
  116. package/dist/modules/customers/__integration__/TC-CRM-008.spec.js +0 -50
  117. package/dist/modules/customers/__integration__/TC-CRM-008.spec.js.map +0 -7
  118. package/dist/modules/customers/__integration__/TC-CRM-009.spec.js +0 -33
  119. package/dist/modules/customers/__integration__/TC-CRM-009.spec.js.map +0 -7
  120. package/dist/modules/customers/__integration__/TC-CRM-010.spec.js +0 -39
  121. package/dist/modules/customers/__integration__/TC-CRM-010.spec.js.map +0 -7
  122. package/dist/modules/customers/__integration__/TC-CRM-011.spec.js +0 -37
  123. package/dist/modules/customers/__integration__/TC-CRM-011.spec.js.map +0 -7
  124. package/dist/modules/customers/__integration__/TC-CRM-012.spec.js +0 -38
  125. package/dist/modules/customers/__integration__/TC-CRM-012.spec.js.map +0 -7
  126. package/dist/modules/customers/__integration__/TC-CRM-013.spec.js +0 -43
  127. package/dist/modules/customers/__integration__/TC-CRM-013.spec.js.map +0 -7
  128. package/dist/modules/customers/__integration__/TC-CRM-014.spec.js +0 -23
  129. package/dist/modules/customers/__integration__/TC-CRM-014.spec.js.map +0 -7
  130. package/dist/modules/customers/__integration__/TC-CRM-015.spec.js +0 -63
  131. package/dist/modules/customers/__integration__/TC-CRM-015.spec.js.map +0 -7
  132. package/dist/modules/customers/__integration__/TC-CRM-016.spec.js +0 -46
  133. package/dist/modules/customers/__integration__/TC-CRM-016.spec.js.map +0 -7
  134. package/dist/modules/customers/__integration__/TC-CRM-017.spec.js +0 -29
  135. package/dist/modules/customers/__integration__/TC-CRM-017.spec.js.map +0 -7
  136. package/dist/modules/customers/__integration__/TC-CRM-018.spec.js +0 -52
  137. package/dist/modules/customers/__integration__/TC-CRM-018.spec.js.map +0 -7
  138. package/dist/modules/customers/__integration__/TC-CRM-019.spec.js +0 -37
  139. package/dist/modules/customers/__integration__/TC-CRM-019.spec.js.map +0 -7
  140. package/dist/modules/customers/__integration__/TC-CRM-020.spec.js +0 -65
  141. package/dist/modules/customers/__integration__/TC-CRM-020.spec.js.map +0 -7
  142. package/dist/modules/progress/__integration__/TC-PROG-001.spec.js +0 -51
  143. package/dist/modules/progress/__integration__/TC-PROG-001.spec.js.map +0 -7
  144. package/dist/modules/resources/__integration__/TC-INT-007.spec.js +0 -88
  145. package/dist/modules/resources/__integration__/TC-INT-007.spec.js.map +0 -7
  146. package/dist/modules/resources/__integration__/helpers/resourcesFixtures.js +0 -45
  147. package/dist/modules/resources/__integration__/helpers/resourcesFixtures.js.map +0 -7
  148. package/dist/modules/sales/__integration__/TC-SALES-001.spec.js +0 -20
  149. package/dist/modules/sales/__integration__/TC-SALES-001.spec.js.map +0 -7
  150. package/dist/modules/sales/__integration__/TC-SALES-002.spec.js +0 -31
  151. package/dist/modules/sales/__integration__/TC-SALES-002.spec.js.map +0 -7
  152. package/dist/modules/sales/__integration__/TC-SALES-003.spec.js +0 -13
  153. package/dist/modules/sales/__integration__/TC-SALES-003.spec.js.map +0 -7
  154. package/dist/modules/sales/__integration__/TC-SALES-004.spec.js +0 -14
  155. package/dist/modules/sales/__integration__/TC-SALES-004.spec.js.map +0 -7
  156. package/dist/modules/sales/__integration__/TC-SALES-005.spec.js +0 -15
  157. package/dist/modules/sales/__integration__/TC-SALES-005.spec.js.map +0 -7
  158. package/dist/modules/sales/__integration__/TC-SALES-006.spec.js +0 -20
  159. package/dist/modules/sales/__integration__/TC-SALES-006.spec.js.map +0 -7
  160. package/dist/modules/sales/__integration__/TC-SALES-007.spec.js +0 -19
  161. package/dist/modules/sales/__integration__/TC-SALES-007.spec.js.map +0 -7
  162. package/dist/modules/sales/__integration__/TC-SALES-008.spec.js +0 -7
  163. package/dist/modules/sales/__integration__/TC-SALES-008.spec.js.map +0 -7
  164. package/dist/modules/sales/__integration__/TC-SALES-009.spec.js +0 -7
  165. package/dist/modules/sales/__integration__/TC-SALES-009.spec.js.map +0 -7
  166. package/dist/modules/sales/__integration__/TC-SALES-010.spec.js +0 -16
  167. package/dist/modules/sales/__integration__/TC-SALES-010.spec.js.map +0 -7
  168. package/dist/modules/sales/__integration__/TC-SALES-011.spec.js +0 -20
  169. package/dist/modules/sales/__integration__/TC-SALES-011.spec.js.map +0 -7
  170. package/dist/modules/sales/__integration__/TC-SALES-012.spec.js +0 -7
  171. package/dist/modules/sales/__integration__/TC-SALES-012.spec.js.map +0 -7
  172. package/dist/modules/sales/__integration__/TC-SALES-013.spec.js +0 -66
  173. package/dist/modules/sales/__integration__/TC-SALES-013.spec.js.map +0 -7
  174. package/dist/modules/sales/__integration__/TC-SALES-014.spec.js +0 -13
  175. package/dist/modules/sales/__integration__/TC-SALES-014.spec.js.map +0 -7
  176. package/dist/modules/sales/__integration__/TC-SALES-015.spec.js +0 -13
  177. package/dist/modules/sales/__integration__/TC-SALES-015.spec.js.map +0 -7
  178. package/dist/modules/sales/__integration__/TC-SALES-016.spec.js +0 -13
  179. package/dist/modules/sales/__integration__/TC-SALES-016.spec.js.map +0 -7
  180. package/dist/modules/sales/__integration__/TC-SALES-017.spec.js +0 -44
  181. package/dist/modules/sales/__integration__/TC-SALES-017.spec.js.map +0 -7
  182. package/dist/modules/sales/__integration__/TC-SALES-018.spec.js +0 -18
  183. package/dist/modules/sales/__integration__/TC-SALES-018.spec.js.map +0 -7
  184. package/dist/modules/sales/__integration__/TC-SALES-019.spec.js +0 -16
  185. package/dist/modules/sales/__integration__/TC-SALES-019.spec.js.map +0 -7
  186. package/dist/modules/sales/__integration__/TC-SALES-020.spec.js +0 -75
  187. package/dist/modules/sales/__integration__/TC-SALES-020.spec.js.map +0 -7
  188. package/dist/modules/staff/__integration__/TC-INT-006.spec.js +0 -64
  189. package/dist/modules/staff/__integration__/TC-INT-006.spec.js.map +0 -7
  190. package/dist/modules/translations/__integration__/TC-TRANS-001.spec.js +0 -48
  191. package/dist/modules/translations/__integration__/TC-TRANS-001.spec.js.map +0 -7
  192. package/dist/modules/translations/__integration__/TC-TRANS-002.spec.js +0 -94
  193. package/dist/modules/translations/__integration__/TC-TRANS-002.spec.js.map +0 -7
  194. package/dist/modules/translations/__integration__/TC-TRANS-003.spec.js +0 -61
  195. package/dist/modules/translations/__integration__/TC-TRANS-003.spec.js.map +0 -7
  196. package/dist/modules/translations/__integration__/TC-TRANS-004.spec.js +0 -52
  197. package/dist/modules/translations/__integration__/TC-TRANS-004.spec.js.map +0 -7
  198. package/dist/modules/translations/__integration__/TC-TRANS-005.spec.js +0 -106
  199. package/dist/modules/translations/__integration__/TC-TRANS-005.spec.js.map +0 -7
  200. package/dist/modules/translations/__integration__/TC-TRANS-006.spec.js +0 -94
  201. package/dist/modules/translations/__integration__/TC-TRANS-006.spec.js.map +0 -7
  202. package/dist/modules/translations/__integration__/TC-TRANS-007.spec.js +0 -62
  203. package/dist/modules/translations/__integration__/TC-TRANS-007.spec.js.map +0 -7
  204. package/dist/modules/translations/__integration__/TC-TRANS-008.spec.js +0 -168
  205. package/dist/modules/translations/__integration__/TC-TRANS-008.spec.js.map +0 -7
  206. package/dist/modules/translations/__integration__/helpers/translationFixtures.js +0 -63
  207. package/dist/modules/translations/__integration__/helpers/translationFixtures.js.map +0 -7
  208. package/dist/modules/workflows/__integration__/TC-WF-001.spec.js +0 -73
  209. package/dist/modules/workflows/__integration__/TC-WF-001.spec.js.map +0 -7
  210. package/src/__tests__/module-decoupling.test.ts +0 -356
  211. package/src/modules/api_keys/api/__tests__/keys.route.test.ts +0 -244
  212. package/src/modules/attachments/api/__tests__/attachments.api.test.ts +0 -240
  213. package/src/modules/attachments/components/__tests__/AttachmentContentPreview.test.tsx +0 -45
  214. package/src/modules/attachments/data/__tests__/entities-ocr.test.ts +0 -15
  215. package/src/modules/attachments/lib/__tests__/ocr-config.test.ts +0 -27
  216. package/src/modules/attachments/lib/__tests__/textExtraction.test.ts +0 -64
  217. package/src/modules/audit_logs/api/__tests__/access.route.test.ts +0 -118
  218. package/src/modules/audit_logs/api/__tests__/redo.route.test.ts +0 -131
  219. package/src/modules/audit_logs/api/__tests__/undo.route.test.ts +0 -103
  220. package/src/modules/audit_logs/services/__tests__/actionLogService.test.ts +0 -26
  221. package/src/modules/auth/__integration__/TC-AUTH-001.spec.ts +0 -13
  222. package/src/modules/auth/__integration__/TC-AUTH-002.spec.ts +0 -30
  223. package/src/modules/auth/__integration__/TC-AUTH-003.spec.ts +0 -28
  224. package/src/modules/auth/__integration__/TC-AUTH-004.spec.ts +0 -21
  225. package/src/modules/auth/__integration__/TC-AUTH-005.spec.ts +0 -17
  226. package/src/modules/auth/__integration__/TC-AUTH-006.spec.ts +0 -17
  227. package/src/modules/auth/__integration__/TC-AUTH-007.spec.ts +0 -19
  228. package/src/modules/auth/__integration__/TC-AUTH-008.spec.ts +0 -31
  229. package/src/modules/auth/__integration__/TC-AUTH-009.spec.ts +0 -22
  230. package/src/modules/auth/__integration__/TC-AUTH-010.spec.ts +0 -39
  231. package/src/modules/auth/__integration__/TC-AUTH-011.spec.ts +0 -35
  232. package/src/modules/auth/__integration__/TC-AUTH-012.spec.ts +0 -36
  233. package/src/modules/auth/__integration__/TC-AUTH-013.spec.ts +0 -48
  234. package/src/modules/auth/__integration__/TC-AUTH-014.spec.ts +0 -31
  235. package/src/modules/auth/__integration__/TC-AUTH-015.spec.ts +0 -28
  236. package/src/modules/auth/__integration__/TC-AUTH-016.spec.ts +0 -109
  237. package/src/modules/auth/__tests__/cli-rotate-encryption.test.ts +0 -97
  238. package/src/modules/auth/__tests__/cli-setup-acl.test.ts +0 -148
  239. package/src/modules/auth/api/__tests__/feature-check.test.ts +0 -65
  240. package/src/modules/auth/api/__tests__/login.test.ts +0 -47
  241. package/src/modules/auth/commands/__tests__/roles.custom-fields.test.ts +0 -126
  242. package/src/modules/auth/commands/__tests__/users.custom-fields.test.ts +0 -147
  243. package/src/modules/auth/lib/__tests__/rateLimitCheck.test.ts +0 -224
  244. package/src/modules/auth/services/__tests__/authService.test.ts +0 -32
  245. package/src/modules/auth/services/__tests__/rbacService.test.ts +0 -814
  246. package/src/modules/business_rules/api/__tests__/execute.route.test.ts +0 -311
  247. package/src/modules/business_rules/api/__tests__/logs-detail.route.test.ts +0 -181
  248. package/src/modules/business_rules/api/__tests__/logs.route.test.ts +0 -261
  249. package/src/modules/business_rules/api/__tests__/rules-detail.route.test.ts +0 -115
  250. package/src/modules/business_rules/api/__tests__/rules.route.test.ts +0 -746
  251. package/src/modules/business_rules/api/__tests__/sets-detail.route.test.ts +0 -169
  252. package/src/modules/business_rules/api/__tests__/sets-members.route.test.ts +0 -367
  253. package/src/modules/business_rules/api/__tests__/sets.route.test.ts +0 -361
  254. package/src/modules/business_rules/api/__tests__/test-helpers.ts +0 -42
  255. package/src/modules/business_rules/components/utils/__tests__/formHelpers.test.ts +0 -69
  256. package/src/modules/business_rules/data/__tests__/validators.test.ts +0 -637
  257. package/src/modules/business_rules/lib/__tests__/action-executor.test.ts +0 -728
  258. package/src/modules/business_rules/lib/__tests__/expression-evaluator.test.ts +0 -592
  259. package/src/modules/business_rules/lib/__tests__/rule-engine.test.ts +0 -805
  260. package/src/modules/business_rules/lib/__tests__/rule-evaluator.test.ts +0 -436
  261. package/src/modules/catalog/__integration__/TC-CAT-001.spec.ts +0 -32
  262. package/src/modules/catalog/__integration__/TC-CAT-002.spec.ts +0 -19
  263. package/src/modules/catalog/__integration__/TC-CAT-003.spec.ts +0 -39
  264. package/src/modules/catalog/__integration__/TC-CAT-004.spec.ts +0 -41
  265. package/src/modules/catalog/__integration__/TC-CAT-005.spec.ts +0 -37
  266. package/src/modules/catalog/__integration__/TC-CAT-006.spec.ts +0 -40
  267. package/src/modules/catalog/__integration__/TC-CAT-007.spec.ts +0 -37
  268. package/src/modules/catalog/__integration__/TC-CAT-008.spec.ts +0 -76
  269. package/src/modules/catalog/__integration__/TC-CAT-009.spec.ts +0 -39
  270. package/src/modules/catalog/__integration__/TC-CAT-010.spec.ts +0 -36
  271. package/src/modules/catalog/__integration__/TC-CAT-011.spec.ts +0 -44
  272. package/src/modules/catalog/__integration__/TC-CAT-012.spec.ts +0 -35
  273. package/src/modules/catalog/api/__tests__/offers.route.test.ts +0 -161
  274. package/src/modules/catalog/api/__tests__/prices.route.test.ts +0 -39
  275. package/src/modules/catalog/api/__tests__/products.route.test.ts +0 -91
  276. package/src/modules/catalog/api/__tests__/utils.test.ts +0 -36
  277. package/src/modules/catalog/api/__tests__/variants.route.test.ts +0 -44
  278. package/src/modules/catalog/backend/catalog/products/__tests__/ProductsDataTable.test.tsx +0 -172
  279. package/src/modules/catalog/commands/__tests__/products.delete.test.ts +0 -146
  280. package/src/modules/catalog/commands/__tests__/products.update.test.ts +0 -142
  281. package/src/modules/catalog/commands/__tests__/registration.test.ts +0 -54
  282. package/src/modules/catalog/commands/__tests__/shared.test.ts +0 -129
  283. package/src/modules/catalog/components/__tests__/catalogComponentsRender.test.tsx +0 -373
  284. package/src/modules/catalog/components/products/__tests__/ProductImageCell.test.tsx +0 -51
  285. package/src/modules/catalog/components/products/__tests__/productForm.test.ts +0 -32
  286. package/src/modules/catalog/lib/__tests__/pricing.test.ts +0 -150
  287. package/src/modules/catalog/services/__tests__/catalogPricingService.test.ts +0 -21
  288. package/src/modules/configs/components/__tests__/CachePanel.test.tsx +0 -134
  289. package/src/modules/configs/components/__tests__/SystemStatusPanel.test.tsx +0 -93
  290. package/src/modules/configs/lib/__tests__/system-status.test.ts +0 -55
  291. package/src/modules/configs/lib/__tests__/upgrade-actions.test.ts +0 -135
  292. package/src/modules/core/__integration__/admin/TC-ADMIN-001.spec.ts +0 -70
  293. package/src/modules/core/__integration__/admin/TC-ADMIN-002.spec.ts +0 -83
  294. package/src/modules/core/__integration__/admin/TC-ADMIN-003.spec.ts +0 -50
  295. package/src/modules/core/__integration__/admin/TC-ADMIN-004.spec.ts +0 -77
  296. package/src/modules/core/__integration__/admin/TC-ADMIN-005.spec.ts +0 -49
  297. package/src/modules/core/__integration__/admin/TC-ADMIN-006.spec.ts +0 -59
  298. package/src/modules/core/__integration__/admin/TC-ADMIN-007.spec.ts +0 -68
  299. package/src/modules/core/__integration__/admin/TC-ADMIN-008.spec.ts +0 -127
  300. package/src/modules/core/__integration__/admin/TC-ADMIN-009.spec.ts +0 -48
  301. package/src/modules/core/__integration__/admin/TC-ADMIN-010.spec.ts +0 -57
  302. package/src/modules/core/__integration__/helpers/api.ts +0 -84
  303. package/src/modules/core/__integration__/helpers/auth.ts +0 -110
  304. package/src/modules/core/__integration__/helpers/authUi.ts +0 -33
  305. package/src/modules/core/__integration__/helpers/catalogFixtures.ts +0 -73
  306. package/src/modules/core/__integration__/helpers/crmFixtures.ts +0 -101
  307. package/src/modules/core/__integration__/helpers/salesFixtures.ts +0 -89
  308. package/src/modules/core/__integration__/helpers/salesUi.ts +0 -528
  309. package/src/modules/core/__integration__/integration/TC-INT-001.spec.ts +0 -34
  310. package/src/modules/core/__integration__/integration/TC-INT-002.spec.ts +0 -74
  311. package/src/modules/core/__integration__/integration/TC-INT-003.spec.ts +0 -43
  312. package/src/modules/core/__integration__/integration/TC-INT-004.spec.ts +0 -82
  313. package/src/modules/core/__integration__/integration/TC-INT-005.spec.ts +0 -29
  314. package/src/modules/currencies/backend/exchange-rates/__tests__/formatDateTimeLocal.test.ts +0 -78
  315. package/src/modules/currencies/data/__tests__/validators.test.ts +0 -100
  316. package/src/modules/currencies/services/__tests__/exchangeRateService.test.ts +0 -666
  317. package/src/modules/currencies/services/__tests__/rateFetchingService.basic.test.ts +0 -398
  318. package/src/modules/currencies/services/__tests__/rateFetchingService.errors.test.ts +0 -296
  319. package/src/modules/currencies/services/__tests__/rateFetchingService.providers.test.ts +0 -350
  320. package/src/modules/currencies/services/__tests__/rateFetchingService.setup.ts +0 -188
  321. package/src/modules/customers/__integration__/TC-CRM-001.spec.ts +0 -42
  322. package/src/modules/customers/__integration__/TC-CRM-002.spec.ts +0 -47
  323. package/src/modules/customers/__integration__/TC-CRM-003.spec.ts +0 -55
  324. package/src/modules/customers/__integration__/TC-CRM-004.spec.ts +0 -57
  325. package/src/modules/customers/__integration__/TC-CRM-005.spec.ts +0 -50
  326. package/src/modules/customers/__integration__/TC-CRM-006.spec.ts +0 -60
  327. package/src/modules/customers/__integration__/TC-CRM-007.spec.ts +0 -57
  328. package/src/modules/customers/__integration__/TC-CRM-008.spec.ts +0 -62
  329. package/src/modules/customers/__integration__/TC-CRM-009.spec.ts +0 -46
  330. package/src/modules/customers/__integration__/TC-CRM-010.spec.ts +0 -49
  331. package/src/modules/customers/__integration__/TC-CRM-011.spec.ts +0 -47
  332. package/src/modules/customers/__integration__/TC-CRM-012.spec.ts +0 -49
  333. package/src/modules/customers/__integration__/TC-CRM-013.spec.ts +0 -61
  334. package/src/modules/customers/__integration__/TC-CRM-014.spec.ts +0 -31
  335. package/src/modules/customers/__integration__/TC-CRM-015.spec.ts +0 -89
  336. package/src/modules/customers/__integration__/TC-CRM-016.spec.ts +0 -55
  337. package/src/modules/customers/__integration__/TC-CRM-017.spec.ts +0 -37
  338. package/src/modules/customers/__integration__/TC-CRM-018.spec.ts +0 -62
  339. package/src/modules/customers/__integration__/TC-CRM-019.spec.ts +0 -44
  340. package/src/modules/customers/__integration__/TC-CRM-020.spec.ts +0 -73
  341. package/src/modules/customers/api/__tests__/utils.test.ts +0 -61
  342. package/src/modules/customers/api/dashboard/widgets/new-deals/__tests__/route.test.ts +0 -54
  343. package/src/modules/customers/commands/__tests__/shared.test.ts +0 -263
  344. package/src/modules/customers/commands/__tests__/undo.custom-fields.test.ts +0 -1184
  345. package/src/modules/customers/components/detail/__tests__/ActivityForm.validation.test.ts +0 -37
  346. package/src/modules/customers/components/detail/__tests__/DealForm.validation.test.ts +0 -45
  347. package/src/modules/customers/components/detail/__tests__/InlineEditors.test.tsx +0 -166
  348. package/src/modules/customers/components/detail/__tests__/TaskForm.submit.test.ts +0 -21
  349. package/src/modules/customers/components/detail/hooks/__tests__/useCustomerDictionary.test.ts +0 -97
  350. package/src/modules/customers/lib/__tests__/customFieldRouting.test.ts +0 -107
  351. package/src/modules/customers/utils/__tests__/addressFormat.test.ts +0 -105
  352. package/src/modules/customers/utils/__tests__/phoneDuplicates.test.ts +0 -98
  353. package/src/modules/dashboards/__tests__/widgets.test.ts +0 -70
  354. package/src/modules/dashboards/lib/__tests__/aggregations.test.ts +0 -328
  355. package/src/modules/dashboards/lib/__tests__/formatters.test.ts +0 -128
  356. package/src/modules/directory/backend/directory/organizations/__tests__/create-submit.test.ts +0 -46
  357. package/src/modules/directory/backend/directory/organizations/__tests__/edit-submit.test.ts +0 -49
  358. package/src/modules/directory/components/__tests__/OrganizationSelect.test.tsx +0 -71
  359. package/src/modules/directory/components/__tests__/TenantSelect.test.tsx +0 -75
  360. package/src/modules/entities/__tests__/cli-decrypt-database.test.ts +0 -534
  361. package/src/modules/entities/__tests__/cli-rotate-encryption.test.ts +0 -123
  362. package/src/modules/entities/api/__tests__/encryption.api.test.ts +0 -57
  363. package/src/modules/entities/api/__tests__/records.get.custom-entity.test.ts +0 -43
  364. package/src/modules/entities/api/__tests__/records.validation.test.ts +0 -53
  365. package/src/modules/entities/backend/entities/user/__tests__/create-entity-submit.test.ts +0 -47
  366. package/src/modules/entities/backend/entities/user/__tests__/records-submit.test.ts +0 -104
  367. package/src/modules/feature_toggles/commands/__tests__/global.test.ts +0 -325
  368. package/src/modules/feature_toggles/commands/__tests__/overrides.test.ts +0 -186
  369. package/src/modules/feature_toggles/lib/__tests__/feature-flag-check.test.ts +0 -365
  370. package/src/modules/feature_toggles/lib/__tests__/queries.test.ts +0 -130
  371. package/src/modules/inbox_ops/api/emails/[id]/reprocess/__tests__/route.test.ts +0 -194
  372. package/src/modules/inbox_ops/api/proposals/[id]/__tests__/route.test.ts +0 -124
  373. package/src/modules/inbox_ops/api/proposals/[id]/accept-all/__tests__/route.test.ts +0 -154
  374. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/__tests__/route.test.ts +0 -200
  375. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/accept/__tests__/route.test.ts +0 -261
  376. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/reject/__tests__/route.test.ts +0 -201
  377. package/src/modules/inbox_ops/api/proposals/[id]/reject/__tests__/route.test.ts +0 -123
  378. package/src/modules/inbox_ops/api/proposals/[id]/replies/[replyId]/send/__tests__/route.test.ts +0 -232
  379. package/src/modules/inbox_ops/api/proposals/[id]/translate/__tests__/route.test.ts +0 -173
  380. package/src/modules/inbox_ops/api/proposals/__tests__/route.test.ts +0 -185
  381. package/src/modules/inbox_ops/api/webhook/__tests__/inbound.test.ts +0 -317
  382. package/src/modules/inbox_ops/data/__tests__/validators.test.ts +0 -463
  383. package/src/modules/inbox_ops/lib/__tests__/catalogLookup.test.ts +0 -143
  384. package/src/modules/inbox_ops/lib/__tests__/contactMatcher.test.ts +0 -158
  385. package/src/modules/inbox_ops/lib/__tests__/emailParser.test.ts +0 -191
  386. package/src/modules/inbox_ops/lib/__tests__/executionEngine.test.ts +0 -1419
  387. package/src/modules/inbox_ops/lib/__tests__/extractionPrompt.test.ts +0 -151
  388. package/src/modules/inbox_ops/lib/__tests__/priceValidator.test.ts +0 -259
  389. package/src/modules/inbox_ops/lib/__tests__/translationProvider.test.ts +0 -99
  390. package/src/modules/inbox_ops/subscribers/__tests__/extractionWorker.test.ts +0 -803
  391. package/src/modules/notifications/__tests__/deliver-notification.test.ts +0 -285
  392. package/src/modules/notifications/__tests__/deliveryStrategies.test.ts +0 -19
  393. package/src/modules/notifications/__tests__/notificationService.test.ts +0 -248
  394. package/src/modules/planner/__tests__/availabilityMerge.test.ts +0 -99
  395. package/src/modules/planner/__tests__/plannerAvailabilityService.test.ts +0 -89
  396. package/src/modules/planner/data/__tests__/validators.test.ts +0 -78
  397. package/src/modules/progress/__integration__/TC-PROG-001.spec.ts +0 -67
  398. package/src/modules/progress/__tests__/progressService.test.ts +0 -377
  399. package/src/modules/query_index/__tests__/hybrid-engine.test.ts +0 -365
  400. package/src/modules/query_index/__tests__/indexer.test.ts +0 -175
  401. package/src/modules/resources/__integration__/TC-INT-007.spec.ts +0 -110
  402. package/src/modules/resources/__integration__/helpers/resourcesFixtures.ts +0 -50
  403. package/src/modules/resources/data/__tests__/validators.test.ts +0 -65
  404. package/src/modules/sales/__integration__/TC-SALES-001.spec.ts +0 -26
  405. package/src/modules/sales/__integration__/TC-SALES-002.spec.ts +0 -38
  406. package/src/modules/sales/__integration__/TC-SALES-003.spec.ts +0 -18
  407. package/src/modules/sales/__integration__/TC-SALES-004.spec.ts +0 -19
  408. package/src/modules/sales/__integration__/TC-SALES-005.spec.ts +0 -21
  409. package/src/modules/sales/__integration__/TC-SALES-006.spec.ts +0 -26
  410. package/src/modules/sales/__integration__/TC-SALES-007.spec.ts +0 -23
  411. package/src/modules/sales/__integration__/TC-SALES-008.spec.ts +0 -11
  412. package/src/modules/sales/__integration__/TC-SALES-009.spec.ts +0 -12
  413. package/src/modules/sales/__integration__/TC-SALES-010.spec.ts +0 -20
  414. package/src/modules/sales/__integration__/TC-SALES-011.spec.ts +0 -26
  415. package/src/modules/sales/__integration__/TC-SALES-012.spec.ts +0 -12
  416. package/src/modules/sales/__integration__/TC-SALES-013.spec.ts +0 -73
  417. package/src/modules/sales/__integration__/TC-SALES-014.spec.ts +0 -17
  418. package/src/modules/sales/__integration__/TC-SALES-015.spec.ts +0 -17
  419. package/src/modules/sales/__integration__/TC-SALES-016.spec.ts +0 -17
  420. package/src/modules/sales/__integration__/TC-SALES-017.spec.ts +0 -60
  421. package/src/modules/sales/__integration__/TC-SALES-018.spec.ts +0 -25
  422. package/src/modules/sales/__integration__/TC-SALES-019.spec.ts +0 -22
  423. package/src/modules/sales/__integration__/TC-SALES-020.spec.ts +0 -107
  424. package/src/modules/sales/api/__tests__/channels.route.test.ts +0 -50
  425. package/src/modules/sales/api/__tests__/document-history.test.ts +0 -146
  426. package/src/modules/sales/api/__tests__/documents.factory.test.ts +0 -98
  427. package/src/modules/sales/api/__tests__/documents.routes.test.ts +0 -149
  428. package/src/modules/sales/api/__tests__/quotes.acceptance.test.ts +0 -209
  429. package/src/modules/sales/api/__tests__/timeline.test.tsx +0 -165
  430. package/src/modules/sales/api/dashboard/widgets/new-orders/__tests__/route.test.ts +0 -112
  431. package/src/modules/sales/api/dashboard/widgets/new-quotes/__tests__/route.test.ts +0 -116
  432. package/src/modules/sales/commands/__tests__/documents.cache.test.ts +0 -126
  433. package/src/modules/sales/commands/__tests__/documents.undo.test.ts +0 -170
  434. package/src/modules/sales/commands/__tests__/registration.test.ts +0 -141
  435. package/src/modules/sales/components/__tests__/salesComponentsRender.test.tsx +0 -456
  436. package/src/modules/sales/lib/__tests__/calculations.test.ts +0 -210
  437. package/src/modules/sales/services/__tests__/salesCalculationService.test.ts +0 -181
  438. package/src/modules/sales/services/__tests__/taxCalculationService.test.ts +0 -79
  439. package/src/modules/sales/widgets/dashboard/new-orders/__tests__/config.test.ts +0 -47
  440. package/src/modules/sales/widgets/dashboard/new-quotes/__tests__/config.test.ts +0 -47
  441. package/src/modules/staff/__integration__/TC-INT-006.spec.ts +0 -71
  442. package/src/modules/staff/data/__tests__/validators.test.ts +0 -60
  443. package/src/modules/translations/__integration__/TC-TRANS-001.spec.ts +0 -57
  444. package/src/modules/translations/__integration__/TC-TRANS-002.spec.ts +0 -114
  445. package/src/modules/translations/__integration__/TC-TRANS-003.spec.ts +0 -71
  446. package/src/modules/translations/__integration__/TC-TRANS-004.spec.ts +0 -66
  447. package/src/modules/translations/__integration__/TC-TRANS-005.spec.ts +0 -135
  448. package/src/modules/translations/__integration__/TC-TRANS-006.spec.ts +0 -113
  449. package/src/modules/translations/__integration__/TC-TRANS-007.spec.ts +0 -80
  450. package/src/modules/translations/__integration__/TC-TRANS-008.spec.ts +0 -209
  451. package/src/modules/translations/__integration__/helpers/translationFixtures.ts +0 -95
  452. package/src/modules/translations/api/__tests__/locales.test.ts +0 -67
  453. package/src/modules/translations/data/__tests__/validators.test.ts +0 -143
  454. package/src/modules/translations/lib/__tests__/extract-record-id.test.ts +0 -75
  455. package/src/modules/translations/lib/__tests__/helpers.test.ts +0 -215
  456. package/src/modules/translations/lib/__tests__/locale.test.ts +0 -115
  457. package/src/modules/translations/lib/__tests__/resolve-field-list.test.ts +0 -176
  458. package/src/modules/translations/lib/__tests__/translatable-fields.test.ts +0 -79
  459. package/src/modules/translations/widgets/__tests__/injection-table.test.ts +0 -83
  460. package/src/modules/workflows/__integration__/TC-WF-001.spec.ts +0 -114
  461. package/src/modules/workflows/api/__tests__/definitions.route.test.ts +0 -762
  462. package/src/modules/workflows/api/__tests__/instances.route.test.ts +0 -869
  463. package/src/modules/workflows/data/__tests__/validators.test.ts +0 -707
  464. package/src/modules/workflows/lib/__tests__/activity-executor.test.ts +0 -1230
  465. package/src/modules/workflows/lib/__tests__/call-api.test.ts +0 -421
  466. package/src/modules/workflows/lib/__tests__/compensation.test.ts +0 -713
  467. package/src/modules/workflows/lib/__tests__/event-logger.test.ts +0 -615
  468. package/src/modules/workflows/lib/__tests__/integration.test.ts +0 -693
  469. package/src/modules/workflows/lib/__tests__/signals.test.ts +0 -566
  470. package/src/modules/workflows/lib/__tests__/step-handler.test.ts +0 -670
  471. package/src/modules/workflows/lib/__tests__/sub-workflow.test.ts +0 -934
  472. package/src/modules/workflows/lib/__tests__/transition-handler.test.ts +0 -925
  473. package/src/modules/workflows/lib/__tests__/workflow-executor.test.ts +0 -684
@@ -1,803 +0,0 @@
1
- /** @jest-environment node */
2
-
3
- import handle from '../extractionWorker'
4
- import { InboxEmail, InboxProposal, InboxProposalAction, InboxDiscrepancy, InboxSettings } from '../../data/entities'
5
-
6
- const mockRunExtraction = jest.fn()
7
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/llmProvider', () => ({
8
- runExtractionWithConfiguredProvider: (...args: unknown[]) => mockRunExtraction(...args),
9
- }))
10
-
11
- const mockMatchContacts = jest.fn()
12
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/contactMatcher', () => ({
13
- matchContacts: (...args: unknown[]) => mockMatchContacts(...args),
14
- }))
15
-
16
- const mockFetchCatalog = jest.fn()
17
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/catalogLookup', () => ({
18
- fetchCatalogProductsForExtraction: (...args: unknown[]) => mockFetchCatalog(...args),
19
- }))
20
-
21
- const mockValidatePrices = jest.fn()
22
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/priceValidator', () => ({
23
- validatePrices: (...args: unknown[]) => mockValidatePrices(...args),
24
- }))
25
-
26
- const mockFindOneWithDecryption = jest.fn()
27
- jest.mock('@open-mercato/shared/lib/encryption/find', () => ({
28
- findOneWithDecryption: (...args: unknown[]) => mockFindOneWithDecryption(...args),
29
- }))
30
-
31
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/extractionPrompt', () => ({
32
- buildExtractionSystemPrompt: jest.fn(() => 'mock system prompt'),
33
- buildExtractionUserPrompt: jest.fn(() => 'mock user prompt'),
34
- }))
35
-
36
- jest.mock('@open-mercato/core/modules/inbox_ops/lib/constants', () => ({
37
- REQUIRED_FEATURES_MAP: {
38
- create_order: 'sales.orders.manage',
39
- create_quote: 'sales.quotes.manage',
40
- update_order: 'sales.orders.manage',
41
- update_shipment: 'sales.shipments.manage',
42
- create_contact: 'customers.people.manage',
43
- link_contact: 'customers.people.manage',
44
- log_activity: 'customers.activities.manage',
45
- draft_reply: 'inbox_ops.replies.send',
46
- },
47
- }))
48
-
49
- const mockEmitInboxOpsEvent = jest.fn()
50
- jest.mock('@open-mercato/core/modules/inbox_ops/events', () => ({
51
- emitInboxOpsEvent: (...args: unknown[]) => mockEmitInboxOpsEvent(...args),
52
- }))
53
-
54
- const mockNativeUpdate = jest.fn()
55
- const mockFindOne = jest.fn()
56
- const mockFlush = jest.fn()
57
- const mockCreate = jest.fn()
58
- const mockPersist = jest.fn()
59
-
60
- const mockEm = {
61
- fork: jest.fn(),
62
- nativeUpdate: mockNativeUpdate,
63
- findOne: mockFindOne,
64
- find: jest.fn(),
65
- create: mockCreate,
66
- persist: mockPersist,
67
- flush: mockFlush,
68
- }
69
-
70
- const MockSalesOrder = class {} as any
71
- const MockSalesChannel = class {} as any
72
- const MockCatalogProduct = class {} as any
73
- const MockCatalogProductPrice = class {} as any
74
- const MockCustomerEntity = class {} as any
75
-
76
- const mockCtx = {
77
- resolve: jest.fn((token: string) => {
78
- if (token === 'em') return mockEm
79
- if (token === 'SalesOrder') return MockSalesOrder
80
- if (token === 'SalesChannel') return MockSalesChannel
81
- if (token === 'CatalogProduct') return MockCatalogProduct
82
- if (token === 'CatalogProductPrice') return MockCatalogProductPrice
83
- if (token === 'CustomerEntity') return MockCustomerEntity
84
- throw new Error(`Unknown DI token: ${token}`)
85
- }),
86
- }
87
-
88
- const VALID_ORDER_PAYLOAD = JSON.stringify({
89
- customerName: 'John Doe',
90
- channelId: '123e4567-e89b-4d56-a456-426614174000',
91
- currencyCode: 'EUR',
92
- lineItems: [{ productName: 'Widget', quantity: '10' }],
93
- })
94
-
95
- function makeExtractionResult(overrides?: Record<string, unknown>) {
96
- return {
97
- summary: 'Customer wants to order 10 widgets',
98
- participants: [
99
- { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
100
- ],
101
- proposedActions: [
102
- {
103
- actionType: 'create_order',
104
- description: 'Create order for 10 widgets',
105
- confidence: 0.9,
106
- payloadJson: VALID_ORDER_PAYLOAD,
107
- },
108
- ],
109
- discrepancies: [],
110
- draftReplies: [],
111
- confidence: 0.9,
112
- detectedLanguage: 'en',
113
- possiblyIncomplete: false,
114
- ...overrides,
115
- }
116
- }
117
-
118
- function makeEmail(overrides?: Record<string, unknown>) {
119
- return {
120
- id: 'email-1',
121
- status: 'processing',
122
- rawText: 'Hello, I would like to order 10 widgets. Best regards, John',
123
- rawHtml: null,
124
- cleanedText: 'Hello, I would like to order 10 widgets.',
125
- subject: 'Order request',
126
- tenantId: 'tenant-1',
127
- organizationId: 'org-1',
128
- detectedLanguage: null,
129
- forwardedByAddress: 'john@example.com',
130
- forwardedByName: 'John Doe',
131
- replyTo: null,
132
- messageId: '<msg-001@example.com>',
133
- emailReferences: null,
134
- threadMessages: [
135
- {
136
- from: { name: 'John Doe', email: 'john@example.com' },
137
- to: [{ name: 'Ops', email: 'ops@example.com' }],
138
- date: new Date().toISOString(),
139
- body: 'Hello, I would like to order 10 widgets.',
140
- contentType: 'text',
141
- isForwarded: false,
142
- },
143
- ],
144
- ...overrides,
145
- }
146
- }
147
-
148
- const basePayload = {
149
- emailId: 'email-1',
150
- tenantId: 'tenant-1',
151
- organizationId: 'org-1',
152
- forwardedByAddress: 'john@example.com',
153
- subject: 'Order request',
154
- }
155
-
156
- describe('extractionWorker', () => {
157
- beforeEach(() => {
158
- jest.clearAllMocks()
159
- mockEm.fork.mockReturnValue(mockEm)
160
- mockFlush.mockResolvedValue(undefined)
161
- mockEmitInboxOpsEvent.mockResolvedValue(undefined)
162
- mockCreate.mockImplementation((_entity: unknown, data: Record<string, unknown>) => ({ ...data }))
163
- mockMatchContacts.mockResolvedValue([])
164
- mockFetchCatalog.mockResolvedValue([])
165
- mockValidatePrices.mockResolvedValue([])
166
- mockFindOneWithDecryption.mockResolvedValue(null)
167
- })
168
-
169
- describe('race condition handling', () => {
170
- it('exits silently when another worker already claimed the email (nativeUpdate returns 0)', async () => {
171
- mockNativeUpdate.mockResolvedValue(0)
172
-
173
- await handle(basePayload, mockCtx as any)
174
-
175
- expect(mockNativeUpdate).toHaveBeenCalledWith(
176
- InboxEmail,
177
- { id: 'email-1', status: 'received' },
178
- { status: 'processing' },
179
- )
180
- expect(mockFindOneWithDecryption).not.toHaveBeenCalled()
181
- expect(mockFlush).not.toHaveBeenCalled()
182
- })
183
-
184
- it('proceeds when nativeUpdate claims the email (returns 1)', async () => {
185
- mockNativeUpdate.mockResolvedValue(1)
186
- mockFindOneWithDecryption.mockResolvedValueOnce({
187
- id: 'email-1',
188
- status: 'processing',
189
- rawText: '',
190
- rawHtml: null,
191
- cleanedText: '',
192
- tenantId: 'tenant-1',
193
- organizationId: 'org-1',
194
- })
195
-
196
- await handle(basePayload, mockCtx as any)
197
-
198
- expect(mockNativeUpdate).toHaveBeenCalledWith(
199
- InboxEmail,
200
- { id: 'email-1', status: 'received' },
201
- { status: 'processing' },
202
- )
203
- expect(mockFindOneWithDecryption).toHaveBeenCalledWith(
204
- mockEm,
205
- InboxEmail,
206
- { id: 'email-1' },
207
- undefined,
208
- expect.objectContaining({ tenantId: 'tenant-1' }),
209
- )
210
- })
211
-
212
- it('exits when email not found after claiming', async () => {
213
- mockNativeUpdate.mockResolvedValue(1)
214
- mockFindOneWithDecryption.mockResolvedValueOnce(null)
215
-
216
- const consoleSpy = jest.spyOn(console, 'error').mockImplementation()
217
-
218
- await handle(
219
- { ...basePayload, emailId: 'email-missing' },
220
- mockCtx as any,
221
- )
222
-
223
- expect(consoleSpy).toHaveBeenCalledWith(
224
- expect.stringContaining('Email not found: email-missing'),
225
- )
226
- consoleSpy.mockRestore()
227
- })
228
- })
229
-
230
- describe('full pipeline — happy path', () => {
231
- it('creates proposal with actions and updates email status to processed', async () => {
232
- mockNativeUpdate.mockResolvedValue(1)
233
- const email = makeEmail()
234
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
235
-
236
- mockMatchContacts.mockResolvedValueOnce([
237
- {
238
- participant: { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
239
- match: { contactId: 'contact-1', contactType: 'person', confidence: 0.95 },
240
- },
241
- ])
242
-
243
- mockRunExtraction.mockResolvedValueOnce({
244
- object: makeExtractionResult(),
245
- totalTokens: 150,
246
- modelWithProvider: 'anthropic:test-model',
247
- })
248
-
249
- await handle(basePayload, mockCtx as any)
250
-
251
- expect(mockCreate).toHaveBeenCalledWith(
252
- InboxProposal,
253
- expect.objectContaining({
254
- summary: 'Customer wants to order 10 widgets',
255
- confidence: '0.90',
256
- status: 'pending',
257
- tenantId: 'tenant-1',
258
- organizationId: 'org-1',
259
- }),
260
- )
261
-
262
- expect(mockCreate).toHaveBeenCalledWith(
263
- InboxProposalAction,
264
- expect.objectContaining({
265
- actionType: 'create_order',
266
- description: 'Create order for 10 widgets',
267
- status: 'pending',
268
- }),
269
- )
270
-
271
- expect(email.status).toBe('processed')
272
-
273
- expect(mockEmitInboxOpsEvent).toHaveBeenCalledWith(
274
- 'inbox_ops.email.processed',
275
- expect.objectContaining({ emailId: 'email-1' }),
276
- )
277
- expect(mockEmitInboxOpsEvent).toHaveBeenCalledWith(
278
- 'inbox_ops.proposal.created',
279
- expect.objectContaining({
280
- emailId: 'email-1',
281
- actionCount: 3,
282
- }),
283
- )
284
- })
285
- })
286
-
287
- describe('LLM failure', () => {
288
- it('sets email status to failed and emits email.failed event', async () => {
289
- mockNativeUpdate.mockResolvedValue(1)
290
- const email = makeEmail()
291
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
292
-
293
- mockRunExtraction.mockRejectedValueOnce(new Error('API rate limit exceeded'))
294
-
295
- await handle(basePayload, mockCtx as any)
296
-
297
- expect(email.status).toBe('failed')
298
- expect(email.processingError).toContain('API rate limit exceeded')
299
- expect(mockFlush).toHaveBeenCalled()
300
- expect(mockEmitInboxOpsEvent).toHaveBeenCalledWith(
301
- 'inbox_ops.email.failed',
302
- expect.objectContaining({
303
- emailId: 'email-1',
304
- error: expect.stringContaining('API rate limit exceeded'),
305
- }),
306
- )
307
- })
308
- })
309
-
310
- describe('low confidence', () => {
311
- it('sets email status to needs_review when confidence is below threshold', async () => {
312
- mockNativeUpdate.mockResolvedValue(1)
313
- const email = makeEmail()
314
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
315
-
316
- mockRunExtraction.mockResolvedValueOnce({
317
- object: makeExtractionResult({ confidence: 0.3 }),
318
- totalTokens: 100,
319
- modelWithProvider: 'anthropic:test-model',
320
- })
321
-
322
- await handle(basePayload, mockCtx as any)
323
-
324
- expect(email.status).toBe('needs_review')
325
- })
326
- })
327
-
328
- describe('empty text', () => {
329
- it('sets email status to failed when email has no text content', async () => {
330
- mockNativeUpdate.mockResolvedValue(1)
331
- const email = makeEmail({ rawText: '', rawHtml: null, cleanedText: '' })
332
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
333
-
334
- await handle(basePayload, mockCtx as any)
335
-
336
- expect(email.status).toBe('failed')
337
- expect(email.processingError).toContain('No text content')
338
- expect(mockRunExtraction).not.toHaveBeenCalled()
339
- })
340
- })
341
-
342
- describe('duplicate order detection', () => {
343
- it('creates duplicate_order discrepancy when customerReference matches existing order', async () => {
344
- mockNativeUpdate.mockResolvedValue(1)
345
- const email = makeEmail()
346
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
347
- mockFindOneWithDecryption.mockResolvedValueOnce(null) // InboxSettings
348
-
349
- const payloadWithRef = JSON.stringify({
350
- customerName: 'John Doe',
351
- channelId: '123e4567-e89b-4d56-a456-426614174000',
352
- currencyCode: 'EUR',
353
- customerReference: 'PO-2026-001',
354
- lineItems: [{ productName: 'Widget', quantity: '10' }],
355
- })
356
-
357
- mockRunExtraction.mockResolvedValueOnce({
358
- object: makeExtractionResult({
359
- proposedActions: [
360
- {
361
- actionType: 'create_order',
362
- description: 'Create order for 10 widgets',
363
- confidence: 0.9,
364
- payloadJson: payloadWithRef,
365
- },
366
- ],
367
- }),
368
- totalTokens: 150,
369
- modelWithProvider: 'anthropic:test-model',
370
- })
371
-
372
- mockFindOneWithDecryption.mockResolvedValueOnce({
373
- id: 'existing-order-1',
374
- orderNumber: 'ORD-500',
375
- customerReference: 'PO-2026-001',
376
- })
377
-
378
- await handle(basePayload, mockCtx as any)
379
-
380
- expect(mockCreate).toHaveBeenCalledWith(
381
- InboxDiscrepancy,
382
- expect.objectContaining({
383
- type: 'duplicate_order',
384
- severity: 'error',
385
- description: expect.stringContaining('PO-2026-001'),
386
- }),
387
- )
388
- })
389
- })
390
-
391
- describe('unknown contact discrepancy', () => {
392
- it('creates unknown_contact discrepancy when no contact match found', async () => {
393
- mockNativeUpdate.mockResolvedValue(1)
394
- const email = makeEmail()
395
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
396
-
397
- mockMatchContacts.mockResolvedValueOnce([
398
- {
399
- participant: { name: 'Unknown Person', email: 'unknown@example.com', role: 'buyer' },
400
- match: null,
401
- },
402
- ])
403
-
404
- mockRunExtraction.mockResolvedValueOnce({
405
- object: makeExtractionResult({
406
- participants: [
407
- { name: 'Unknown Person', email: 'unknown@example.com', role: 'buyer' },
408
- ],
409
- }),
410
- totalTokens: 100,
411
- modelWithProvider: 'anthropic:test-model',
412
- })
413
-
414
- await handle(basePayload, mockCtx as any)
415
-
416
- expect(mockCreate).toHaveBeenCalledWith(
417
- InboxDiscrepancy,
418
- expect.objectContaining({
419
- type: 'unknown_contact',
420
- severity: 'warning',
421
- description: expect.stringContaining('unknown@example.com'),
422
- foundValue: 'unknown@example.com',
423
- }),
424
- )
425
- })
426
- })
427
-
428
- describe('discrepancy action association', () => {
429
- it('associates product_not_found discrepancy with the order action, not auto-generated contact actions', async () => {
430
- mockNativeUpdate.mockResolvedValue(1)
431
- const email = makeEmail()
432
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
433
-
434
- // Unmatched contact → triggers auto create_contact action (prepended before order)
435
- mockMatchContacts.mockResolvedValueOnce([
436
- {
437
- participant: { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
438
- match: null,
439
- },
440
- ])
441
-
442
- // Catalog has no products → line item won't match → product_not_found discrepancy
443
- mockFetchCatalog.mockResolvedValueOnce([])
444
-
445
- mockRunExtraction.mockResolvedValueOnce({
446
- object: makeExtractionResult({
447
- participants: [
448
- { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
449
- ],
450
- discrepancies: [
451
- {
452
- actionIndex: 0,
453
- type: 'currency_mismatch',
454
- severity: 'warning',
455
- description: 'EUR vs USD',
456
- },
457
- ],
458
- }),
459
- totalTokens: 150,
460
- modelWithProvider: 'anthropic:test-model',
461
- })
462
-
463
- await handle(basePayload, mockCtx as any)
464
-
465
- // Collect all InboxDiscrepancy create calls
466
- const discrepancyCalls = mockCreate.mock.calls
467
- .filter(([entity]: [unknown]) => entity === InboxDiscrepancy)
468
- .map(([, data]: [unknown, Record<string, unknown>]) => data)
469
-
470
- // product_not_found should point to the order action, not the create_contact
471
- const productDiscrepancy = discrepancyCalls.find(
472
- (d: Record<string, unknown>) => d.type === 'product_not_found',
473
- )
474
- expect(productDiscrepancy).toBeDefined()
475
-
476
- // currency_mismatch from LLM (actionIndex: 0) should also point to the order, not contact
477
- const currencyDiscrepancy = discrepancyCalls.find(
478
- (d: Record<string, unknown>) => d.type === 'currency_mismatch',
479
- )
480
- expect(currencyDiscrepancy).toBeDefined()
481
-
482
- // The order action creates with actionType 'create_order'
483
- const orderActionCall = mockCreate.mock.calls.find(
484
- ([entity, data]: [unknown, Record<string, unknown>]) =>
485
- entity === InboxProposalAction && data.actionType === 'create_order',
486
- )
487
- expect(orderActionCall).toBeDefined()
488
- const orderActionId = orderActionCall[1].id
489
-
490
- // Both discrepancies should reference the order action's ID
491
- if (productDiscrepancy) {
492
- expect(productDiscrepancy.actionId).toBe(orderActionId)
493
- }
494
- if (currencyDiscrepancy) {
495
- expect(currencyDiscrepancy.actionId).toBe(orderActionId)
496
- }
497
- })
498
- })
499
-
500
- describe('LLM-discovered participant create_contact', () => {
501
- it('generates create_contact action for unmatched participant discovered by LLM but not in email headers', async () => {
502
- mockNativeUpdate.mockResolvedValue(1)
503
- const email = makeEmail()
504
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
505
-
506
- // Header-based contact matching only finds John (the sender)
507
- mockMatchContacts.mockResolvedValueOnce([
508
- {
509
- participant: { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
510
- match: { contactId: 'contact-1', contactType: 'person', confidence: 1.0 },
511
- },
512
- ])
513
-
514
- // LLM discovers an additional participant (Arjun) from the email body
515
- mockRunExtraction.mockResolvedValueOnce({
516
- object: makeExtractionResult({
517
- participants: [
518
- { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
519
- { name: 'Arjun Patel', email: 'arjun@example.com', role: 'buyer' },
520
- ],
521
- proposedActions: [
522
- {
523
- actionType: 'create_order',
524
- description: 'Create order',
525
- confidence: 0.9,
526
- payloadJson: VALID_ORDER_PAYLOAD,
527
- },
528
- ],
529
- }),
530
- totalTokens: 150,
531
- modelWithProvider: 'anthropic:test-model',
532
- })
533
-
534
- await handle(basePayload, mockCtx as any)
535
-
536
- // Should create a create_contact action for Arjun (LLM-discovered, not in headers)
537
- const createContactCalls = mockCreate.mock.calls
538
- .filter(([entity, data]: [unknown, Record<string, unknown>]) =>
539
- entity === InboxProposalAction && data.actionType === 'create_contact',
540
- )
541
- .map(([, data]: [unknown, Record<string, unknown>]) => data)
542
-
543
- const arjunAction = createContactCalls.find((d: Record<string, unknown>) => {
544
- const payload = d.payload as Record<string, unknown>
545
- return payload?.email === 'arjun@example.com'
546
- })
547
-
548
- expect(arjunAction).toBeDefined()
549
- expect((arjunAction!.payload as Record<string, unknown>).name).toBe('Arjun Patel')
550
-
551
- // Should also create an unknown_contact discrepancy for Arjun
552
- const discrepancyCalls = mockCreate.mock.calls
553
- .filter(([entity]: [unknown]) => entity === InboxDiscrepancy)
554
- .map(([, data]: [unknown, Record<string, unknown>]) => data)
555
-
556
- const arjunDiscrepancy = discrepancyCalls.find(
557
- (d: Record<string, unknown>) =>
558
- d.type === 'unknown_contact' && d.foundValue === 'arjun@example.com',
559
- )
560
- expect(arjunDiscrepancy).toBeDefined()
561
- })
562
- })
563
-
564
- describe('partial forward detection', () => {
565
- it('marks proposal as possiblyIncomplete for RE: subject with single thread message', async () => {
566
- mockNativeUpdate.mockResolvedValue(1)
567
- const email = makeEmail({
568
- subject: 'RE: Order confirmation',
569
- threadMessages: [
570
- {
571
- from: { name: 'John', email: 'john@example.com' },
572
- to: [{ name: 'Ops', email: 'ops@example.com' }],
573
- date: new Date().toISOString(),
574
- body: 'Partial content',
575
- contentType: 'text',
576
- isForwarded: false,
577
- },
578
- ],
579
- })
580
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
581
-
582
- mockRunExtraction.mockResolvedValueOnce({
583
- object: makeExtractionResult({ possiblyIncomplete: false }),
584
- totalTokens: 100,
585
- modelWithProvider: 'anthropic:test-model',
586
- })
587
-
588
- await handle(basePayload, mockCtx as any)
589
-
590
- expect(mockCreate).toHaveBeenCalledWith(
591
- InboxProposal,
592
- expect.objectContaining({
593
- possiblyIncomplete: true,
594
- }),
595
- )
596
- })
597
- })
598
-
599
- describe('hallucinated productId clearing', () => {
600
- it('generates create_product action when LLM hallucinates a productId not in catalog', async () => {
601
- mockNativeUpdate.mockResolvedValue(1)
602
- const email = makeEmail()
603
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
604
-
605
- // Contact matches: John is known
606
- mockMatchContacts.mockResolvedValueOnce([
607
- {
608
- participant: { name: 'John Doe', email: 'john@example.com', role: 'buyer' },
609
- match: { contactId: 'contact-1', contactType: 'person', confidence: 1.0 },
610
- },
611
- ])
612
-
613
- // Catalog has one product
614
- const realProductId = '11111111-1111-1111-1111-111111111111'
615
- mockFetchCatalog.mockResolvedValueOnce([
616
- { id: realProductId, name: 'Widget', sku: 'WDG-001' },
617
- ])
618
-
619
- // LLM returns an order with a hallucinated productId for "Silk Scarf"
620
- const hallucinatedProductId = '99999999-9999-9999-9999-999999999999'
621
- mockRunExtraction.mockResolvedValueOnce({
622
- object: makeExtractionResult({
623
- proposedActions: [
624
- {
625
- actionType: 'create_order',
626
- description: 'Create order',
627
- confidence: 0.9,
628
- payloadJson: JSON.stringify({
629
- customerName: 'John Doe',
630
- channelId: '123e4567-e89b-4d56-a456-426614174000',
631
- currencyCode: 'EUR',
632
- lineItems: [
633
- { productName: 'Widget', quantity: '5', productId: realProductId },
634
- { productName: 'Silk Scarf', quantity: '2', productId: hallucinatedProductId },
635
- ],
636
- }),
637
- },
638
- ],
639
- discrepancies: [
640
- {
641
- actionIndex: 0,
642
- type: 'product_not_found',
643
- severity: 'error',
644
- description: 'Product "Silk Scarf" not found',
645
- foundValue: 'Silk Scarf',
646
- },
647
- ],
648
- }),
649
- totalTokens: 200,
650
- modelWithProvider: 'anthropic:test-model',
651
- })
652
-
653
- await handle(basePayload, mockCtx as any)
654
-
655
- // Should generate a create_product action for Silk Scarf
656
- const createProductCalls = mockCreate.mock.calls
657
- .filter(([entity, data]: [unknown, Record<string, unknown>]) =>
658
- entity === InboxProposalAction && data.actionType === 'create_product',
659
- )
660
- .map(([, data]: [unknown, Record<string, unknown>]) => data)
661
-
662
- expect(createProductCalls.length).toBe(1)
663
- const productPayload = createProductCalls[0].payload as Record<string, unknown>
664
- expect(productPayload.title).toBe('Silk Scarf')
665
-
666
- // Should have a product_not_found discrepancy from step 6c (auto-generated)
667
- const discrepancyCalls = mockCreate.mock.calls
668
- .filter(([entity]: [unknown]) => entity === InboxDiscrepancy)
669
- .map(([, data]: [unknown, Record<string, unknown>]) => data)
670
-
671
- const productNotFound = discrepancyCalls.filter(
672
- (d: Record<string, unknown>) => d.type === 'product_not_found',
673
- )
674
- expect(productNotFound.length).toBeGreaterThanOrEqual(1)
675
- })
676
- })
677
-
678
- describe('draft replies', () => {
679
- it('creates draft_reply actions from extraction output', async () => {
680
- mockNativeUpdate.mockResolvedValue(1)
681
- const email = makeEmail()
682
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
683
-
684
- mockRunExtraction.mockResolvedValueOnce({
685
- object: makeExtractionResult({
686
- proposedActions: [],
687
- draftReplies: [
688
- {
689
- to: 'john@example.com',
690
- toName: 'John Doe',
691
- subject: 'Re: Order request',
692
- body: 'Thank you for your inquiry. We can fulfill your order.',
693
- },
694
- ],
695
- }),
696
- totalTokens: 100,
697
- modelWithProvider: 'anthropic:test-model',
698
- })
699
-
700
- await handle(basePayload, mockCtx as any)
701
-
702
- expect(mockCreate).toHaveBeenCalledWith(
703
- InboxProposalAction,
704
- expect.objectContaining({
705
- actionType: 'draft_reply',
706
- payload: expect.objectContaining({
707
- to: 'john@example.com',
708
- subject: 'Re: Order request',
709
- }),
710
- requiredFeature: 'inbox_ops.replies.send',
711
- }),
712
- )
713
- })
714
- })
715
-
716
- describe('working language', () => {
717
- it('defaults workingLanguage to "en" when no InboxSettings found', async () => {
718
- mockNativeUpdate.mockResolvedValue(1)
719
- const email = makeEmail()
720
- // First call returns email, second (InboxSettings) returns null
721
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
722
- mockFindOneWithDecryption.mockResolvedValueOnce(null)
723
-
724
- mockMatchContacts.mockResolvedValueOnce([])
725
- mockRunExtraction.mockResolvedValueOnce({
726
- object: makeExtractionResult(),
727
- totalTokens: 100,
728
- modelWithProvider: 'anthropic:test-model',
729
- })
730
-
731
- const { buildExtractionSystemPrompt } = require('@open-mercato/core/modules/inbox_ops/lib/extractionPrompt')
732
-
733
- await handle(basePayload, mockCtx as any)
734
-
735
- expect(buildExtractionSystemPrompt).toHaveBeenCalledWith(
736
- expect.anything(),
737
- expect.anything(),
738
- undefined,
739
- 'en',
740
- )
741
-
742
- expect(mockCreate).toHaveBeenCalledWith(
743
- InboxProposal,
744
- expect.objectContaining({ workingLanguage: 'en' }),
745
- )
746
- })
747
-
748
- it('passes workingLanguage from InboxSettings to prompt and proposal', async () => {
749
- mockNativeUpdate.mockResolvedValue(1)
750
- const email = makeEmail()
751
- // First call returns email, second returns settings with German
752
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
753
- mockFindOneWithDecryption.mockResolvedValueOnce({ workingLanguage: 'de' })
754
-
755
- mockMatchContacts.mockResolvedValueOnce([])
756
- mockRunExtraction.mockResolvedValueOnce({
757
- object: makeExtractionResult(),
758
- totalTokens: 100,
759
- modelWithProvider: 'anthropic:test-model',
760
- })
761
-
762
- const { buildExtractionSystemPrompt } = require('@open-mercato/core/modules/inbox_ops/lib/extractionPrompt')
763
-
764
- await handle(basePayload, mockCtx as any)
765
-
766
- expect(buildExtractionSystemPrompt).toHaveBeenCalledWith(
767
- expect.anything(),
768
- expect.anything(),
769
- undefined,
770
- 'de',
771
- )
772
-
773
- expect(mockCreate).toHaveBeenCalledWith(
774
- InboxProposal,
775
- expect.objectContaining({ workingLanguage: 'de' }),
776
- )
777
- })
778
-
779
- it('queries InboxSettings with correct scope filters', async () => {
780
- mockNativeUpdate.mockResolvedValue(1)
781
- const email = makeEmail()
782
- mockFindOneWithDecryption.mockResolvedValueOnce(email)
783
- mockFindOneWithDecryption.mockResolvedValueOnce(null)
784
-
785
- mockMatchContacts.mockResolvedValueOnce([])
786
- mockRunExtraction.mockResolvedValueOnce({
787
- object: makeExtractionResult(),
788
- totalTokens: 100,
789
- modelWithProvider: 'anthropic:test-model',
790
- })
791
-
792
- await handle(basePayload, mockCtx as any)
793
-
794
- expect(mockFindOneWithDecryption).toHaveBeenCalledWith(
795
- mockEm,
796
- InboxSettings,
797
- { organizationId: 'org-1', tenantId: 'tenant-1', deletedAt: null },
798
- undefined,
799
- { organizationId: 'org-1', tenantId: 'tenant-1' },
800
- )
801
- })
802
- })
803
- })