@getjones/test-infra 3.0.1 → 3.0.2

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 (213) 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 +123 -102
  5. package/src/common/consts/activationStatuses.js +6 -6
  6. package/src/common/consts/constantsForRecordsSortingAndFilters.js +40 -0
  7. package/src/common/consts/dashboardCharts.js +18 -18
  8. package/src/common/consts/projectSettings.js +6 -6
  9. package/src/common/consts/recordTypes.js +5 -5
  10. package/src/common/consts/s3FileTypes.js +12 -12
  11. package/src/common/consts/userTypes.js +8 -8
  12. package/src/common/errorCodes.js +3 -3
  13. package/src/common/httpResponseStatusCodes.json +11 -11
  14. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  15. package/src/common/requests/cookieAuth/requests.js +40 -40
  16. package/src/common/requests/internalAuth/requests.js +48 -48
  17. package/src/common/requests/requestHandlers.js +78 -78
  18. package/src/common/utils/complianceUtil.js +83 -83
  19. package/src/common/utils/configsUtil.js +22 -22
  20. package/src/common/utils/dataTypeUtils.js +41 -41
  21. package/src/common/utils/numberUtils.js +22 -22
  22. package/src/common/utils/objectUtils.js +7 -7
  23. package/src/common/utils/timeUtils.js +177 -177
  24. package/src/common/validations/errorValidation.js +16 -16
  25. package/src/common/validations/typeValidations.js +36 -36
  26. package/src/defaults/configs/auditConfigs.js +91 -91
  27. package/src/defaults/configs/coverage.js +227 -227
  28. package/src/defaults/configs/polices.js +64 -64
  29. package/src/defaults/configs/requirement.js +32 -32
  30. package/src/defaults/index.js +6 -6
  31. package/src/env.js +57 -57
  32. package/src/factory/globalRecord/globalRecord.js +70 -70
  33. package/src/factory/index.js +8 -8
  34. package/src/factory/records/records.js +169 -183
  35. package/src/factory/users/users.js +77 -77
  36. package/src/index.js +91 -91
  37. package/src/resources/virusFile.pdf +0 -0
  38. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  39. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  40. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  41. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  42. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  43. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  44. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  45. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  46. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  47. package/src/saas/internal-api/accounts/index.js +22 -22
  48. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  49. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +38 -38
  50. package/src/saas/internal-api/accounts/utils/utils.js +58 -58
  51. package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
  52. package/src/saas/internal-api/agreement/api/agreement.service.js +81 -81
  53. package/src/saas/internal-api/agreement/consts/consts.js +8 -8
  54. package/src/saas/internal-api/agreement/index.js +11 -11
  55. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  56. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  57. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  58. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  59. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  60. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  61. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  62. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  63. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  64. package/src/saas/internal-api/auditNotes/index.js +4 -4
  65. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  66. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  67. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  68. package/src/saas/internal-api/auth/index.js +3 -3
  69. package/src/saas/internal-api/coi/api/coi.api.js +40 -40
  70. package/src/saas/internal-api/coi/api/coi.service.js +26 -26
  71. package/src/saas/internal-api/coi/consts/hashes.js +4 -0
  72. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  73. package/src/saas/internal-api/coi/index.js +14 -13
  74. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  75. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  76. package/src/saas/internal-api/compliance/api/audit/audit.api.js +100 -100
  77. package/src/saas/internal-api/compliance/api/audit/audit.service.js +242 -230
  78. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  79. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  80. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  81. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  82. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
  83. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
  84. package/src/saas/internal-api/compliance/consts/audit.js +103 -103
  85. package/src/saas/internal-api/compliance/index.js +33 -33
  86. package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
  87. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  88. package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
  89. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  90. package/src/saas/internal-api/contractors/api/contractors.api.js +185 -179
  91. package/src/saas/internal-api/contractors/api/contractors.service.js +259 -247
  92. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  93. package/src/saas/internal-api/contractors/index.js +8 -8
  94. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  95. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +62 -60
  96. package/src/saas/internal-api/contractors/models/link.request.model.js +10 -0
  97. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  98. package/src/saas/internal-api/contractors/utils.js +25 -25
  99. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  100. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  101. package/src/saas/internal-api/dashboard/index.js +5 -5
  102. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  103. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  104. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +147 -147
  105. package/src/saas/internal-api/dbEmails/consts/consts.js +54 -54
  106. package/src/saas/internal-api/dbEmails/index.js +6 -6
  107. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  108. package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
  109. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  110. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  111. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  112. package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
  113. package/src/saas/internal-api/globalRecord/api/global.record.service.js +105 -105
  114. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  115. package/src/saas/internal-api/globalRecord/index.js +6 -6
  116. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  117. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  118. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  119. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  120. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  121. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  122. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  123. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  124. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  125. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  126. package/src/saas/internal-api/projects/index.js +24 -24
  127. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  128. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  129. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +41 -41
  130. package/src/saas/internal-api/projects/utils/utils.js +156 -156
  131. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  132. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  133. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  134. package/src/saas/internal-api/recordNotes/index.js +3 -3
  135. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  136. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  137. package/src/saas/internal-api/reports/consts/consts.js +65 -64
  138. package/src/saas/internal-api/reports/index.js +15 -15
  139. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  140. package/src/saas/internal-api/requests/api/requests.api.js +120 -96
  141. package/src/saas/internal-api/requests/api/requests.service.js +272 -220
  142. package/src/saas/internal-api/requests/index.js +20 -18
  143. package/src/saas/internal-api/requests/models/create.request.model.js +33 -34
  144. package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -0
  145. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  146. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  147. package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
  148. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  149. package/src/saas/internal-api/requests/utils.js +8 -8
  150. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  151. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  152. package/src/saas/internal-api/requestsTable/index.js +3 -3
  153. package/src/saas/internal-api/requirements/api/requirements.api.js +51 -51
  154. package/src/saas/internal-api/requirements/api/requirements.service.js +153 -153
  155. package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -6
  156. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  157. package/src/saas/internal-api/requirements/index.js +10 -10
  158. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  159. package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
  160. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  161. package/src/saas/internal-api/requirements/utils/utils.js +116 -116
  162. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  163. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  164. package/src/saas/internal-api/serviceArea/index.js +4 -4
  165. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  166. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  167. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  168. package/src/saas/internal-api/tabs/index.js +3 -3
  169. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  170. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  171. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +31 -31
  172. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +42 -42
  173. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  174. package/src/saas/internal-api/uploadFiles/index.js +3 -3
  175. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
  176. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +97 -97
  177. package/src/saas/internal-api/users/api/users.api.js +115 -115
  178. package/src/saas/internal-api/users/api/users.service.js +203 -203
  179. package/src/saas/internal-api/users/index.js +16 -16
  180. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  181. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  182. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  183. package/src/saas/internal-api/users/models/users.model.js +41 -41
  184. package/src/saas/internal-api/users/utils/util.js +39 -39
  185. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  186. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  187. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  188. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  189. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  190. package/src/saas/openapi/coi/coi.api.js +20 -20
  191. package/src/saas/openapi/coi/coi.service.js +13 -13
  192. package/src/saas/openapi/projects/projects.api.js +83 -83
  193. package/src/saas/openapi/projects/projects.service.js +64 -64
  194. package/src/saas/openapi/requests/index.js +7 -7
  195. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  196. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  197. package/src/saas/openapi/requests/requests.api.js +82 -82
  198. package/src/saas/openapi/requests/requests.service.js +70 -70
  199. package/src/saas/openapi/requirements/index.js +6 -6
  200. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  201. package/src/saas/openapi/requirements/requirements.api.js +32 -32
  202. package/src/saas/openapi/requirements/requirements.service.js +37 -37
  203. package/src/saas/openapi/tabs/index.js +6 -6
  204. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  205. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  206. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  207. package/src/saas/openapi/users/user.model.js +10 -10
  208. package/src/saas/openapi/users/users.api.js +33 -33
  209. package/src/saas/openapi/users/users.service.js +41 -41
  210. package/tests/env.test.js +40 -40
  211. package/tests/validation.test.js +83 -83
  212. package/.npmrc.bak +0 -2
  213. package/package.json.bak +0 -30
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@getjones/test-infra",
3
- "version": "3.0.1",
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": "3.0.2",
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,102 +1,123 @@
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 contractors = require('../../../saas/internal-api/contractors');
7
- const compliance = require('../../../saas/internal-api/compliance');
8
-
9
- const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
10
- const offsetInDaysList = isTenant ?
11
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
12
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
13
-
14
- for (const offsetInDays of offsetInDaysList) {
15
- await updateLastInviteActionDate(recordId, offsetInDays, context);
16
- }
17
- };
18
-
19
- const updateInviteDate = async function(recordId, inviteDate, context) {
20
- await timeUtils.waitFor(1).seconds;
21
- const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
22
-
23
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
24
- throw new Error(`Failed to update record invite date\n${updateResponse}`);
25
- }
26
-
27
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
28
-
29
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
30
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
31
- }
32
-
33
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
34
- };
35
-
36
- const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
37
- await timeUtils.waitFor(1).seconds;
38
- /*
39
- To run the reminders mails successfully we must first update the compliance audit actions date,
40
- Since the thread scheduler will trigger the logic of the reminders mails
41
- only if last invite action date will be equal or after compliance audit actions date
42
- */
43
- const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
44
-
45
- if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
46
- throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
47
- }
48
-
49
- const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
50
-
51
- if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
52
- throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
53
- }
54
-
55
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
56
-
57
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
58
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
59
- }
60
-
61
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
62
- };
63
-
64
- const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
65
- const dates = timeUtils.getAutomaticRenewalsExpirationDates();
66
-
67
- for (const date of dates) {
68
- await updatePolicyExpiryDateForRecord(recordId, date, policyName);
69
- }
70
- };
71
-
72
- const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
73
- const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
74
-
75
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
76
- throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
77
- }
78
-
79
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
80
-
81
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
82
- throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
83
- }
84
-
85
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
86
- };
87
-
88
- const getHistoryEvents = async function(recordId, context) {
89
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
90
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
91
-
92
- return recordHistory.data.map(item => item.itemTitle).reverse();
93
- };
94
-
95
- module.exports = {
96
- makeRecordNotResponsive,
97
- runOverAllRenewalDatesForRecord,
98
- updateInviteDate,
99
- updatePolicyExpiryDateForRecord,
100
- getHistoryEvents,
101
- updateLastInviteActionDate
102
- };
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 contractors = require('../../../saas/internal-api/contractors');
7
+ const compliance = require('../../../saas/internal-api/compliance');
8
+ const requests = require('../../../saas/internal-api/requests');
9
+
10
+ const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
11
+ const offsetInDaysList = isTenant ?
12
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
13
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
14
+
15
+ for (const offsetInDays of offsetInDaysList) {
16
+ await updateLastInviteActionDate(recordId, offsetInDays, context);
17
+ }
18
+ };
19
+
20
+ const editRequestAndRecordDetails = async function(request, recordConfig, context) {
21
+ const tabModel = new requests.models.TabModel(request.tab.type);
22
+ const recordDetailsModel = contractors.services.getContractorDetailsModel(recordConfig);
23
+ const record = new contractors.models.edit.ContractorModel(
24
+ request.record.contractorId,
25
+ request.record.recordType,
26
+ recordConfig.company,
27
+ recordConfig.emailAddress,
28
+ recordDetailsModel
29
+ );
30
+ const requestEditModel = new requests.models.RequestModel(request.id, record, tabModel, {});
31
+
32
+ const editRequestResponse = await requests.services.editRequestAndRecordDetails(requestEditModel, context);
33
+
34
+ if (editRequestResponse.status !== httpResponseStatusCodes.OK) {
35
+ throw Error(`Failed to edit record ${recordCompany}\n${editRequestResponse.data.message}`);
36
+ }
37
+ };
38
+
39
+ const updateInviteDate = async function(recordId, inviteDate, context) {
40
+ await timeUtils.waitFor(1).seconds;
41
+ const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
42
+
43
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
44
+ throw new Error(`Failed to update record invite date\n${updateResponse}`);
45
+ }
46
+
47
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
48
+
49
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
50
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
51
+ }
52
+
53
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
54
+ };
55
+
56
+ const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
57
+ await timeUtils.waitFor(1).seconds;
58
+ /*
59
+ To run the reminders mails successfully we must first update the compliance audit actions date,
60
+ Since the thread scheduler will trigger the logic of the reminders mails
61
+ only if last invite action date will be equal or after compliance audit actions date
62
+ */
63
+ const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
64
+
65
+ if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
66
+ throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
67
+ }
68
+
69
+ const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
70
+
71
+ if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
72
+ throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
73
+ }
74
+
75
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
76
+
77
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
78
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
79
+ }
80
+
81
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
82
+ };
83
+
84
+ const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
85
+ const dates = timeUtils.getAutomaticRenewalsExpirationDates();
86
+
87
+ for (const date of dates) {
88
+ await updatePolicyExpiryDateForRecord(recordId, date, policyName);
89
+ }
90
+ };
91
+
92
+ const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
93
+ const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
94
+
95
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
96
+ throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
97
+ }
98
+
99
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
100
+
101
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
102
+ throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
103
+ }
104
+
105
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
106
+ };
107
+
108
+ const getHistoryEvents = async function(recordId, context) {
109
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
110
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
111
+
112
+ return recordHistory.data.map(item => item.itemTitle).reverse();
113
+ };
114
+
115
+ module.exports = {
116
+ makeRecordNotResponsive,
117
+ runOverAllRenewalDatesForRecord,
118
+ editRequestAndRecordDetails,
119
+ updateInviteDate,
120
+ updatePolicyExpiryDateForRecord,
121
+ getHistoryEvents,
122
+ updateLastInviteActionDate
123
+ };
@@ -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
+ };
@@ -0,0 +1,40 @@
1
+ const activeRecordSortBy = {
2
+ companyName: 'SORT_BY_COMPANYNAME',
3
+ recordId: 'SORT_BY_RECORD_ID',
4
+ vendorStatus: 'SORT_BY_VENDOR_STATUS',
5
+ minPolicyExpired: 'SORT_BY_MIN_POLICY_EXP',
6
+ insuranceStatus: 'SORT_BY_INSURANCE_STATUS'
7
+ };
8
+
9
+ const recordComplianceStatuses = {
10
+ compliant: 'COMPLIANT_STATUS',
11
+ notCompliant: 'NOT_COMPLIANT_STATUS',
12
+ noCOIRequired: 'NO_COI_REQUIRED',
13
+ awaitingNewCOI: 'WAITING_NEW_COI_STATUS',
14
+ waived: 'WAIVED_STATUS',
15
+ underReview: 'UNDER_REVIEW',
16
+ expired: 'Expired',
17
+ notResponsive: 'NotResponsive'
18
+ };
19
+
20
+ const draftRecordSortBy = {
21
+ companyName: 'SORT_BY_COMPANY_NAME',
22
+ recordId: 'SORT_BY_RECORD_ID',
23
+ missingData: 'SORT_BY_MISSING_DATA',
24
+ coi: 'SORT_BY_COI'
25
+ };
26
+
27
+ const draftCompletionStatus = {
28
+ missingContact: 'missingContact',
29
+ missingRequirements: 'missingRequirements',
30
+ missingCoi: 'missingCoi',
31
+ readyForCoiRequest: 'readyForCoiRequest',
32
+ readyForReview: 'readyForReview'
33
+ };
34
+
35
+ module.exports = {
36
+ recordComplianceStatuses,
37
+ activeRecordSortBy,
38
+ draftRecordSortBy,
39
+ draftCompletionStatus
40
+ };
@@ -1,18 +1,18 @@
1
- const chartTypes = {
2
- requiringAttention: 'requiringAttention',
3
- expirationDatePerMonth: 'expirationDatePerMonth',
4
- waivedByRequirement: 'waivedByRequirement',
5
- notCompliantForRequirement: 'notCompliantForRequirement'
6
- };
7
- const sortBy = {
8
- companyName: 'SORT_BY_COMPANYNAME',
9
- projectName: 'SORT_BY_PROJECT_NAME',
10
- insuranceStatus: 'SORT_BY_INSURANCE_STATUS',
11
- minPolicyExpiration: 'SORT_BY_MIN_POLICY_EXP'
12
-
13
- };
14
-
15
- module.exports = {
16
- chartTypes,
17
- sortBy
18
- };
1
+ const chartTypes = {
2
+ requiringAttention: 'requiringAttention',
3
+ expirationDatePerMonth: 'expirationDatePerMonth',
4
+ waivedByRequirement: 'waivedByRequirement',
5
+ notCompliantForRequirement: 'notCompliantForRequirement'
6
+ };
7
+ const sortBy = {
8
+ companyName: 'SORT_BY_COMPANYNAME',
9
+ projectName: 'SORT_BY_PROJECT_NAME',
10
+ insuranceStatus: 'SORT_BY_INSURANCE_STATUS',
11
+ minPolicyExpiration: 'SORT_BY_MIN_POLICY_EXP'
12
+
13
+ };
14
+
15
+ module.exports = {
16
+ chartTypes,
17
+ sortBy
18
+ };
@@ -1,6 +1,6 @@
1
- module.exports = {
2
- tenantSolution: {
3
- on: { tenantSolution: true },
4
- off: { tenantSolution: false }
5
- }
6
- };
1
+ module.exports = {
2
+ tenantSolution: {
3
+ on: { tenantSolution: true },
4
+ off: { tenantSolution: false }
5
+ }
6
+ };
@@ -1,5 +1,5 @@
1
- module.exports = {
2
- VENDORS: 'Vendors',
3
- TENANTS: 'Tenants',
4
- GUESTS: 'Guests'
5
- };
1
+ module.exports = {
2
+ VENDORS: 'Vendors',
3
+ TENANTS: 'Tenants',
4
+ GUESTS: 'Guests'
5
+ };
@@ -1,12 +1,12 @@
1
- module.exports = {
2
- DOCUMENT: 'DOCUMENT',
3
- REPORTS: 'REPORTS',
4
- SNIPPET: 'SNIPPET',
5
- CONTRACT: 'CONTRACT',
6
- TEMPCOI: 'TEMPCOI',
7
- COI: 'COI',
8
- ATTACHMENT: 'ATTACHMENT',
9
- OCRDATA: 'OCRDATA',
10
- VENDORREPORT: 'VENDORREPORT',
11
- TEMP_DOCUMENTS: 'TEMP_DOCUMENTS'
12
- };
1
+ module.exports = {
2
+ DOCUMENT: 'DOCUMENT',
3
+ REPORTS: 'REPORTS',
4
+ SNIPPET: 'SNIPPET',
5
+ CONTRACT: 'CONTRACT',
6
+ TEMPCOI: 'TEMPCOI',
7
+ COI: 'COI',
8
+ ATTACHMENT: 'ATTACHMENT',
9
+ OCRDATA: 'OCRDATA',
10
+ VENDORREPORT: 'VENDORREPORT',
11
+ TEMP_DOCUMENTS: 'TEMP_DOCUMENTS'
12
+ };
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- ICS: 'ICS',
3
- PM: 'PM',
4
- AUDITOR: 'Auditor',
5
- VENDOR: 'Vendor',
6
- auditor: 'Auditor',
7
- operator: 'Operator'
8
- };
1
+ module.exports = {
2
+ ICS: 'ICS',
3
+ PM: 'PM',
4
+ AUDITOR: 'Auditor',
5
+ VENDOR: 'Vendor',
6
+ auditor: 'Auditor',
7
+ operator: 'Operator'
8
+ };
@@ -1,3 +1,3 @@
1
- module.exports = {
2
- UNKNOWN: 'UNKNOWN'
3
- };
1
+ module.exports = {
2
+ UNKNOWN: 'UNKNOWN'
3
+ };
@@ -1,12 +1,12 @@
1
- {
2
- "OK": 200,
3
- "NO_CONTENT": 204,
4
- "IM_USED": 226,
5
- "BAD_REQUEST": 400,
6
- "UNAUTHORIZED": 401,
7
- "FORBIDDEN": 403,
8
- "NOT_FOUND": 404,
9
- "CONFLICT": 409,
10
- "TOO_MANY_REQUESTS": 429,
11
- "CLIENT_CLOSED_REQUEST": 499
1
+ {
2
+ "OK": 200,
3
+ "NO_CONTENT": 204,
4
+ "IM_USED": 226,
5
+ "BAD_REQUEST": 400,
6
+ "UNAUTHORIZED": 401,
7
+ "FORBIDDEN": 403,
8
+ "NOT_FOUND": 404,
9
+ "CONFLICT": 409,
10
+ "TOO_MANY_REQUESTS": 429,
11
+ "CLIENT_CLOSED_REQUEST": 499
12
12
  }