@getjones/test-infra 1.3.0 → 1.3.1

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": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@ const Endpoints = {
12
12
 
13
13
  const audit = async (contractorId, auditRequestModel, context) => {
14
14
  await requests.getRequestHandler(Endpoints.preAudit(contractorId), {}, context);
15
- return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context).then(res => res.data);
15
+ return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context);
16
16
  };
17
17
 
18
18
  const isReaudit = (contractorId, context) => {
@@ -20,15 +20,15 @@ const isReaudit = (contractorId, context) => {
20
20
  };
21
21
 
22
22
  const getAuditorContractorList = (page, accountId, context) => {
23
- return requests.getRequestHandler(Endpoints.auditorContractorList, { page, accountId }, context).then(res => res.data);
23
+ return requests.getRequestHandler(Endpoints.auditorContractorList, { page, accountId }, context);
24
24
  };
25
25
 
26
26
  const getContractorDetailsForAudit = (contractorId, context) => {
27
- return requests.getRequestHandler(Endpoints.contractorDetailsForAudit(contractorId), {}, context).then(res => res.data);
27
+ return requests.getRequestHandler(Endpoints.contractorDetailsForAudit(contractorId), {}, context);
28
28
  };
29
29
 
30
30
  const getRequirementDetailsForAudit = (contractorId, context) => {
31
- return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context).then(res => res.data);
31
+ return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context);
32
32
  };
33
33
 
34
34
  module.exports = {
@@ -2,25 +2,25 @@ const auditApi = require('./audit.api');
2
2
  const { AuditRequestModel } = require('../../models/audit/audit.model');
3
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
4
4
 
5
- const audit = async (auditRequestModel, context) => {
5
+ const audit = (auditRequestModel, context) => {
6
6
  validateType(auditRequestModel, AuditRequestModel);
7
- return await auditApi.audit(auditRequestModel.auditData.contractorId, auditRequestModel, context);
7
+ return auditApi.audit(auditRequestModel.auditData.contractorId, auditRequestModel, context);
8
8
  };
9
9
 
10
10
  const isReaudit = (contractorId, context) => {
11
11
  return auditApi.isReaudit(contractorId, context);
12
12
  };
13
13
 
14
- const getAuditorContractorList = async (page, accountId, context) => {
15
- return await auditApi.getAuditorContractorList(page, accountId, context);
14
+ const getAuditorContractorList = (page, accountId, context) => {
15
+ return auditApi.getAuditorContractorList(page, accountId, context);
16
16
  };
17
17
 
18
- const getContractorDetailsForAudit = async (contractorId, context) => {
19
- return await auditApi.getContractorDetailsForAudit(contractorId, context);
18
+ const getContractorDetailsForAudit = (contractorId, context) => {
19
+ return auditApi.getContractorDetailsForAudit(contractorId, context);
20
20
  };
21
21
 
22
- const getRequirementDetailsForAudit = async (contractorId, context) => {
23
- return await auditApi.getRequirementDetailsForAudit(contractorId, context);
22
+ const getRequirementDetailsForAudit = (contractorId, context) => {
23
+ return auditApi.getRequirementDetailsForAudit(contractorId, context);
24
24
  };
25
25
 
26
26
  module.exports = {
@@ -9,13 +9,13 @@ const Endpoints = {
9
9
  const waive = async (contractorId, waiveRequestModel, context) => {
10
10
  const status = waiveRequestModel.status;
11
11
  delete waiveRequestModel.status;
12
- return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status }).then(res => res.data);
12
+ return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
13
13
  };
14
14
 
15
15
  const retract = async (contractorId, retractRequestModel, context) => {
16
16
  const status = retractRequestModel.status;
17
17
  delete retractRequestModel.status;
18
- return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status }).then(res => res.data);
18
+ return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
19
19
  };
20
20
 
21
21
  module.exports = { waive, retract };
@@ -2,12 +2,12 @@ const waiveApi = require('./waive.api');
2
2
  const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
3
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
4
4
 
5
- const waive = async (waiveRequestModel, context) => {
5
+ const waive = (waiveRequestModel, context) => {
6
6
  validateType(waiveRequestModel, WaiveRequestModel);
7
7
  return waiveApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
8
8
  };
9
9
 
10
- const retract = async (retractRequestModel, context) => {
10
+ const retract = (retractRequestModel, context) => {
11
11
  validateType(retractRequestModel, RetractRequestModel);
12
12
  return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
13
13
  };
@@ -7,7 +7,7 @@ const Endpoints = {
7
7
  createGlobalRecord: `${nodeBackendUrl}/global-record`,
8
8
  getGlobalRecordById: id => `${nodeBackendUrl}/global-record/id/${id}`,
9
9
  getAllGlobalRecords: (pageNumber, itemsInPage) => `${nodeBackendUrl}/global-record/all-global-records/${pageNumber}/items/${itemsInPage}`,
10
- getGlobalRecordServiceArea: `${backendUrl}/saas/global-record/service-areas`,
10
+ getGlobalRecordServiceAreas: `${backendUrl}/saas/global-record/service-areas`,
11
11
  deleteGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
12
12
  updateGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
13
13
  getRecordProfileDetails: id => `${nodeBackendUrl}/global-record/record-profile/id/${id}`
@@ -25,16 +25,16 @@ const getAllGlobalRecords = async (data, pageNumber, itemsInPage, context) => {
25
25
  return cookieAuthRequests.postRequestHandler(Endpoints.getAllGlobalRecords(pageNumber, itemsInPage), data, context);
26
26
  };
27
27
 
28
- const deleteGlobalRecord = async (id, context) => {
29
- return cookieAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), context);
28
+ const deleteGlobalRecord = async (id, nodeBackendSecret) => {
29
+ return apiKeyAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), nodeBackendSecret);
30
30
  };
31
31
 
32
32
  const updateGlobalRecord = async (id, nodeBackendSecret, updatedGlobalRecord) => {
33
33
  return apiKeyAuthRequests.putRequestHandler(Endpoints.updateGlobalRecord(id), nodeBackendSecret, updatedGlobalRecord);
34
34
  };
35
35
 
36
- const getGlobalRecordServiceArea = async context => {
37
- return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordServiceArea, {}, context);
36
+ const getGlobalRecordServiceAreas = async context => {
37
+ return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordServiceAreas, {}, context);
38
38
  };
39
39
 
40
40
  const getRecordProfileDetails = async (id, context) => {
@@ -45,7 +45,7 @@ module.exports = {
45
45
  createGlobalRecord,
46
46
  getGlobalRecord,
47
47
  getAllGlobalRecords,
48
- getGlobalRecordServiceArea,
48
+ getGlobalRecordServiceAreas,
49
49
  deleteGlobalRecord,
50
50
  updateGlobalRecord,
51
51
  getRecordProfileDetails
@@ -17,8 +17,8 @@ const getAllGlobalRecordsInPage = async (pageNumber, context, itemsInPage = 10)
17
17
  return globalRecordAPI.getAllGlobalRecords(param, pageNumber, itemsInPage, context);
18
18
  };
19
19
 
20
- const getAllGlobalRecordsInPageByServiceArea = async (serviceArea, pageNumber, contxet, itemsInPage = 10) => {
21
- const data = Array.isArray(serviceArea) ? { serviceArea } : { serviceArea: new Array(serviceArea) };
20
+ const getAllGlobalRecordsInPageByServiceAreas = async (serviceAreas, pageNumber, contxet, itemsInPage = 10) => {
21
+ const data = Array.isArray(serviceAreas) ? { serviceAreas } : { serviceAreas: new Array(serviceAreas) };
22
22
  return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, contxet);
23
23
  };
24
24
 
@@ -32,12 +32,12 @@ const getAllGlobalRecordsInPageByCombinedSearch = async (combinedSearch, pageNum
32
32
  return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, context);
33
33
  };
34
34
 
35
- const getGlobalRecordServiceArea = async context => {
36
- return globalRecordAPI.getGlobalRecordServiceArea(context);
35
+ const getGlobalRecordServiceAreas = async context => {
36
+ return globalRecordAPI.getGlobalRecordServiceAreas(context);
37
37
  };
38
38
 
39
- const deleteGlobalRecord = async (id, context) => {
40
- return globalRecordAPI.deleteGlobalRecord(id, context);
39
+ const deleteGlobalRecord = async id => {
40
+ return globalRecordAPI.deleteGlobalRecord(id, nodeBackendSecret);
41
41
  };
42
42
 
43
43
  const updateGlobalRecord = async (id, updatedGlobalRecordModel) => {
@@ -52,10 +52,10 @@ module.exports = {
52
52
  createGlobalRecord,
53
53
  getGlobalRecordById,
54
54
  getAllGlobalRecordsInPage,
55
- getAllGlobalRecordsInPageByServiceArea,
55
+ getAllGlobalRecordsInPageByServiceAreas,
56
56
  getAllGlobalRecordsInPageBySearchTerm,
57
57
  getAllGlobalRecordsInPageByCombinedSearch,
58
- getGlobalRecordServiceArea,
58
+ getGlobalRecordServiceAreas,
59
59
  deleteGlobalRecord,
60
60
  updateGlobalRecord,
61
61
  getRecordProfileDetails
@@ -0,0 +1,20 @@
1
+ const SERVICE_AREAS = {
2
+ 'alabama': 'Alabama',
3
+ 'arizona': 'Arizona',
4
+ 'arkansas': 'Arkansas',
5
+ 'california': 'California',
6
+ 'connecticut': 'Connecticut',
7
+ 'delaware': 'Delaware',
8
+ 'florida': 'Florida',
9
+ 'illinois': 'Illinois',
10
+ 'newYork': 'New York',
11
+ 'newJersey': 'New Jersey'
12
+ };
13
+
14
+ const GLOBAL_RECORD_STATUS = {
15
+ newGlobal: 'New Global',
16
+ newInfo: 'New Info',
17
+ published: 'Published'
18
+ };
19
+
20
+ module.exports = { SERVICE_AREAS, GLOBAL_RECORD_STATUS };
@@ -2,7 +2,7 @@ class CreateGlobalRecordModel {
2
2
  constructor(
3
3
  header,
4
4
  expirationDate,
5
- glPolicyNumber,
5
+ glPolicyNumbers,
6
6
  numberOfAssociatedRequests,
7
7
  numberOfFilledMandatory,
8
8
  {
@@ -10,7 +10,7 @@ class CreateGlobalRecordModel {
10
10
  additionalContacts,
11
11
  brokerEmails,
12
12
  publishDate,
13
- serviceArea,
13
+ serviceAreas,
14
14
  primaryEmail,
15
15
  dba,
16
16
  lastPublishUserName
@@ -21,11 +21,11 @@ class CreateGlobalRecordModel {
21
21
  this.additionalContacts = additionalContacts;
22
22
  this.expirationDate = expirationDate;
23
23
  this.publishDate = publishDate;
24
- this.glPolicyNumber = glPolicyNumber;
24
+ this.glPolicyNumbers = glPolicyNumbers;
25
25
  this.numberOfAssociatedRequests = numberOfAssociatedRequests;
26
26
  this.brokerEmails = brokerEmails;
27
27
  this.numberOfFilledMandatory = numberOfFilledMandatory;
28
- this.serviceArea = serviceArea;
28
+ this.serviceAreas = serviceAreas;
29
29
  this.primaryEmail = primaryEmail;
30
30
  this.dba = dba;
31
31
  this.lastPublishUserName = lastPublishUserName;
@@ -0,0 +1,124 @@
1
+ const env = require('../../../../../../../src/env');
2
+ const { internalAPI } = require('../../../..')(env);
3
+ const { globalRecord } = internalAPI;
4
+
5
+ const { CreateGlobalRecordModel } = globalRecord.models;
6
+ const { createGlobalRecord, getAllGlobalRecordsInPage } = globalRecord.services;
7
+
8
+ const { getCapitalLetterUnicodeValueList, getUniqueNumber } = require('../../../../../../../src/utils/numberUtils');
9
+
10
+ const { SERVICE_AREAS } = require('../consts');
11
+
12
+ const createGlobalRecordConfig = (name, { stateIndex, glPolicyNumbers } = {}) => {
13
+ const serviceArea = getServiceAreaByIndex(stateIndex || 0);
14
+ const uniqueNumbers = glPolicyNumbers || getUniqueNumber();
15
+ const emailBase = name.replace(/\s+/g, '').toLowerCase();
16
+ return {
17
+ 'header': `${name}Header`,
18
+ 'recordName': `${name}Name`,
19
+ 'additionalContacts': [`${emailBase}@additional1.jon`, `${emailBase}@additional2.jon`],
20
+ 'brokerEmails': [`${emailBase}@broker1.jon`, `${emailBase}@broker2.jon`],
21
+ 'expirationDate': '2030-12-09',
22
+ 'publishDate': '',
23
+ 'lastPublishUserName': '',
24
+ 'glPolicyNumbers': [uniqueNumbers.toString()],
25
+ 'numberOfAssociatedRequests': 0,
26
+ 'numberOfFilledMandatory': 0,
27
+ 'dba': '',
28
+ 'primaryEmail': '',
29
+ 'serviceAreas': [
30
+ getServiceArea(serviceArea)
31
+ ]
32
+ };
33
+ };
34
+
35
+ const getServiceArea = state => {
36
+ return {
37
+ 'city': `${state}TestCity`,
38
+ 'state': state
39
+ };
40
+ };
41
+
42
+ const createGlobalRecordConfigs = (nameList, { stateIndexes, glPolicyNumbers } = {}) => {
43
+ return nameList.map((name, index) => createGlobalRecordConfig(
44
+ name,
45
+ {
46
+ stateIndex: stateIndexes ? stateIndexes[index] : index,
47
+ glPolicyNumbers: glPolicyNumbers ? glPolicyNumbers[index] : null
48
+ }
49
+ ));
50
+ };
51
+
52
+ const createGlobalRecordModel = config => {
53
+ return new CreateGlobalRecordModel(
54
+ config.header,
55
+ config.expirationDate,
56
+ config.glPolicyNumbers,
57
+ config.numberOfAssociatedRequests,
58
+ config.numberOfFilledMandatory,
59
+ {
60
+ recordName: config.recordName,
61
+ additionalContacts: config.additionalContacts,
62
+ brokerEmails: config.brokerEmails,
63
+ publishDate: config.publishDate,
64
+ serviceAreas: config.serviceAreas,
65
+ primaryEmail: config.primaryEmail,
66
+ dba: config.dba,
67
+ lastPublishUserName: config.lastPublishUserName
68
+ }
69
+ );
70
+ };
71
+
72
+ const createGlobalRecordModels = configList => {
73
+ return configList.map(config => createGlobalRecordModel(config));
74
+ };
75
+
76
+ const getCreateRandomGlobalRecordModels = nameList => {
77
+ const configList = createGlobalRecordConfigs(nameList);
78
+ return createGlobalRecordModels(configList);
79
+ };
80
+
81
+ const createGlobalRecords = async (globalRecordModelList, context) => {
82
+ const newGlobalRecodDetailsList = new Array();
83
+ for (globalRecordModel of globalRecordModelList) {
84
+ const newGlobalRecordDetails = await createGlobalRecord(globalRecordModel, context);
85
+ newGlobalRecodDetailsList.push(newGlobalRecordDetails);
86
+ }
87
+
88
+ return newGlobalRecodDetailsList;
89
+ };
90
+
91
+ const getAllGlobalRecords = async (numberOfPages, context) => {
92
+ const allGlobalRecords = new Array();
93
+
94
+ for (let pageNumber = 1; pageNumber <= numberOfPages; pageNumber++) {
95
+ const allGlobalRecordsInPage = await getAllGlobalRecordsInPage(pageNumber, context);
96
+ allGlobalRecords.push(allGlobalRecordsInPage);
97
+ }
98
+
99
+ return allGlobalRecords;
100
+ };
101
+
102
+ const getServiceAreaByIndex = stateIndex => {
103
+ return SERVICE_AREAS[Object.keys(SERVICE_AREAS)[stateIndex % 10]];
104
+ };
105
+
106
+ const getGlobalRecordsDefaultNameList = (nameBase, listLength) => {
107
+ const letterUnicodeValueList = getCapitalLetterUnicodeValueList({ listLength });
108
+
109
+ //How much times same letter will appear in one index on the array
110
+ const repeatTimes = 4;
111
+ return letterUnicodeValueList.map(unicode => `${nameBase} ${String.fromCharCode(unicode).repeat(repeatTimes)}`);
112
+ };
113
+
114
+ module.exports = {
115
+ createGlobalRecords,
116
+ createGlobalRecordConfig,
117
+ createGlobalRecordConfigs,
118
+ createGlobalRecordModel,
119
+ createGlobalRecordModels,
120
+ getCreateRandomGlobalRecordModels,
121
+ getGlobalRecordsDefaultNameList,
122
+ getAllGlobalRecords,
123
+ getServiceArea
124
+ };