@getjones/test-infra 4.4.8 → 4.4.10

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 (226) hide show
  1. package/package.json +30 -30
  2. package/src/common/commonFlows/auth/auth.js +40 -40
  3. package/src/common/commonFlows/index.js +4 -4
  4. package/src/common/commonFlows/records/records.js +195 -195
  5. package/src/common/consts/accountSettings.js +14 -14
  6. package/src/common/consts/activationStatuses.js +6 -6
  7. package/src/common/consts/autocomplete.js +9 -9
  8. package/src/common/consts/constantsForRecordsSortingAndFilters.js +40 -40
  9. package/src/common/consts/dashboardCharts.js +18 -18
  10. package/src/common/consts/ocrStatuses.js +6 -6
  11. package/src/common/consts/projectSettings.js +21 -21
  12. package/src/common/consts/recordTypes.js +5 -5
  13. package/src/common/consts/s3FileTypes.js +13 -13
  14. package/src/common/consts/userTypes.js +8 -8
  15. package/src/common/errorCodes.js +3 -3
  16. package/src/common/httpResponseStatusCodes.json +11 -11
  17. package/src/common/httpResponseTypes.json +2 -2
  18. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  19. package/src/common/requests/cookieAuth/requests.js +40 -40
  20. package/src/common/requests/internalAuth/requests.js +48 -48
  21. package/src/common/requests/requestHandlers.js +80 -80
  22. package/src/common/utils/complianceUtil.js +114 -114
  23. package/src/common/utils/configsUtil.js +22 -22
  24. package/src/common/utils/dataTypeUtils.js +41 -41
  25. package/src/common/utils/numberUtils.js +22 -22
  26. package/src/common/utils/objectUtils.js +7 -7
  27. package/src/common/utils/timeUtils.js +177 -177
  28. package/src/common/validations/errorValidation.js +16 -16
  29. package/src/common/validations/typeValidations.js +36 -36
  30. package/src/defaults/configs/auditConfigs.js +124 -124
  31. package/src/defaults/configs/coverage.js +227 -227
  32. package/src/defaults/configs/polices.js +75 -75
  33. package/src/defaults/configs/requirement.js +32 -32
  34. package/src/defaults/index.js +6 -6
  35. package/src/env.js +57 -57
  36. package/src/factory/globalRecord/globalRecord.js +43 -43
  37. package/src/factory/index.js +8 -8
  38. package/src/factory/records/records.js +231 -231
  39. package/src/factory/users/users.js +77 -77
  40. package/src/index.js +95 -95
  41. package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +50 -50
  42. package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +182 -182
  43. package/src/saas/internal-api/accountDirectory/index.js +4 -4
  44. package/src/saas/internal-api/accountDirectory/models/accountDirectory.model.js +40 -40
  45. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  46. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  47. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  48. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  49. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  50. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  51. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  52. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  53. package/src/saas/internal-api/accounts/consts/consts.js +8 -8
  54. package/src/saas/internal-api/accounts/index.js +22 -22
  55. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  56. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +42 -42
  57. package/src/saas/internal-api/accounts/utils/utils.js +60 -59
  58. package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
  59. package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
  60. package/src/saas/internal-api/agreement/consts/consts.js +10 -10
  61. package/src/saas/internal-api/agreement/index.js +12 -12
  62. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  63. package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
  64. package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
  65. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  66. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  67. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  68. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  69. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  70. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  71. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  72. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  73. package/src/saas/internal-api/auditNotes/index.js +4 -4
  74. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  75. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  76. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  77. package/src/saas/internal-api/auth/index.js +3 -3
  78. package/src/saas/internal-api/coi/api/coi.api.js +45 -45
  79. package/src/saas/internal-api/coi/api/coi.service.js +39 -39
  80. package/src/saas/internal-api/coi/consts/hashes.js +4 -4
  81. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  82. package/src/saas/internal-api/coi/index.js +14 -14
  83. package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
  84. package/src/saas/internal-api/coi/models/submit.coi.model.js +19 -19
  85. package/src/saas/internal-api/coi/utils/utils.js +117 -117
  86. package/src/saas/internal-api/compliance/api/audit/audit.api.js +115 -115
  87. package/src/saas/internal-api/compliance/api/audit/audit.service.js +300 -300
  88. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  89. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  90. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  91. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  92. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +38 -38
  93. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +182 -182
  94. package/src/saas/internal-api/compliance/consts/audit.js +110 -110
  95. package/src/saas/internal-api/compliance/index.js +33 -33
  96. package/src/saas/internal-api/compliance/models/audit/audit.model.js +96 -96
  97. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  98. package/src/saas/internal-api/compliance/utils/auditUtil.js +254 -254
  99. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  100. package/src/saas/internal-api/contractors/api/contractors.api.js +203 -203
  101. package/src/saas/internal-api/contractors/api/contractors.service.js +342 -342
  102. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  103. package/src/saas/internal-api/contractors/index.js +8 -8
  104. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  105. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +62 -62
  106. package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
  107. package/src/saas/internal-api/contractors/models/subscription.contractor.model.js +13 -13
  108. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  109. package/src/saas/internal-api/contractors/utils.js +25 -25
  110. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  111. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  112. package/src/saas/internal-api/dashboard/index.js +5 -5
  113. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  114. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  115. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +156 -156
  116. package/src/saas/internal-api/dbEmails/consts/consts.js +55 -55
  117. package/src/saas/internal-api/dbEmails/index.js +6 -6
  118. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  119. package/src/saas/internal-api/dbEmails/utils/util.js +87 -87
  120. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  121. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  122. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  123. package/src/saas/internal-api/globalRecord/api/global.record.api.js +101 -101
  124. package/src/saas/internal-api/globalRecord/api/global.record.service.js +117 -117
  125. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  126. package/src/saas/internal-api/globalRecord/index.js +6 -6
  127. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  128. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  129. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  130. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  131. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  132. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  133. package/src/saas/internal-api/projects/api/core/projects.service.js +70 -70
  134. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  135. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  136. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  137. package/src/saas/internal-api/projects/index.js +24 -24
  138. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  139. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  140. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +40 -40
  141. package/src/saas/internal-api/projects/utils/utils.js +155 -155
  142. package/src/saas/internal-api/recordHub/api/record.hub.api.js +14 -14
  143. package/src/saas/internal-api/recordHub/api/record.hub.service.js +21 -21
  144. package/src/saas/internal-api/recordHub/index.js +3 -3
  145. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  146. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  147. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  148. package/src/saas/internal-api/recordNotes/index.js +3 -3
  149. package/src/saas/internal-api/reports/api/reports.api.js +62 -62
  150. package/src/saas/internal-api/reports/api/reports.service.js +79 -79
  151. package/src/saas/internal-api/reports/consts/consts.js +74 -74
  152. package/src/saas/internal-api/reports/index.js +15 -15
  153. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  154. package/src/saas/internal-api/requests/api/requests.api.js +120 -120
  155. package/src/saas/internal-api/requests/api/requests.service.js +272 -272
  156. package/src/saas/internal-api/requests/index.js +20 -20
  157. package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
  158. package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
  159. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  160. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  161. package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
  162. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  163. package/src/saas/internal-api/requests/utils.js +8 -8
  164. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  165. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  166. package/src/saas/internal-api/requestsTable/index.js +3 -3
  167. package/src/saas/internal-api/requirements/api/requirements.api.js +57 -57
  168. package/src/saas/internal-api/requirements/api/requirements.service.js +177 -177
  169. package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
  170. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  171. package/src/saas/internal-api/requirements/index.js +10 -10
  172. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  173. package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
  174. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  175. package/src/saas/internal-api/requirements/utils/utils.js +129 -129
  176. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  177. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  178. package/src/saas/internal-api/serviceArea/index.js +4 -4
  179. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  180. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  181. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  182. package/src/saas/internal-api/tabs/index.js +3 -3
  183. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  184. package/src/saas/internal-api/thread-scheduler/runner.js +55 -55
  185. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +49 -49
  186. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +117 -117
  187. package/src/saas/internal-api/uploadFiles/consts.js +31 -31
  188. package/src/saas/internal-api/uploadFiles/index.js +11 -11
  189. package/src/saas/internal-api/uploadFiles/models/create.policy.file.model.js +11 -11
  190. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
  191. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +108 -108
  192. package/src/saas/internal-api/users/api/users.api.js +127 -121
  193. package/src/saas/internal-api/users/api/users.service.js +225 -214
  194. package/src/saas/internal-api/users/index.js +16 -16
  195. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  196. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  197. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  198. package/src/saas/internal-api/users/models/users.model.js +41 -41
  199. package/src/saas/internal-api/users/utils/util.js +39 -39
  200. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  201. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  202. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  203. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  204. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  205. package/src/saas/openapi/coi/coi.api.js +30 -30
  206. package/src/saas/openapi/coi/coi.service.js +43 -43
  207. package/src/saas/openapi/projects/projects.api.js +83 -83
  208. package/src/saas/openapi/projects/projects.service.js +64 -64
  209. package/src/saas/openapi/requests/index.js +7 -7
  210. package/src/saas/openapi/requests/models/invite.request.model.js +40 -40
  211. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  212. package/src/saas/openapi/requests/requests.api.js +87 -87
  213. package/src/saas/openapi/requests/requests.service.js +81 -81
  214. package/src/saas/openapi/requirements/index.js +6 -6
  215. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  216. package/src/saas/openapi/requirements/requirements.api.js +41 -41
  217. package/src/saas/openapi/requirements/requirements.service.js +49 -49
  218. package/src/saas/openapi/tabs/index.js +6 -6
  219. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  220. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  221. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  222. package/src/saas/openapi/users/user.model.js +10 -10
  223. package/src/saas/openapi/users/users.api.js +33 -33
  224. package/src/saas/openapi/users/users.service.js +41 -41
  225. package/tests/env.test.js +40 -40
  226. package/tests/validation.test.js +83 -83
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@getjones/test-infra",
3
- "version": "4.4.8",
4
- "description": "Providing internal and openapi interface",
5
- "main": "src/index.js",
6
- "scripts": {
7
- "test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail",
8
- "eslint-fix": "eslint \"./src/**/*.js\" --fix"
9
- },
10
- "author": "",
11
- "license": "ISC",
12
- "dependencies": {
13
- "axios": "^0.21.1",
14
- "axios-file": "^1.0.17",
15
- "chai": "^4.3.4",
16
- "dotenv": "^8.2.0",
17
- "enum": "^3.0.4",
18
- "form-data": "^4.0.0",
19
- "mocha": "^8.3.2"
20
- },
21
- "devDependencies": {
22
- "babel-eslint": "^10.0.3",
23
- "eslint": "^6.8.0",
24
- "eslint-plugin-import": "^2.19.1",
25
- "mocha-spec-json-output-reporter": "^1.1.7"
26
- },
27
- "directories": {
28
- "test": "tests"
29
- }
30
- }
1
+ {
2
+ "name": "@getjones/test-infra",
3
+ "version": "4.4.10",
4
+ "description": "Providing internal and openapi interface",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail",
8
+ "eslint-fix": "eslint \"./src/**/*.js\" --fix"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "axios": "^0.21.1",
14
+ "axios-file": "^1.0.17",
15
+ "chai": "^4.3.4",
16
+ "dotenv": "^8.2.0",
17
+ "enum": "^3.0.4",
18
+ "form-data": "^4.0.0",
19
+ "mocha": "^8.3.2"
20
+ },
21
+ "devDependencies": {
22
+ "babel-eslint": "^10.0.3",
23
+ "eslint": "^6.8.0",
24
+ "eslint-plugin-import": "^2.19.1",
25
+ "mocha-spec-json-output-reporter": "^1.1.7"
26
+ },
27
+ "directories": {
28
+ "test": "tests"
29
+ }
30
+ }
@@ -1,40 +1,40 @@
1
- const { expect } = require('chai');
2
-
3
- const env = require('../../../../../../src/env');
4
-
5
- const { internalAPI } = require('../../../../src')(env);
6
- const { dbEmails, auth } = internalAPI;
7
-
8
- const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
9
-
10
- const textInSubject = 'One-Time Security Code';
11
- const textInBody = 'Please use the one-time code below to confirm your identity';
12
- const codeLength = 6;
13
-
14
- const getVendorHubAuthCookie = async email => {
15
- const createOneTimeSessionResponse = await auth.services.createOneTimeSession(email);
16
- expect(createOneTimeSessionResponse.status, `Create one-time session for email ${email} has failed`).to.equal(httpResponseStatusCodes.OK);
17
-
18
- const recipients = {
19
- from: env.credentials.superUser,
20
- to: [email]
21
- };
22
-
23
- const userEmailBody = await dbEmails.services.getLastMessage({ recipients, textInSubject });
24
- expect(userEmailBody, 'Fetching user one-time security code email has failed').to.be.a('string').that.includes(textInBody);
25
-
26
- const oneTimeCode = await extractOneTimeCode(userEmailBody);
27
- expect(oneTimeCode.length, 'One-time security code extraction from email body has failed').to.equal(codeLength);
28
-
29
- return auth.services.getHubUserCookie(email, oneTimeCode);
30
- };
31
-
32
- async function extractOneTimeCode(inputString) {
33
- const regex = '\s*(\\d{6})\n\s*';
34
- const match = inputString.match(regex);
35
-
36
- return match ? match[1] : null;
37
- }
38
- module.exports = {
39
- getVendorHubAuthCookie
40
- };
1
+ const { expect } = require('chai');
2
+
3
+ const env = require('../../../../../../src/env');
4
+
5
+ const { internalAPI } = require('../../../../src')(env);
6
+ const { dbEmails, auth } = internalAPI;
7
+
8
+ const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
9
+
10
+ const textInSubject = 'One-Time Security Code';
11
+ const textInBody = 'Please use the one-time code below to confirm your identity';
12
+ const codeLength = 6;
13
+
14
+ const getVendorHubAuthCookie = async email => {
15
+ const createOneTimeSessionResponse = await auth.services.createOneTimeSession(email);
16
+ expect(createOneTimeSessionResponse.status, `Create one-time session for email ${email} has failed`).to.equal(httpResponseStatusCodes.OK);
17
+
18
+ const recipients = {
19
+ from: env.credentials.superUser,
20
+ to: [email]
21
+ };
22
+
23
+ const userEmailBody = await dbEmails.services.getLastMessage({ recipients, textInSubject });
24
+ expect(userEmailBody, 'Fetching user one-time security code email has failed').to.be.a('string').that.includes(textInBody);
25
+
26
+ const oneTimeCode = await extractOneTimeCode(userEmailBody);
27
+ expect(oneTimeCode.length, 'One-time security code extraction from email body has failed').to.equal(codeLength);
28
+
29
+ return auth.services.getHubUserCookie(email, oneTimeCode);
30
+ };
31
+
32
+ async function extractOneTimeCode(inputString) {
33
+ const regex = '\s*(\\d{6})\n\s*';
34
+ const match = inputString.match(regex);
35
+
36
+ return match ? match[1] : null;
37
+ }
38
+ module.exports = {
39
+ getVendorHubAuthCookie
40
+ };
@@ -1,4 +1,4 @@
1
- const records = require('./records/records');
2
- const auth = require('./auth/auth');
3
-
4
- module.exports = { records, auth };
1
+ const records = require('./records/records');
2
+ const auth = require('./auth/auth');
3
+
4
+ module.exports = { records, auth };
@@ -1,195 +1,195 @@
1
- const { expect } = require('chai');
2
-
3
- const threadScheduler = require('../../../saas/internal-api/thread-scheduler/runner');
4
- const timeUtils = require('../../utils/timeUtils');
5
- const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
6
- const ocrStatuses = require('../../consts/ocrStatuses');
7
- const contractors = require('../../../saas/internal-api/contractors');
8
- const compliance = require('../../../saas/internal-api/compliance');
9
- const requests = require('../../../saas/internal-api/requests');
10
- const dbEmails = require('../../../saas/internal-api/dbEmails');
11
- const activationStatuses = require('../../../common/consts/activationStatuses');
12
- const recordTypes = require('../../../common/consts/recordTypes');
13
-
14
- const makeRecordNotResponsive = async function(recordId, context) {
15
- const { data: record } = await contractors.services.getContractorById(recordId, context);
16
- const isTenant = record.recordType === recordTypes.TENANTS;
17
-
18
- const offsetInDaysList = isTenant ?
19
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
20
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
21
-
22
- for (const offsetInDays of offsetInDaysList) {
23
- await updateLastInviteActionDate(recordId, offsetInDays, context);
24
- }
25
- };
26
-
27
- const editRequestAndRecordDetails = async function(request, recordConfig, context) {
28
- const tabModel = new requests.models.TabModel(request.tab.type);
29
- const recordDetailsModel = contractors.services.getContractorDetailsModel(recordConfig);
30
- const record = new contractors.models.edit.ContractorModel(
31
- request.record.contractorId,
32
- request.record.recordType,
33
- recordConfig.company,
34
- recordConfig.emailAddress,
35
- recordDetailsModel
36
- );
37
- const requestEditModel = new requests.models.RequestModel(request.id, record, tabModel, {});
38
-
39
- const editRequestResponse = await requests.services.editRequestAndRecordDetails(requestEditModel, context);
40
-
41
- if (editRequestResponse.status !== httpResponseStatusCodes.OK) {
42
- throw Error(`Failed to edit record \n${editRequestResponse.data.message}`);
43
- }
44
- };
45
-
46
- const updateInviteDate = async function(recordId, inviteDate, context) {
47
- await timeUtils.waitFor(1).seconds;
48
- const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
49
-
50
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
51
- throw new Error(`Failed to update record invite date\n${updateResponse}`);
52
- }
53
-
54
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
55
-
56
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
57
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
58
- }
59
-
60
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
61
- };
62
-
63
- const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
64
- await timeUtils.waitFor(1).seconds;
65
- /*
66
- To run the reminders mails successfully we must first update the compliance audit actions date,
67
- Since the thread scheduler will trigger the logic of the reminders mails
68
- only if last invite action date will be equal or after compliance audit actions date
69
- */
70
- const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
71
-
72
- if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
73
- throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
74
- }
75
-
76
- const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
77
-
78
- if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
79
- throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
80
- }
81
-
82
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
83
-
84
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
85
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
86
- }
87
-
88
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
89
- };
90
-
91
- const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
92
- const dates = timeUtils.getAutomaticRenewalsExpirationDates();
93
-
94
- for (const date of dates) {
95
- await updatePolicyExpiryDateForRecord(recordId, date, policyName);
96
- }
97
- };
98
-
99
- const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
100
- const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
101
-
102
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
103
- throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
104
- }
105
-
106
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
107
-
108
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
109
- throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
110
- }
111
-
112
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
113
- };
114
-
115
- const getHistoryEvents = async function(recordId, context) {
116
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
117
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
118
-
119
- return recordHistory.data.map(item => item.itemTitle).reverse();
120
- };
121
-
122
- const getFirstHistoryEventId = async function(recordId, context) {
123
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
124
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
125
- return recordHistory.data[recordHistory.data.length - 1].itemId;
126
- };
127
-
128
- const getLatestHistoryEventId = async function(recordId, context) {
129
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
130
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
131
- return recordHistory.data[0].itemId;
132
- };
133
-
134
- const getLatestRecordHistoryEventIdByItemTitle = async function(recordId, itemTitle, context) {
135
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
136
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
137
-
138
- const latestHistoryByTitle = recordHistory.data.find(historyItem => historyItem.itemTitle === itemTitle);
139
-
140
- if (!latestHistoryByTitle) {
141
- throw new Error(`History event with title ${itemTitle} not found`);
142
- }
143
-
144
- return latestHistoryByTitle.itemId;
145
- };
146
-
147
- const waitForOcrStatus = async function(recordId, context, { expectedStatus = ocrStatuses.SUCCESS } = {}) {
148
- let { data: recordOcrStatus } = await contractors.services.getRecordOcrStatus(recordId, context);
149
- let maxRetries = 25;
150
- while (recordOcrStatus !== expectedStatus && recordOcrStatus !== ocrStatuses.FAILED && maxRetries > 0) {
151
- await timeUtils.waitFor(5).seconds;
152
- recordOcrStatus = (await contractors.services.getRecordOcrStatus(recordId, context)).data;
153
- maxRetries--;
154
- }
155
-
156
- if (recordOcrStatus !== expectedStatus) {
157
- throw new Error(`Record OCR status not is as expected. Expected: ${expectedStatus}, Actual: ${recordOcrStatus}`);
158
- }
159
- };
160
-
161
- const deleteAllRequestsInProject = async function(accountId, projectId, context) {
162
- const activationStatus = [activationStatuses.ACTIVE, activationStatuses.ARCHIVED, activationStatuses.DRAFT];
163
- const { data: requestsInAccount } = await requests.services.getRequestsByAccountId(accountId, context, activationStatus);
164
-
165
- for (const request of requestsInAccount) {
166
- if (request.projectInfo.projectId === projectId) {
167
- const response = await contractors.services.deleteByContractorId(request.record.contractorId, context);
168
-
169
- if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
170
- throw new Error(`Failed to delete request ${request.id}\n${response}`);
171
- }
172
- }
173
- }
174
- };
175
-
176
- const generateSubscriptionModelFromMail = async function(recipients) {
177
- const data = await dbEmails.services.getSubscriptionData(recipients);
178
- return contractors.services.getSubscriptionModel(data);
179
- };
180
-
181
- module.exports = {
182
- makeRecordNotResponsive,
183
- runOverAllRenewalDatesForRecord,
184
- editRequestAndRecordDetails,
185
- updateInviteDate,
186
- updatePolicyExpiryDateForRecord,
187
- getHistoryEvents,
188
- getFirstHistoryEventId,
189
- getLatestHistoryEventId,
190
- updateLastInviteActionDate,
191
- waitForOcrStatus,
192
- generateSubscriptionModelFromMail,
193
- deleteAllRequestsInProject,
194
- getLatestRecordHistoryEventIdByItemTitle
195
- };
1
+ const { expect } = require('chai');
2
+
3
+ const threadScheduler = require('../../../saas/internal-api/thread-scheduler/runner');
4
+ const timeUtils = require('../../utils/timeUtils');
5
+ const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
6
+ const ocrStatuses = require('../../consts/ocrStatuses');
7
+ const contractors = require('../../../saas/internal-api/contractors');
8
+ const compliance = require('../../../saas/internal-api/compliance');
9
+ const requests = require('../../../saas/internal-api/requests');
10
+ const dbEmails = require('../../../saas/internal-api/dbEmails');
11
+ const activationStatuses = require('../../../common/consts/activationStatuses');
12
+ const recordTypes = require('../../../common/consts/recordTypes');
13
+
14
+ const makeRecordNotResponsive = async function(recordId, context) {
15
+ const { data: record } = await contractors.services.getContractorById(recordId, context);
16
+ const isTenant = record.recordType === recordTypes.TENANTS;
17
+
18
+ const offsetInDaysList = isTenant ?
19
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
20
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
21
+
22
+ for (const offsetInDays of offsetInDaysList) {
23
+ await updateLastInviteActionDate(recordId, offsetInDays, context);
24
+ }
25
+ };
26
+
27
+ const editRequestAndRecordDetails = async function(request, recordConfig, context) {
28
+ const tabModel = new requests.models.TabModel(request.tab.type);
29
+ const recordDetailsModel = contractors.services.getContractorDetailsModel(recordConfig);
30
+ const record = new contractors.models.edit.ContractorModel(
31
+ request.record.contractorId,
32
+ request.record.recordType,
33
+ recordConfig.company,
34
+ recordConfig.emailAddress,
35
+ recordDetailsModel
36
+ );
37
+ const requestEditModel = new requests.models.RequestModel(request.id, record, tabModel, {});
38
+
39
+ const editRequestResponse = await requests.services.editRequestAndRecordDetails(requestEditModel, context);
40
+
41
+ if (editRequestResponse.status !== httpResponseStatusCodes.OK) {
42
+ throw Error(`Failed to edit record \n${editRequestResponse.data.message}`);
43
+ }
44
+ };
45
+
46
+ const updateInviteDate = async function(recordId, inviteDate, context) {
47
+ await timeUtils.waitFor(1).seconds;
48
+ const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
49
+
50
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
51
+ throw new Error(`Failed to update record invite date\n${updateResponse}`);
52
+ }
53
+
54
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
55
+
56
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
57
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
58
+ }
59
+
60
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
61
+ };
62
+
63
+ const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
64
+ await timeUtils.waitFor(1).seconds;
65
+ /*
66
+ To run the reminders mails successfully we must first update the compliance audit actions date,
67
+ Since the thread scheduler will trigger the logic of the reminders mails
68
+ only if last invite action date will be equal or after compliance audit actions date
69
+ */
70
+ const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
71
+
72
+ if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
73
+ throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
74
+ }
75
+
76
+ const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
77
+
78
+ if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
79
+ throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
80
+ }
81
+
82
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
83
+
84
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
85
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
86
+ }
87
+
88
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
89
+ };
90
+
91
+ const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
92
+ const dates = timeUtils.getAutomaticRenewalsExpirationDates();
93
+
94
+ for (const date of dates) {
95
+ await updatePolicyExpiryDateForRecord(recordId, date, policyName);
96
+ }
97
+ };
98
+
99
+ const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
100
+ const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
101
+
102
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
103
+ throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
104
+ }
105
+
106
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
107
+
108
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
109
+ throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
110
+ }
111
+
112
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
113
+ };
114
+
115
+ const getHistoryEvents = async function(recordId, context) {
116
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
117
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
118
+
119
+ return recordHistory.data.map(item => item.itemTitle).reverse();
120
+ };
121
+
122
+ const getFirstHistoryEventId = async function(recordId, context) {
123
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
124
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
125
+ return recordHistory.data[recordHistory.data.length - 1].itemId;
126
+ };
127
+
128
+ const getLatestHistoryEventId = async function(recordId, context) {
129
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
130
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
131
+ return recordHistory.data[0].itemId;
132
+ };
133
+
134
+ const getLatestRecordHistoryEventIdByItemTitle = async function(recordId, itemTitle, context) {
135
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
136
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
137
+
138
+ const latestHistoryByTitle = recordHistory.data.find(historyItem => historyItem.itemTitle === itemTitle);
139
+
140
+ if (!latestHistoryByTitle) {
141
+ throw new Error(`History event with title ${itemTitle} not found`);
142
+ }
143
+
144
+ return latestHistoryByTitle.itemId;
145
+ };
146
+
147
+ const waitForOcrStatus = async function(recordId, context, { expectedStatus = ocrStatuses.SUCCESS } = {}) {
148
+ let { data: recordOcrStatus } = await contractors.services.getRecordOcrStatus(recordId, context);
149
+ let maxRetries = 25;
150
+ while (recordOcrStatus !== expectedStatus && recordOcrStatus !== ocrStatuses.FAILED && maxRetries > 0) {
151
+ await timeUtils.waitFor(5).seconds;
152
+ recordOcrStatus = (await contractors.services.getRecordOcrStatus(recordId, context)).data;
153
+ maxRetries--;
154
+ }
155
+
156
+ if (recordOcrStatus !== expectedStatus) {
157
+ throw new Error(`Record OCR status not is as expected. Expected: ${expectedStatus}, Actual: ${recordOcrStatus}`);
158
+ }
159
+ };
160
+
161
+ const deleteAllRequestsInProject = async function(accountId, projectId, context) {
162
+ const activationStatus = [activationStatuses.ACTIVE, activationStatuses.ARCHIVED, activationStatuses.DRAFT];
163
+ const { data: requestsInAccount } = await requests.services.getRequestsByAccountId(accountId, context, activationStatus);
164
+
165
+ for (const request of requestsInAccount) {
166
+ if (request.projectInfo.projectId === projectId) {
167
+ const response = await contractors.services.deleteByContractorId(request.record.contractorId, context);
168
+
169
+ if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
170
+ throw new Error(`Failed to delete request ${request.id}\n${response}`);
171
+ }
172
+ }
173
+ }
174
+ };
175
+
176
+ const generateSubscriptionModelFromMail = async function(recipients) {
177
+ const data = await dbEmails.services.getSubscriptionData(recipients);
178
+ return contractors.services.getSubscriptionModel(data);
179
+ };
180
+
181
+ module.exports = {
182
+ makeRecordNotResponsive,
183
+ runOverAllRenewalDatesForRecord,
184
+ editRequestAndRecordDetails,
185
+ updateInviteDate,
186
+ updatePolicyExpiryDateForRecord,
187
+ getHistoryEvents,
188
+ getFirstHistoryEventId,
189
+ getLatestHistoryEventId,
190
+ updateLastInviteActionDate,
191
+ waitForOcrStatus,
192
+ generateSubscriptionModelFromMail,
193
+ deleteAllRequestsInProject,
194
+ getLatestRecordHistoryEventIdByItemTitle
195
+ };
@@ -1,14 +1,14 @@
1
- module.exports = {
2
- isOcrEnabled: {
3
- on: { isOcrEnabled: true },
4
- off: { isOcrEnabled: false }
5
- },
6
- isAccountRequirementsEnabled: {
7
- on: { isAccountRequirementsEnabled: true },
8
- off: { isAccountRequirementsEnabled: false }
9
- },
10
- isPolicyVerificationEnabled: {
11
- on: { hasPolicyVerification: true },
12
- off: { hasPolicyVerification: false }
13
- }
14
- };
1
+ module.exports = {
2
+ isOcrEnabled: {
3
+ on: { isOcrEnabled: true },
4
+ off: { isOcrEnabled: false }
5
+ },
6
+ isAccountRequirementsEnabled: {
7
+ on: { isAccountRequirementsEnabled: true },
8
+ off: { isAccountRequirementsEnabled: false }
9
+ },
10
+ isPolicyVerificationEnabled: {
11
+ on: { hasPolicyVerification: true },
12
+ off: { hasPolicyVerification: false }
13
+ }
14
+ };
@@ -1,6 +1,6 @@
1
- module.exports = {
2
- ACTIVE: 'Active',
3
- ARCHIVED: 'Archived',
4
- DRAFT: 'Draft',
5
- DELETED: 'Deleted'
6
- };
1
+ module.exports = {
2
+ ACTIVE: 'Active',
3
+ ARCHIVED: 'Archived',
4
+ DRAFT: 'Draft',
5
+ DELETED: 'Deleted'
6
+ };
@@ -1,9 +1,9 @@
1
- const autocompleteResultType = {
2
- account: 'Account',
3
- jonesGlobalCoi: 'JonesGlobalCoi',
4
- network: 'Network'
5
- };
6
-
7
- module.exports = {
8
- autocompleteResultType
9
- };
1
+ const autocompleteResultType = {
2
+ account: 'Account',
3
+ jonesGlobalCoi: 'JonesGlobalCoi',
4
+ network: 'Network'
5
+ };
6
+
7
+ module.exports = {
8
+ autocompleteResultType
9
+ };