@getjones/test-infra 5.3.1 → 5.3.2

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": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -7,10 +7,6 @@ module.exports = {
7
7
  on: { isAccountRequirementsEnabled: true },
8
8
  off: { isAccountRequirementsEnabled: false }
9
9
  },
10
- isWeeklyDigestEnabled: {
11
- on: { isWeeklyDigestEnabled: true },
12
- off: { isWeeklyDigestEnabled: false }
13
- },
14
10
  isPolicyVerificationEnabled: {
15
11
  on: { hasPolicyVerification: true },
16
12
  off: { hasPolicyVerification: false }
package/src/index.js CHANGED
@@ -48,7 +48,6 @@ const getInternalAPI = () => {
48
48
 
49
49
  const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
50
50
  const schedulerJobRun = require('./saas/internal-api/schedulerJobRun');
51
- const weeklyDigest = require('./saas/internal-api/weeklyDigest');
52
51
  const certificial = require('./saas/internal-api/certificial');
53
52
  const dbEmails = require('./saas/internal-api/dbEmails/index');
54
53
  const agreement = require('./saas/internal-api/agreement/index');
@@ -90,7 +89,6 @@ const getInternalAPI = () => {
90
89
  sampleCoi,
91
90
  threadScheduler,
92
91
  schedulerJobRun,
93
- weeklyDigest,
94
92
  certificial,
95
93
  dbEmails,
96
94
  emailCustomization,
@@ -289,7 +289,6 @@ const getAllRecords = async (accountId, context, {
289
289
  sortOrder,
290
290
  pageNum,
291
291
  rowsPerPage,
292
- digestScope,
293
292
  expectError
294
293
  } = {}) => {
295
294
  const model = new accountDirectoryModels.AllRecordsTableRequestModel({
@@ -305,8 +304,7 @@ const getAllRecords = async (accountId, context, {
305
304
  sortBy,
306
305
  sortOrder,
307
306
  pageNum,
308
- rowsPerPage,
309
- digestScope
307
+ rowsPerPage
310
308
  });
311
309
 
312
310
  const response = await accountDirectoryAPI.getAllRecords(model, context);
@@ -331,7 +329,6 @@ const selectAllRecords = async (accountId, context, {
331
329
  selectedTagIds,
332
330
  expiryDateFrom,
333
331
  expiryDateTo,
334
- digestScope,
335
332
  expectError
336
333
  } = {}) => {
337
334
  const model = new accountDirectoryModels.AllRecordsTableRequestModel({
@@ -343,8 +340,7 @@ const selectAllRecords = async (accountId, context, {
343
340
  selectedRequirementIds,
344
341
  selectedTagIds,
345
342
  expiryDateFrom,
346
- expiryDateTo,
347
- digestScope
343
+ expiryDateTo
348
344
  });
349
345
 
350
346
  const response = await accountDirectoryAPI.selectAllRecords(model, context);
@@ -401,7 +397,6 @@ const exportAllRecords = async (accountId, context, {
401
397
  expiryDateTo,
402
398
  sortBy,
403
399
  sortOrder,
404
- digestScope,
405
400
  expectError
406
401
  } = {}) => {
407
402
  const model = new accountDirectoryModels.AllRecordsTableRequestModel({
@@ -415,8 +410,7 @@ const exportAllRecords = async (accountId, context, {
415
410
  expiryDateFrom,
416
411
  expiryDateTo,
417
412
  sortBy,
418
- sortOrder,
419
- digestScope
413
+ sortOrder
420
414
  });
421
415
 
422
416
  const response = await accountDirectoryAPI.exportAllRecords(model, context);
@@ -80,8 +80,7 @@ class AllRecordsTableRequestModel {
80
80
  sortBy = ALL_RECORDS_TABLE_SORT_BY.COMPANY_NAME,
81
81
  sortOrder = 'ASC',
82
82
  pageNum = 1,
83
- rowsPerPage = ROWS_PER_PAGE.TEN,
84
- digestScope = undefined
83
+ rowsPerPage = ROWS_PER_PAGE.TEN
85
84
  } = {}) {
86
85
  this.accountId = accountId;
87
86
  this.searchTerm = searchTerm;
@@ -96,7 +95,6 @@ class AllRecordsTableRequestModel {
96
95
  this.sortOrder = sortOrder;
97
96
  this.pageNum = pageNum;
98
97
  this.rowsPerPage = rowsPerPage;
99
- this.digestScope = digestScope;
100
98
  }
101
99
  }
102
100
 
@@ -55,15 +55,7 @@ const EMAIL_SUBJECT = {
55
55
  overrideGapRequestRejected: ({ accountName }) => `${accountName} denied your exception request`,
56
56
  overrideGapRequestApproved: ({ accountName }) => `${accountName} approved your exception request`,
57
57
  timedOverrideExpired: ({ recordCompanyName, requesterName }) => `Override ended - ${recordCompanyName} in ${requesterName}`,
58
- allRecordsExport: 'Jones - All Records Export',
59
- weeklyDigest: ({ accountName }) => `Your Weekly updates for ${accountName}`
60
- };
61
-
62
- const EMAIL_LINK_REGEX = {
63
- mailActionButton: /(https:\/\/[a-zA-Z0-9.].*[a-zA-Z.]+\/CheckCustomersInviteLinkJSON\?data=[^"]+)/g,
64
- sampleCoiDownload: /\/sample-coi\/requirement\/([^/]+)\/download\?source=email/,
65
- allRecordsExportDownload: /href="(https?:\/\/[^"]+)"/,
66
- weeklyDigestViewAll: issue => new RegExp(`(https:\\/\\/[^"]+\\/all-records\\?digestIssue=${issue}[^"]*)`)
58
+ allRecordsExport: 'Jones - All Records Export'
67
59
  };
68
60
 
69
61
  const EMAIL_POLLING = {
@@ -71,4 +63,4 @@ const EMAIL_POLLING = {
71
63
  expectNoMail: { maxRetries: 3, pollIntervalSeconds: 1 }
72
64
  };
73
65
 
74
- module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, EMAIL_LINK_REGEX, EMAIL_POLLING, tenantUserExtension };
66
+ module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, EMAIL_POLLING, tenantUserExtension };
@@ -62,6 +62,10 @@ const getEmailTextInSubject = (recordCompanyName, emailType, isAfterUpdateRequir
62
62
  return isAfterUpdateRequirements ? `Updated Requirements - ${subject}` : subject;
63
63
  };
64
64
 
65
+ const getMailActionButtonUrlRegex = () => {
66
+ return /(https:\/\/[a-zA-Z0-9.].*[a-zA-Z.]+\/CheckCustomersInviteLinkJSON\?data=[^"]+)/g;
67
+ };
68
+
65
69
  const getEncryptedDataFromLink = (link, { removeLastTwoCharts } = {}) => {
66
70
  const encryptedData = link.split('data=').pop();
67
71
  return removeLastTwoCharts ? encryptedData.slice(0, -2) : encryptedData;
@@ -73,5 +77,6 @@ module.exports = {
73
77
  extractEmailFromNameAndEmailFormat,
74
78
  logRetrievedEmailInfo,
75
79
  getEmailTextInSubject,
80
+ getMailActionButtonUrlRegex,
76
81
  getEncryptedDataFromLink
77
82
  };
@@ -66,9 +66,6 @@ module.exports = {
66
66
  requireScope(entityIds, schedulerJobs.CERTIFICIAL_MONITORING);
67
67
  return runSchedulerJob({ jobType: schedulerJobs.CERTIFICIAL_MONITORING, entityIds });
68
68
  },
69
- runJobForWeeklyDigest: function(entityIds) {
70
- return runSchedulerJob({ jobType: schedulerJobs.WEEKLY_DIGEST, entityIds });
71
- },
72
69
  runAllJobsNew: function(entityIds) {
73
70
  return runSchedulerJob({ jobType: schedulerJobs.ALL, entityIds });
74
71
  }
@@ -6,6 +6,5 @@ module.exports = {
6
6
  EXPIRE_TIMED_OVERRIDES: 'EXPIRE_TIMED_OVERRIDES',
7
7
  CERTIFICIAL_ENROLLMENT: 'CERTIFICIAL_ENROLLMENT',
8
8
  CERTIFICIAL_MONITORING: 'CERTIFICIAL_MONITORING',
9
- WEEKLY_DIGEST: 'WEEKLY_DIGEST',
10
9
  ALL: 'ALL'
11
10
  };
@@ -1,32 +0,0 @@
1
- const requests = require('../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- snapshot: `${backendUrl}/saas/integration-tests/weekly-digest/snapshot`,
6
- accountSnapshot: accountId => `${backendUrl}/saas/integration-tests/weekly-digest/account/${accountId}/snapshot`,
7
- run: accountId => `${backendUrl}/saas/integration-tests/weekly-digest/account/${accountId}/run`,
8
- reportLog: `${backendUrl}/saas/integration-tests/weekly-digest/report-log`
9
- };
10
-
11
- const takeAccountSnapshot = (accountId, context) => {
12
- return requests.postRequestHandler(Endpoints.accountSnapshot(accountId), null, context);
13
- };
14
-
15
- const takeAccountsSnapshot = (accountIds, context) => {
16
- return requests.postRequestHandler(Endpoints.snapshot, { accountIds }, context);
17
- };
18
-
19
- const runWeeklyDigest = (accountId, body, context) => {
20
- return requests.postRequestHandler(Endpoints.run(accountId), body, context);
21
- };
22
-
23
- const getWeeklyDigestReports = (accountId, weekStart, context) => {
24
- return requests.getRequestHandler(Endpoints.reportLog, { accountId, weekStart }, context);
25
- };
26
-
27
- module.exports = {
28
- takeAccountSnapshot,
29
- takeAccountsSnapshot,
30
- runWeeklyDigest,
31
- getWeeklyDigestReports
32
- };
@@ -1,69 +0,0 @@
1
- const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
2
- const timeUtils = require('../../../../common/utils/timeUtils');
3
-
4
- const authService = require('../../auth/api/auth.service');
5
- const weeklyDigestApi = require('./weekly.digest.api');
6
- const { REPORT_STATUS } = require('../consts/weekly.digest.consts');
7
-
8
- const takeAccountSnapshot = async accountId => {
9
- const response = await weeklyDigestApi.takeAccountSnapshot(accountId, await authService.getIcsCookie());
10
-
11
- if (response.status !== httpResponseStatusCodes.OK) {
12
- throw new Error(`Account snapshot failed for account ${accountId}. Status code: ${response.status}`);
13
- }
14
-
15
- return response.data.snapshotId;
16
- };
17
-
18
- const takeAccountsSnapshot = async accountIds => {
19
- const response = await weeklyDigestApi.takeAccountsSnapshot(accountIds, await authService.getIcsCookie());
20
-
21
- if (response.status !== httpResponseStatusCodes.OK) {
22
- throw new Error(`Accounts snapshot failed for accounts ${accountIds}. Status code: ${response.status}`);
23
- }
24
-
25
- return response.data.snapshotId;
26
- };
27
-
28
- // Runs synchronously for next Monday's week, after clearing the account's report-log rows for that week.
29
- const runWeeklyDigest = async (accountId, { previousRunId, currentRunId }) => {
30
- const body = { beforeSnapshotId: previousRunId, afterSnapshotId: currentRunId };
31
- const response = await weeklyDigestApi.runWeeklyDigest(accountId, body, await authService.getIcsCookie());
32
-
33
- if (response.status !== httpResponseStatusCodes.OK) {
34
- throw new Error(`Weekly digest run failed for account ${accountId}. Status code: ${response.status}`);
35
- }
36
-
37
- return response.data;
38
- };
39
-
40
- const getWeeklyDigestReports = async (accountId, weekStart) => {
41
- const response = await weeklyDigestApi.getWeeklyDigestReports(accountId, weekStart, await authService.getIcsCookie());
42
-
43
- if (response.status !== httpResponseStatusCodes.OK) {
44
- throw new Error(`Weekly digest reports failed for account ${accountId}. Status code: ${response.status}`);
45
- }
46
-
47
- return response.data;
48
- };
49
-
50
- // The scheduler endpoint returns before the job runs, so a real-job run has to poll the report log.
51
- const waitForWeeklyDigestReport = async (accountId, weekStart, userId, { expectedStatus = REPORT_STATUS.SENT, retries = 10 } = {}) => {
52
- let report;
53
-
54
- while (report?.reportData.status !== expectedStatus && retries-- > 0) {
55
- await timeUtils.waitFor(3).seconds;
56
- const reports = await getWeeklyDigestReports(accountId, weekStart);
57
- report = reports.find(row => row.userId === userId);
58
- }
59
-
60
- return report;
61
- };
62
-
63
- module.exports = {
64
- takeAccountSnapshot,
65
- takeAccountsSnapshot,
66
- runWeeklyDigest,
67
- getWeeklyDigestReports,
68
- waitForWeeklyDigestReport
69
- };
@@ -1,21 +0,0 @@
1
- const REPORT_STATUS = {
2
- IN_PROGRESS: 'IN_PROGRESS',
3
- SENT: 'SENT',
4
- NO_VISIBLE_REQUESTS: 'NO_VISIBLE_REQUESTS'
5
- };
6
-
7
- const NEW_ISSUE_TYPE = {
8
- EXPIRED_LAST_WEEK: 'EXPIRED_LAST_WEEK',
9
- BECAME_NOT_COMPLIANT: 'BECAME_NOT_COMPLIANT',
10
- EXPIRING_THIS_WEEK: 'EXPIRING_THIS_WEEK',
11
- BECAME_NOT_RESPONSIVE: 'BECAME_NOT_RESPONSIVE'
12
- };
13
-
14
- const ACTIVITY_TYPE = {
15
- TIMED_OVERRIDE_ENDING: 'TIMED_OVERRIDE_ENDING',
16
- EXCEPTION_REQUEST: 'EXCEPTION_REQUEST',
17
- MENTION: 'MENTION',
18
- RELATED_DOC: 'RELATED_DOC'
19
- };
20
-
21
- module.exports = { REPORT_STATUS, NEW_ISSUE_TYPE, ACTIVITY_TYPE };
@@ -1,4 +0,0 @@
1
- const services = require('./api/weekly.digest.service');
2
- const consts = require('./consts/weekly.digest.consts');
3
-
4
- module.exports = { services, consts };