@getjones/test-infra 4.5.4 → 4.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "4.5.4",
3
+ "version": "4.5.5",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
Binary file
@@ -40,7 +40,7 @@ const getAllWaiveModels = (
40
40
  userRole,
41
41
  auditId
42
42
  } = {}) => {
43
- const auditIds = [auditId] || getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
43
+ const auditIds = auditId ? [auditId] : getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
44
44
  userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
45
45
  userRole = userRole || userTypes.ICS;
46
46
 
@@ -77,6 +77,7 @@ const getWaiveModel = (
77
77
  return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole, auditId })[0];
78
78
  };
79
79
 
80
+ // used by automation. has to return a single model
80
81
  const getWaiveModelByGap = (
81
82
  record,
82
83
  policyName,
@@ -87,25 +88,27 @@ const getWaiveModelByGap = (
87
88
  userId,
88
89
  userRole
89
90
  } = {}) => {
90
- const attributeName = auditUtil.getAttributeNameByGap(record, policyName, gap);
91
- const auditorContractorId = auditUtil.getAuditorContractorIdByGap(record, policyName, gap);
91
+ const { attributeName, auditId } = auditUtil.getAttributeNameAndAuditIdByGap(record, policyName, gap);
92
92
 
93
- return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole, auditId: auditorContractorId });
93
+ return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole, auditId });
94
94
  };
95
95
 
96
- const getRetractModel = (record, policyName, attributeName) => {
97
- const auditId = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName))[0];
96
+ const getRetractModel = (record, policyName, attributeName, { isAttributeMultipleComments } = {}) => {
97
+ const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
98
98
  const userId = env.getSystemUserIdentity(credentials.superUser).id;
99
99
  const userRole = userTypes.ICS;
100
100
 
101
- const retractModel = new RetractRequestModel({
102
- contractorId: record.id,
103
- auditId,
104
- userId,
105
- userRole
106
- });
107
-
108
- return retractModel;
101
+ const retractModels = [];
102
+ for (const auditId of auditIds) {
103
+ const model = new RetractRequestModel({
104
+ contractorId: record.id,
105
+ auditId,
106
+ userId,
107
+ userRole
108
+ });
109
+ retractModels.push(model);
110
+ }
111
+ return isAttributeMultipleComments ? retractModels : retractModels[0];
109
112
  };
110
113
 
111
114
  const getPolicyAuditIdsFromRecord = (record, policyName, attributeName) => {
@@ -26,7 +26,7 @@ const getWaiveReason = reason => {
26
26
  return waiveReasons[reason] || reason;
27
27
  };
28
28
 
29
- const getAttributeNameByGap = function(record, policyName, gap) {
29
+ const getAttributeNameAndAuditIdByGap = function(record, policyName, gap) {
30
30
  const policy = record.reviewbyAuditor.find(contractorCoverage =>
31
31
  contractorCoverage.insuranceName === policyName);
32
32
 
@@ -40,24 +40,7 @@ const getAttributeNameByGap = function(record, policyName, gap) {
40
40
  throw new Error(`Gap ${gap} don't exist in record`);
41
41
  }
42
42
 
43
- return attribute.limitname;
44
- };
45
-
46
- const getAuditorContractorIdByGap = function(record, policyName, gap) {
47
- const policy = record.reviewbyAuditor.find(contractorCoverage =>
48
- contractorCoverage.insuranceName === policyName);
49
-
50
- if (!policy) {
51
- throw new Error(`Policy name ${policyName} don't exist in record`);
52
- }
53
-
54
- const attribute = policy.errorList.find(error => error.errorHeadline === gap);
55
-
56
- if (!attribute) {
57
- throw new Error(`Gap ${gap} don't exist in record`);
58
- }
59
-
60
- return attribute.auditId;
43
+ return { attributeName: attribute.limitName, auditId: attribute.auditId };
61
44
  };
62
45
 
63
46
  const getAllWaivablePolicies = function(record) {
@@ -230,10 +213,9 @@ module.exports = {
230
213
  getPolicyId,
231
214
  createAuditEntity,
232
215
  getAttributeKey,
233
- getAttributeNameByGap,
216
+ getAttributeNameAndAuditIdByGap,
234
217
  getWaiveReason,
235
- getAllWaivablePolicies,
236
- getAuditorContractorIdByGap
218
+ getAllWaivablePolicies
237
219
  };
238
220
 
239
221
  const certificateEndorsementsList = [