@getjones/test-infra 4.5.6 → 4.5.7

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.6",
3
+ "version": "4.5.7",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,5 +10,9 @@ module.exports = {
10
10
  isPolicyVerificationEnabled: {
11
11
  on: { hasPolicyVerification: true },
12
12
  off: { hasPolicyVerification: false }
13
+ },
14
+ isAuditingAiEnabled: {
15
+ on: { isAuditingAiEnabled: true },
16
+ off: { isAuditingAiEnabled: false }
13
17
  }
14
18
  };
@@ -56,5 +56,6 @@ const attributesConvertor = {
56
56
  'Coverage Auditing': 'isCoverageAudit',
57
57
  'Account Requirements': 'isAccountRequirementsEnabled',
58
58
  'Skip 50 miles autocomplete limitation': 'isWithoutAutocompleteDistanceLimitation',
59
- 'Policy Verification': 'hasPolicyVerification'
59
+ 'Policy Verification': 'hasPolicyVerification',
60
+ 'Auditing AI Enabled': 'isAuditingAiEnabled'
60
61
  };
@@ -9,13 +9,24 @@ const doesRecordHaveAgreementStep = async (recordId, context) => {
9
9
  const recordDataResponse = await getRecordHubDataByRecordId(recordId, context);
10
10
 
11
11
  if (recordDataResponse.status !== httpResponseStatusCodes.OK) {
12
- throw new Error(`Failed to get record hub data\n${recordDataResponse.status}`);
12
+ throw new Error(`Failed to get record hub data, response status - ${recordDataResponse.status}`);
13
13
  }
14
14
 
15
15
  return recordDataResponse?.data?.isVendorsAgreementSignNeeded;
16
16
  };
17
17
 
18
+ const isFullPolicyCopyInRequirementByRecordId = async (recordId, context) => {
19
+ const recordDataResponse = await getRecordHubDataByRecordId(recordId, context);
20
+
21
+ if (recordDataResponse.status !== httpResponseStatusCodes.OK) {
22
+ throw new Error(`Failed to get record hub data, response status - ${recordDataResponse.status}`);
23
+ }
24
+
25
+ return recordDataResponse?.data?.isFullPolicyCopyInRequirement;
26
+ };
27
+
18
28
  module.exports = {
19
29
  getRecordHubDataByRecordId,
20
- doesRecordHaveAgreementStep
30
+ doesRecordHaveAgreementStep,
31
+ isFullPolicyCopyInRequirementByRecordId
21
32
  };
@@ -98,9 +98,11 @@ const deleteRequirementByName = async (requirementName, tabId, context) => {
98
98
  const deleteAllRequirementsInTabs = async (tabIds, context) => {
99
99
  const failedToDeleteRequirements = [];
100
100
  const successfulDeleteRes = [];
101
+ let requirementsToDelete = [];
101
102
 
102
103
  for (const tabId of tabIds) {
103
104
  const { data: existingRequirements } = await getRequirementsByTabId(tabId, context);
105
+ requirementsToDelete = existingRequirements || [];
104
106
 
105
107
  for (const requirement of existingRequirements) {
106
108
  const response = await deleteByRequirementId(requirement.id, context);
@@ -110,6 +112,11 @@ const deleteAllRequirementsInTabs = async (tabIds, context) => {
110
112
  failedToDeleteRequirements.push(response);
111
113
  }
112
114
 
115
+ if (response.data.result === 'linked') {
116
+ console.error('Requirement is linked to a record and cannot be deleted', requirement.id);
117
+ failedToDeleteRequirements.push(response);
118
+ }
119
+
113
120
  if (response.status === httpResponseStatusCodes.OK) {
114
121
  successfulDeleteRes.push(response.data.result);
115
122
  }
@@ -117,7 +124,7 @@ const deleteAllRequirementsInTabs = async (tabIds, context) => {
117
124
  }
118
125
 
119
126
  if (failedToDeleteRequirements.length) {
120
- throw Error(`Failed to delete ${failedToDeleteRequirements.length} of ${existingRequirements.length} requirements in account. Failed with status: ${ failedToDeleteRequirements[0].status }`);
127
+ throw Error(`Failed to delete ${failedToDeleteRequirements.length} of ${requirementsToDelete.length} requirements in account. Failed with status: ${ failedToDeleteRequirements[0].status }`);
121
128
  }
122
129
 
123
130
  return successfulDeleteRes;