@getjones/test-infra 4.5.10 → 4.5.12

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.10",
3
+ "version": "4.5.12",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,9 +10,9 @@ const { InviteUserModel } = users.models;
10
10
  const defaultsPassword = credentials.strongPassword;
11
11
  const { internalApiUserRoles: roles } = require('../../../src/common/consts/userRoles');
12
12
 
13
- const inviteSaasUser = async (username, role, projectIds, context, { hasCompleteAccessPermission } = {}) => {
13
+ const inviteSaasUser = async (username, role, projectIds, context, { hasCompleteAccessPermission, disableSendMail } = {}) => {
14
14
  const inviteUserModel = new InviteUserModel(username, role, projectIds, hasCompleteAccessPermission);
15
- const inviteResponse = await users.services.inviteUser([inviteUserModel], context);
15
+ const inviteResponse = await users.services.inviteUser([inviteUserModel], context, { disableSendMail });
16
16
 
17
17
  if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
18
18
  throw new Error(`Failed to invite user with email: ${username}\n${inviteResponse}`);
@@ -35,8 +35,8 @@ const signupSaasUser = async (username, role, context) => {
35
35
  }
36
36
  };
37
37
 
38
- const prepareUser = async (username, role, projectIds, context, { signup = true, hasCompleteAccessPermission } = {}) => {
39
- await inviteSaasUser(username, role, projectIds, context, { hasCompleteAccessPermission });
38
+ const prepareUser = async (username, role, projectIds, context, { signup = true, hasCompleteAccessPermission, disableSendMail } = {}) => {
39
+ await inviteSaasUser(username, role, projectIds, context, { hasCompleteAccessPermission, disableSendMail });
40
40
 
41
41
  const icsContext = await auth.getIcsCookie();
42
42
  signup && await signupSaasUser(username, role, icsContext); // Can not use other context than ics to use this function
@@ -50,16 +50,16 @@ const prepareUser = async (username, role, projectIds, context, { signup = true,
50
50
  return userResponse.data;
51
51
  };
52
52
 
53
- const prepareComplianceManagerUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
54
- return prepareUser(username, roles.cm, projectIds, context, { signup, hasCompleteAccessPermission });
53
+ const prepareComplianceManagerUser = (username, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail } = {}) => {
54
+ return prepareUser(username, roles.cm, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail });
55
55
  };
56
56
 
57
- const prepareInviterUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
58
- return prepareUser(username, roles.inviter, projectIds, context, { signup, hasCompleteAccessPermission });
57
+ const prepareInviterUser = (username, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail } = {}) => {
58
+ return prepareUser(username, roles.inviter, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail });
59
59
  };
60
60
 
61
- const prepareReadOnlyUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
62
- return prepareUser(username, roles.readOnly, projectIds, context, { signup, hasCompleteAccessPermission });
61
+ const prepareReadOnlyUser = (username, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail } = {}) => {
62
+ return prepareUser(username, roles.readOnly, projectIds, context, { signup, hasCompleteAccessPermission, disableSendMail });
63
63
  };
64
64
 
65
65
  module.exports = {
@@ -17,7 +17,8 @@ const Endpoints = {
17
17
  resumeAudit: onHoldId => `${backendUrl}/saas/auditor/on-hold/${onHoldId}/resume`,
18
18
  getAuditMetadata: auditId => `${backendUrl}/saas/auditor/audit-metadata/${auditId}`,
19
19
  updateComplianceAuditActionsDate: recordId => `${backendUrl}/saas/automation/record/${recordId}/update-audit-actions-date`,
20
- auditRawData: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/raw`
20
+ auditRawData: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/raw`,
21
+ getAuditResultAttributeState: auditId => `${backendUrl}/saas/audit/automation/audit/${auditId}`
21
22
  };
22
23
 
23
24
  const submitAudit = async (auditRequestModel, context) => {
@@ -86,6 +87,10 @@ const getAuditRawData = (recordId, context) => {
86
87
  return requests.getRequestHandler(Endpoints.auditRawData(recordId), {}, context);
87
88
  };
88
89
 
90
+ const getAuditResultAttributeState = (auditId, context) => {
91
+ return requests.getRequestHandler(Endpoints.getAuditResultAttributeState(auditId), {}, context);
92
+ };
93
+
89
94
  module.exports = {
90
95
  submitAudit,
91
96
  revertCoi,
@@ -102,5 +107,6 @@ module.exports = {
102
107
  getAuditMetadata,
103
108
  updateComplianceAuditActionsDate,
104
109
  getAuditRawData,
105
- verifyAuditBeforeEnter
110
+ verifyAuditBeforeEnter,
111
+ getAuditResultAttributeState
106
112
  };
@@ -7,6 +7,7 @@ const { cloneObject } = require('../../../../../common/utils/objectUtils');
7
7
  const complianceUtil = require('../../../../../common/utils/complianceUtil');
8
8
  const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
9
9
 
10
+ // This method is used only for submitting audit after already entering audit
10
11
  const submitAudit = async (auditRequestModel, context, { expectError } = {}) => {
11
12
  validateType(auditRequestModel, AuditRequestModel);
12
13
 
@@ -19,64 +20,6 @@ const submitAudit = async (auditRequestModel, context, { expectError } = {}) =>
19
20
  return submitAuditResponse;
20
21
  };
21
22
 
22
- const revertCoi = (contractorId, dateModified, context) => {
23
- const dateModifiedObj = { dateModified };
24
- return auditApi.revertCoi(contractorId, dateModifiedObj, context);
25
- };
26
-
27
- const wrongCoi = (recordId, context) => {
28
- return auditApi.wrongCoi(recordId, context);
29
- };
30
-
31
- const isReaudit = (contractorId, context) => {
32
- return complianceUtil.isReaudit(contractorId, context);
33
- };
34
-
35
- const getAuditorContractorList = (auditListParametersModel, context) => {
36
- validateType(auditListParametersModel, AuditListParametersModel);
37
- return auditApi.getAuditorContractorList(auditListParametersModel, context);
38
- };
39
-
40
- const getAuditRequestModelAfterEnterAudit = async (accountId, projectId, requirementId, recordId, auditConfig, context, { shouldSendNotificationToPM, dateStartedAudit } = {}) => {
41
- const metadata = await prepareMetadataForAudit(context, accountId, projectId, requirementId, recordId, { shouldSendNotificationToPM, dateStartedAudit });
42
- const auditEntities = await getAuditEntities(recordId, auditConfig, context);
43
- const auditRequestModel = getAuditRequestModel(metadata, auditEntities);
44
-
45
- return auditRequestModel;
46
- };
47
-
48
- const enterAudit = async (recordId, context, { shouldSendNotificationToPM, shouldGetAuditRequestModelAfterEnterAudit, accountId, projectId, requirementId, auditConfig } = {}) => {
49
- const enterAuditResponse = await auditApi.enterAudit(recordId, context);
50
-
51
- if (enterAuditResponse.status !== httpResponseStatusCodes.OK) {
52
- throw Error(`Failed to enter audit\n$response - ${enterAuditResponse.status}\n${JSON.stringify(enterAuditResponse.data)}`);
53
- }
54
-
55
- if (shouldGetAuditRequestModelAfterEnterAudit) {
56
- const dateStartedAudit = enterAuditResponse.data.dateStartedAudit;
57
- return getAuditRequestModelAfterEnterAudit(accountId, projectId, requirementId, recordId, auditConfig, context, { shouldSendNotificationToPM, dateStartedAudit });
58
- } else {
59
- return enterAuditResponse;
60
- }
61
- };
62
-
63
- const getAuditRecordModel = (recordId, context) => {
64
- return auditApi.getAuditRecordModel(recordId, context);
65
- };
66
-
67
- const getRequirementDetailsForAudit = (contractorId, context) => {
68
- return auditApi.getRequirementDetailsForAudit(contractorId, context);
69
- };
70
- const getAuditorContractorReviewByRecordId = async (recordId, context) => {
71
- const response = await auditApi.getAuditorContractorReviewByRecordId(recordId, context);
72
-
73
- if (response.status !== httpResponseStatusCodes.OK) {
74
- throw Error(`Failed to get auditor review fields from recordId - ${recordId} error status ${response.status}`);
75
- }
76
-
77
- return response.data;
78
- };
79
-
80
23
  const prepareMetadataForAudit = async (
81
24
  auditorContext,
82
25
  accountId,
@@ -103,11 +46,15 @@ const prepareMetadataForAudit = async (
103
46
  );
104
47
  };
105
48
 
106
- const getAuditByRecordId = async (recordId, context, { isRecordDeleted } = {}) => {
107
- const responseAudit = await auditApi.getAuditByRecordId(recordId, context, { isRecordDeleted });
49
+ const getRequirementDetailsForAudit = (contractorId, context) => {
50
+ return auditApi.getRequirementDetailsForAudit(contractorId, context);
51
+ };
52
+
53
+ const getAuditRawData = async function(recordId, context) {
54
+ const responseAudit = await auditApi.getAuditRawData(recordId, context);
108
55
 
109
56
  if (responseAudit.status !== httpResponseStatusCodes.OK) {
110
- throw Error(`Failed to get audits by record id\n${responseAudit}`);
57
+ throw Error(`Failed to get audit raw data by record id\n${responseAudit}`);
111
58
  }
112
59
 
113
60
  return responseAudit.data;
@@ -169,6 +116,32 @@ const getAuditRequestModel = (metaData, auditEntities) => {
169
116
  return auditRequestModel;
170
117
  };
171
118
 
119
+ const getAuditRequestModelAfterEnterAudit = async (accountId, projectId, requirementId, recordId, auditConfig, context, { shouldSendNotificationToPM, dateStartedAudit } = {}) => {
120
+ const metadata = await prepareMetadataForAudit(context, accountId, projectId, requirementId, recordId, { shouldSendNotificationToPM, dateStartedAudit });
121
+ const auditEntities = await getAuditEntities(recordId, auditConfig, context);
122
+ const auditRequestModel = getAuditRequestModel(metadata, auditEntities);
123
+
124
+ return auditRequestModel;
125
+ };
126
+
127
+ //This method is used only for entering audit and not for submitting the audit
128
+ const enterAudit = async (recordId, context, { shouldSendNotificationToPM, shouldGetAuditRequestModelAfterEnterAudit, accountId, projectId, requirementId, auditConfig } = {}) => {
129
+ const enterAuditResponse = await auditApi.enterAudit(recordId, context);
130
+
131
+ if (enterAuditResponse.status !== httpResponseStatusCodes.OK) {
132
+ throw Error(`Failed to enter audit\n$response - ${enterAuditResponse.status}\n${JSON.stringify(enterAuditResponse.data)}`);
133
+ }
134
+
135
+ // Create model for future submission of audit
136
+ if (shouldGetAuditRequestModelAfterEnterAudit) {
137
+ const dateStartedAudit = enterAuditResponse.data.dateStartedAudit;
138
+ return getAuditRequestModelAfterEnterAudit(accountId, projectId, requirementId, recordId, auditConfig, context, { shouldSendNotificationToPM, dateStartedAudit });
139
+ }
140
+
141
+ return enterAuditResponse;
142
+ };
143
+
144
+ // The main method for encapsulating full audit flow
172
145
  const auditRecord = async function(
173
146
  auditorContext,
174
147
  accountId,
@@ -187,6 +160,44 @@ const auditRecord = async function(
187
160
  return submitAudit(auditRequestModel, auditorContext, { expectError });
188
161
  };
189
162
 
163
+ const getAuditByRecordId = async (recordId, context, { isRecordDeleted } = {}) => {
164
+ const responseAudit = await auditApi.getAuditByRecordId(recordId, context, { isRecordDeleted });
165
+
166
+ if (responseAudit.status !== httpResponseStatusCodes.OK) {
167
+ throw Error(`Failed to get audits by record id\n${responseAudit}`);
168
+ }
169
+
170
+ return responseAudit.data;
171
+ };
172
+
173
+ const revertCoi = (contractorId, dateModified, context) => {
174
+ const dateModifiedObj = { dateModified };
175
+ return auditApi.revertCoi(contractorId, dateModifiedObj, context);
176
+ };
177
+
178
+ const wrongCoi = (recordId, context) => {
179
+ return auditApi.wrongCoi(recordId, context);
180
+ };
181
+
182
+ const isReaudit = (contractorId, context) => {
183
+ return complianceUtil.isReaudit(contractorId, context);
184
+ };
185
+
186
+ const getAuditorContractorList = (auditListParametersModel, context) => {
187
+ validateType(auditListParametersModel, AuditListParametersModel);
188
+ return auditApi.getAuditorContractorList(auditListParametersModel, context);
189
+ };
190
+
191
+ const getAuditorContractorReviewByRecordId = async (recordId, context) => {
192
+ const response = await auditApi.getAuditorContractorReviewByRecordId(recordId, context);
193
+
194
+ if (response.status !== httpResponseStatusCodes.OK) {
195
+ throw Error(`Failed to get auditor review fields from recordId - ${recordId} error status ${response.status}`);
196
+ }
197
+
198
+ return response.data;
199
+ };
200
+
190
201
  const getOnHoldModel = (auditId, onHoldReason) => {
191
202
  return new AuditOnHoldModel(auditId, onHoldReason);
192
203
  };
@@ -249,6 +260,10 @@ const getComplianceJson = async function(recordId, context) {
249
260
  return getComplianceJsonResponse.data;
250
261
  };
251
262
 
263
+ const getAuditRecordModel = (recordId, context) => {
264
+ return auditApi.getAuditRecordModel(recordId, context);
265
+ };
266
+
252
267
  const getCurrentAuditUniqueCoiId = async function(recordId, auditorContext) {
253
268
  const recordDetailsResponse = await getAuditRecordModel(recordId, auditorContext);
254
269
 
@@ -260,18 +275,18 @@ const getCurrentAuditUniqueCoiId = async function(recordId, auditorContext) {
260
275
  return uniqueCoiId;
261
276
  };
262
277
 
263
- const getAuditRawData = async function(recordId, context) {
264
- const responseAudit = await auditApi.getAuditRawData(recordId, context);
278
+ const getAttributeKey = attributeName => {
279
+ return auditUtil.getAttributeKey(attributeName);
280
+ };
265
281
 
266
- if (responseAudit.status !== httpResponseStatusCodes.OK) {
267
- throw Error(`Failed to get audit raw data by record id\n${responseAudit}`);
268
- }
282
+ const getAuditResultAttributeState = async function(auditId, context) {
283
+ const attributeStateResponse = await auditApi.getAuditResultAttributeState(auditId, context);
269
284
 
270
- return responseAudit.data;
271
- };
285
+ if (attributeStateResponse.status !== httpResponseStatusCodes.OK) {
286
+ throw Error(`Failed to get audit result attribute state\n${JSON.stringify(attributeStateResponse)}`);
287
+ }
272
288
 
273
- const getAttributeKey = attributeName => {
274
- return auditUtil.getAttributeKey(attributeName);
289
+ return response.data;
275
290
  };
276
291
 
277
292
  module.exports = {
@@ -298,5 +313,6 @@ module.exports = {
298
313
  getCurrentAuditUniqueCoiId,
299
314
  getAuditRawData,
300
315
  getAuditorContractorReviewByRecordId,
301
- getAttributeKey
316
+ getAttributeKey,
317
+ getAuditResultAttributeState
302
318
  };
@@ -23,7 +23,7 @@ const EMAIL_TYPES = {
23
23
  };
24
24
 
25
25
  const EMAIL_SUBJECT = {
26
- invite: 'Your Insurance Docs are needed for',
26
+ invite: 'Your Insurance Documents are needed for',
27
27
  compliant: ({ requesterName, recordCompanyName }) => `Accepted Insurance for ${requesterName} - ${recordCompanyName}`,
28
28
  sendGaps: ({ requesterName }) => `Corrected Insurance Docs Required for ${requesterName} - `, //For this email type, guest is the same as vendor
29
29
  sendGapsForTenant: ({ requesterName }) => `Corrected Insurance Docs Required for leased space at ${requesterName} - `,
@@ -49,7 +49,8 @@ const EMAIL_SUBJECT = {
49
49
  malwareCoiFound: 'COI upload failed to pass security scan',
50
50
  thankYou: 'Thank you for submitting your documents',
51
51
  teamNoteMention: ({ taggingUserFullName, recordCompanyName }) => `${taggingUserFullName} mentioned you in a team note for ${recordCompanyName}`,
52
- reportSentSingleProject: ({ accountName, projectName }) => `Jones - Report for ${accountName}: ${projectName}`
52
+ reportSentSingleProject: ({ accountName, projectName }) => `Jones - Report for ${accountName}: ${projectName}`,
53
+ inviteUserToProject: ({ accountName }) => `${accountName} invited you to join their project`
53
54
  };
54
55
 
55
56
  module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, tenantUserExtension };