@getjones/test-infra 4.4.15 → 4.4.16

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.4.15",
3
+ "version": "4.4.16",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ COMPLAINCE_ISSUE: 'complianceIssue',
3
+ DRAFT: 'draft',
4
+ MUTED: 'muted'
5
+ };
@@ -5,6 +5,8 @@ const Endpoints = {
5
5
  getPolicyFilesForVendorReport: requestId => `${backendUrl}/saas/request/${requestId}/policy-files`,
6
6
  getPreSignedUrlByPolicyId: policyFileId => `${backendUrl}/saas/policy-file/${policyFileId}`,
7
7
  getAuditPolicyFilesByAuditId: (recordId, auditId) => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/${auditId}/policy-files`,
8
+ unpublishPolicyFile: `${backendUrl}/saas/policy-file/unpublish`,
9
+ publishPolicyFile: `${backendUrl}/saas/policy-file/publish`,
8
10
  getPolicyFilesRequireAudit: recordId => `${backendUrl}/saas/integration-tests/record/${recordId}/policy-files-to-audit`
9
11
  };
10
12
  const getPolicyFilesForVendorReport = async (requestId, context) => {
@@ -19,6 +21,14 @@ const getAuditPolicyFiles = async (recordId, auditId, context) => {
19
21
  return requests.getRequestHandler(Endpoints.getAuditPolicyFilesByAuditId(recordId, auditId), {}, context);
20
22
  };
21
23
 
24
+ const unpublishPolicyFile = async (unpublishPolicyFileModel, context) => {
25
+ return requests.putRequestHandler(Endpoints.unpublishPolicyFile, unpublishPolicyFileModel, context);
26
+ };
27
+
28
+ const publishPolicyFile = async (publishPolicyFileModel, context) => {
29
+ return requests.putRequestHandler(Endpoints.publishPolicyFile, publishPolicyFileModel, context);
30
+ };
31
+
22
32
  const getPolicyFilesRequireAudit = async (recordId, context) => {
23
33
  return requests.getRequestHandler(Endpoints.getPolicyFilesRequireAudit(recordId), {}, context);
24
34
  };
@@ -27,5 +37,7 @@ module.exports = {
27
37
  getPolicyFilesForVendorReport,
28
38
  getPreSignedUrlByPolicyId,
29
39
  getAuditPolicyFiles,
40
+ unpublishPolicyFile,
41
+ publishPolicyFile,
30
42
  getPolicyFilesRequireAudit
31
43
  };
@@ -1,5 +1,6 @@
1
1
  const policyFileApi = require('./policy.file.api');
2
2
  const timeUtils = require('../../../../common/utils/timeUtils');
3
+ const { PolicyFileToSetPublishFlagRequestBodyModel } = require('../models/set.publish.flag.to.policy.model');
3
4
 
4
5
  const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
5
6
 
@@ -33,6 +34,46 @@ const getAuditPolicyFiles = async (recordId, auditId, context) => {
33
34
  return getAuditPolicyFilesResponse;
34
35
  };
35
36
 
37
+ const unpublishPolicyFile = async (unpublishPolicyFileModel, context, { shouldExpectError } = {}) => {
38
+ const unpublishResponse = await policyFileApi.unpublishPolicyFile(unpublishPolicyFileModel, context);
39
+
40
+ if (unpublishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
41
+ throw new Error(`Failed to unpublish policy file - ${unpublishPolicyFileModel.policyFileId}`);
42
+ }
43
+
44
+ return unpublishResponse;
45
+ };
46
+
47
+ const publishPolicyFile = async (publishPolicyFileModel, context, { shouldExpectError } = {}) => {
48
+ const publishResponse = await policyFileApi.publishPolicyFile(publishPolicyFileModel, context);
49
+
50
+ if (publishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
51
+ throw new Error(`Failed to unpublish policy file - ${publishPolicyFileModel.policyFileId}`);
52
+ }
53
+
54
+ return publishResponse;
55
+ };
56
+
57
+ const getSetPublishFlagToPolicyFileModel = async (requestId, policyFileId, context) => {
58
+ const { isPublished, dateModified } = await getPolicyDetailsForPublishModel(requestId, policyFileId, context);
59
+
60
+ return new PolicyFileToSetPublishFlagRequestBodyModel(policyFileId, isPublished, dateModified);
61
+ };
62
+
63
+ const getPolicyDetailsForPublishModel = async (requestId, policyFileId, context) => {
64
+ const getPoliciesResponse = await getPolicyFilesForVendorReport(requestId, context);
65
+
66
+ for (const policy of getPoliciesResponse.data) {
67
+ if (policy.policyFileId === policyFileId) {
68
+ return {
69
+ isPublished: policy.isPublished,
70
+ dateModified: policy.dateModified
71
+ };
72
+ }
73
+ }
74
+ throw new Error(`No match found for policy file id: ${policyFileId}`);
75
+ };
76
+
36
77
  const getPolicyFilesIfExist = async (recordId, context) => {
37
78
  let retries = 10;
38
79
  let policiesToReviewResponse;
@@ -69,5 +110,8 @@ module.exports = {
69
110
  getPolicyFilesForVendorReport,
70
111
  getPreSignedUrlByPolicyId,
71
112
  getAuditPolicyFiles,
113
+ getSetPublishFlagToPolicyFileModel,
114
+ unpublishPolicyFile,
115
+ publishPolicyFile,
72
116
  getPolicyFilesRequireAudit
73
117
  };
@@ -0,0 +1,13 @@
1
+ class PolicyFileToSetPublishFlagRequestBodyModel {
2
+ constructor(
3
+ policyFileId,
4
+ isPublished,
5
+ policyFileDateModified
6
+ ) {
7
+ this.policyFileId = policyFileId;
8
+ this.isPublished = isPublished;
9
+ this.policyFileDateModified = policyFileDateModified;
10
+ }
11
+ }
12
+
13
+ module.exports = { PolicyFileToSetPublishFlagRequestBodyModel };
@@ -7,6 +7,7 @@ const { RequestModel } = require('../models/edit.request.model');
7
7
  const { validateType } = require('../../../../common/validations/typeValidations');
8
8
  const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
9
9
  const activationStatuses = require('../../../../common/consts/activationStatuses');
10
+ const { HomepageRequestCriteriaModel } = require('../models/homepageRequestCriteriaModel');
10
11
 
11
12
  const createRequest = async (createRequestModel, context) => {
12
13
  validateType(createRequestModel, CreateRequestModel);
@@ -179,9 +180,18 @@ const getInnerPageRequests = async (requestListCriteriaModel, context) => {
179
180
  return response.data;
180
181
  };
181
182
 
182
- const getHomePageRequests = async (requestListCriteriaModel, context) => {
183
- validateType(requestListCriteriaModel, RequestListCriteriaModel);
184
- const response = await requestsAPI.getHomePageRequests(requestListCriteriaModel, context);
183
+ const getHomePageRequests = async (context, { sortBy, sortOrder, pageNumber, attentionTab, shouldExceptError } = {}) => {
184
+ const homepageRequestCriteriaModel = new HomepageRequestCriteriaModel({ sortBy, sortOrder, attentionTab, pageNumber });
185
+ return getHomePageRequestsByModel(homepageRequestCriteriaModel, context, shouldExceptError);
186
+ };
187
+
188
+ const getHomePageRequestsByModel = async (homepageRequestCriteriaModel, context, shouldExceptError) => {
189
+ validateType(homepageRequestCriteriaModel, HomepageRequestCriteriaModel);
190
+ const response = await requestsAPI.getHomePageRequests(homepageRequestCriteriaModel, context);
191
+
192
+ if (shouldExceptError) {
193
+ return response;
194
+ }
185
195
 
186
196
  if (response.status !== httpResponseStatusCodes.OK) {
187
197
  throw Error(`Get requests home page has fail\n${response}`);
@@ -190,6 +200,16 @@ const getHomePageRequests = async (requestListCriteriaModel, context) => {
190
200
  return response.data;
191
201
  };
192
202
 
203
+ const getHomePageRequestsCount = async context => {
204
+ const response = await requestsAPI.getHomePageRequestsCount(context);
205
+
206
+ if (response.status !== httpResponseStatusCodes.OK) {
207
+ throw Error(`Get requests count home page has fail\n${response}`);
208
+ }
209
+
210
+ return response.data;
211
+ };
212
+
193
213
  const getAllRequestsByName = async (recordName, accountId, context) => {
194
214
  const { data: requestsInAccount } = await requestsAPI.getRequestsByAccountId(accountId, context);
195
215
  const requests = requestsInAccount.filter(requests => requests.record.company === recordName);
@@ -265,6 +285,7 @@ module.exports = {
265
285
  getRequestFromTabByRecordId,
266
286
  getInnerPageRequests,
267
287
  getHomePageRequests,
288
+ getHomePageRequestsCount,
268
289
  getAllRequestsByName,
269
290
  getRequestByName,
270
291
  getDraftRequestList,
@@ -0,0 +1,19 @@
1
+ const AttentionTab = require('../../../../common/consts/homepage/AttentionTab');
2
+
3
+ class HomepageRequestCriteriaModel {
4
+ constructor({
5
+ sortBy,
6
+ sortOrder,
7
+ attentionTab = AttentionTab.COMPLAINCE_ISSUE,
8
+ pageNumber = 1
9
+ } = {}) {
10
+ this.sortBy = sortBy,
11
+ this.sortOrder = sortOrder,
12
+ this.attentionTab = attentionTab,
13
+ this.pageNo = pageNumber;
14
+ }
15
+ }
16
+
17
+ module.exports = {
18
+ HomepageRequestCriteriaModel
19
+ };
@@ -54,7 +54,7 @@ const getTenantUserByEmail = async (projectId, email, context) => {
54
54
  const getOrCreateTenantUser = async (projectId, email, company, requestId, context, { fullName = 'Tenant User', password = credentials.strongPassword, toSignUp = true, expectError } = {}) => {
55
55
  let tenantUser = await getTenantUserByEmail(projectId, email, context);
56
56
 
57
- if (tenantUser && tenantUser.subuserId && tenantUser.isVerified) {
57
+ if (tenantUser && tenantUser.id && tenantUser.isVerified) {
58
58
  return tenantUser;
59
59
  }
60
60
 
@@ -90,10 +90,10 @@ const getOrCreateTenantUser = async (projectId, email, company, requestId, conte
90
90
  const removeAllTenantUsersFromProject = async (projectId, context) => {
91
91
  const tenantsListInProjects = await getTenantUsersByProjectId(projectId, context);
92
92
  for (const tenant of tenantsListInProjects) {
93
- const deleteInviteResponse = await removeTenantUser(projectId, tenant.subuserId, context);
93
+ const deleteInviteResponse = await removeTenantUser(projectId, tenant.id, context);
94
94
  expect(deleteInviteResponse.status, 'Failed to delete user invite').to.equal(httpResponseStatusCodes.OK);
95
95
 
96
- const deleteUserResponse = await users.removeAllUserTraceFromDb(tenant.subuserId, context);
96
+ const deleteUserResponse = await users.removeAllUserTraceFromDb(tenant.id, context);
97
97
  expect(deleteUserResponse.status, 'Failed to completely delete user from DB').to.equal(httpResponseStatusCodes.NO_CONTENT);
98
98
  }
99
99
  };