sr-npm 1.7.449 → 1.7.451

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.
@@ -71,16 +71,6 @@ const COLLECTIONS_FIELDS = {
71
71
  ],
72
72
  };
73
73
 
74
- const TEMPLATE_TYPE = {
75
- INTERNAL: 'INTERNAL',
76
- EXTERNAL: 'PUBLIC',
77
- }
78
-
79
- const TOKEN_NAME = {
80
- COMPANY_ID: 'companyId',
81
- SMART_TOKEN: 'x-smarttoken',
82
- }
83
-
84
74
 
85
75
  module.exports = {
86
76
  COLLECTIONS,
@@ -88,6 +78,4 @@ const COLLECTIONS_FIELDS = {
88
78
  JOBS_COLLECTION_FIELDS,
89
79
  AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS,
90
80
  CITIES_COLLECTION_FIELDS,
91
- TEMPLATE_TYPE,
92
- TOKEN_NAME,
93
81
  };
package/backend/consts.js CHANGED
@@ -73,7 +73,15 @@ const TASKS = {
73
73
  }
74
74
 
75
75
 
76
+ const TEMPLATE_TYPE = {
77
+ INTERNAL: 'INTERNAL',
78
+ EXTERNAL: 'PUBLIC',
79
+ }
76
80
 
81
+ const TOKEN_NAME = {
82
+ COMPANY_ID: 'companyId',
83
+ SMART_TOKEN: 'x-smarttoken',
84
+ }
77
85
 
78
86
  const TASK_TYPE = {
79
87
  SCHEDULED: 'scheduled',
@@ -85,4 +93,6 @@ const TASK_TYPE = {
85
93
  TASK_TYPE,
86
94
  TASKS,
87
95
  QUERY_MAX_LIMIT,
96
+ TEMPLATE_TYPE,
97
+ TOKEN_NAME
88
98
  };
package/backend/data.js CHANGED
@@ -1,9 +1,10 @@
1
1
  const { items: wixData } = require('@wix/data');
2
2
  const { fetchPositionsFromSRAPI, fetchJobDescription } = require('./fetchPositionsFromSRAPI');
3
3
  const { createCollectionIfMissing } = require('@hisense-staging/velo-npm/backend');
4
- const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS,TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
4
+ const { COLLECTIONS, COLLECTIONS_FIELDS,JOBS_COLLECTION_FIELDS } = require('./collectionConsts');
5
5
  const { chunkedBulkOperation, countJobsPerGivenField, fillCityLocationAndLocationAddress ,prepareToSaveArray,normalizeCityName} = require('./utils');
6
6
  const { getAllPositions } = require('./queries');
7
+ const{TEMPLATE_TYPE,TOKEN_NAME} = require('./consts');
7
8
  const { getCompanyId, getSmartToken } = require('./secretsData');
8
9
 
9
10
  function validatePosition(position) {
@@ -344,18 +345,16 @@ async function clearCollections() {
344
345
 
345
346
  async function markTemplateAsExternal() {
346
347
  await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
347
- const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
348
+ await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
348
349
  templateType: TEMPLATE_TYPE.EXTERNAL
349
350
  });
350
- return tempalte;
351
351
  }
352
352
 
353
353
  async function markTemplateAsInternal() {
354
354
  await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
355
- const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
355
+ await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
356
356
  templateType: TEMPLATE_TYPE.INTERNAL
357
357
  });
358
- return tempalte;
359
358
  }
360
359
 
361
360
  async function fillSecretManagerMirror() {
@@ -1,6 +1,8 @@
1
1
  const { fetch } = require('wix-fetch');
2
2
  const { items: wixData } = require('@wix/data');
3
- const { COLLECTIONS,TEMPLATE_TYPE,TOKEN_NAME } = require('./collectionConsts');
3
+ const { COLLECTIONS } = require('./collectionConsts');
4
+ const { TEMPLATE_TYPE,TOKEN_NAME } = require('./consts');
5
+
4
6
  async function makeSmartRecruitersRequest(path,templateType) {
5
7
  const baseUrl = 'https://api.smartrecruiters.com';
6
8
  const fullUrl = `${baseUrl}${path}`;
@@ -32,18 +34,12 @@ async function makeSmartRecruitersRequest(path,templateType) {
32
34
  }
33
35
  }
34
36
 
35
- async function fetchPositionsFromSRAPI(testObject=undefined) {
37
+ async function fetchPositionsFromSRAPI(companyID=undefined) {
36
38
  let allPositions = [];
37
39
  let totalFound = 0;
38
40
  let page = 0;
39
41
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
40
-
41
- let companyId, templateType;
42
- if (testObject) {
43
- ({ companyId, templateType } = testObject);
44
- } else {
45
- ({ companyId, templateType } = await getApiKeys());
46
- }
42
+ const {companyId,templateType} = await getApiKeys();
47
43
  console.log('Starting to fetch all positions with pagination...');
48
44
  let offset=0;
49
45
 
@@ -103,15 +99,6 @@ async function fetchPositionsFromSRAPI(testObject=undefined) {
103
99
  return result;
104
100
  }
105
101
 
106
- // async function fetchJobDescription(jobId,testObject=undefined) {
107
- // let companyId, templateType;
108
- // if (testObject) {
109
- // ({ companyId, templateType } = testObject);
110
- // } else {
111
- // ({ companyId, templateType } = await getApiKeys());
112
- // }
113
- // return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
114
- // }
115
102
  async function fetchJobDescription(jobId) {
116
103
  const {companyId,templateType} = await getApiKeys();
117
104
  return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
@@ -11,17 +11,11 @@ function getSmartToken() {
11
11
  }
12
12
 
13
13
  function getCompanyId() {
14
- console.log("Getting the company ID from the secrets");
15
- const getSecretValue2 = auth.elevate(secrets.getSecretValue);
16
- console.log("getSecretValue2 is : ", getSecretValue2);
17
-
18
- return getSecretValue2("companyID")
14
+ console.log("Getting the#$#@@$# company ID from the secrets");
15
+ return getSecretValue("companyID")
19
16
  .then((secret) => {
20
17
  return secret;
21
- }).catch((error) => {
22
- console.error("Error getting the company ID from the secrets: ", error);
23
- throw error;
24
- });
18
+ })
25
19
  }
26
20
  module.exports = {
27
21
  getCompanyId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.449",
3
+ "version": "1.7.451",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,74 +1,59 @@
1
- const { executeApiRequest } = require('tests-utils');
2
- const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
3
-
4
- describe('Job details fetch from SR API Tests', () => {
5
-
6
- const templateTypes = [
7
- { templatename: 'External', templateType: 'PUBLIC'},
8
- { templatename: 'Internal', templateType: 'INTERNAL'}
9
- ];
10
-
11
- templateTypes.forEach(({ templateType ,templatename}) => {
12
- describe(`Job details fetch from SR API Tests - ${templatename}`, () => {
13
- let positions;
14
- beforeAll(async () => {
15
- const fetchPositionsFromSRAPIRequestBody = `fetchPositionsFromSRAPI({companyId:'WixTest',templateType: '${templateType}'});`;
16
- positions = await executeApiRequest(fetchPositionsFromSRAPIRequestBody);
17
- });
18
-
19
-
20
- test(`should successfully fetch job details from SR API (${templatename})`, async () => {
21
- const randomPosition = getRandomPosition(positions.data.result.content);
22
- expect(positions.data.result.totalFound).toBeGreaterThan(0);
23
- expect(positions.data.result.content.length).toBeGreaterThan(0);
24
- expect(randomPosition.id.length).toBeGreaterThan(0);
25
- expect(randomPosition.name.length).toBeGreaterThan(0);
26
- expect(randomPosition.jobAdId.length).toBeGreaterThan(0);
27
- expect(randomPosition.location).toBeDefined();
28
- expect(randomPosition.department).toBeDefined();
29
- });
30
-
31
- test(`should successfully fetch job description from SR API (${templatename})`, async () => {
32
- const randomPosition = getRandomPosition(positions.data.result.content);
33
- const fetchJobDescriptionRequestBody = `fetchJobDescription(${randomPosition.id},{companyId:'WixTest',templateType: '${templateType}'});`;
34
- const jobFetchResponse = await executeApiRequest(fetchJobDescriptionRequestBody);
35
- expect(jobFetchResponse.data.result.id).toBe(randomPosition.id);
36
- expect(jobFetchResponse.data.result.jobAd.sections.jobDescription).toBeDefined();
37
- expect(jobFetchResponse.data.result.jobAd.sections.jobDescription.text.length).toBeGreaterThan(0);
38
- expect(jobFetchResponse.data.result.applyUrl.length).toBeGreaterThan(0);
39
- expect(jobFetchResponse.data.result.location).toBeDefined();
40
- });
41
- });
42
- });
43
- });
44
-
45
- describe('fetchPositionsFromSRAPI error handling', () => {
46
- test('should throw error if invalid companyId is found external template', async () => {
47
- const requestBody = `fetchPositionsFromSRAPI({companyId: 'invalid_company_id',templateType: 'EXTERNAL'});`;
48
- executeRequestAndTest(requestBody)
49
- });
50
-
51
- test('should throw error if invalid companyId is found internal template', async () => {
52
- const requestBody = `fetchPositionsFromSRAPI({companyId: 'invalid_company_id',templateType: 'INTERNAL'});`;
53
- executeRequestAndTest(requestBody)
54
- });
55
-
56
- test('should throw error when a bad URL is used', async () => {
57
- const requestBody = `makeSmartRecruitersRequest('/v1/error/companyId/postings');`;
58
- executeRequestAndTest(requestBody)
59
- });
60
-
61
-
62
-
63
- });
64
-
65
- describe('fetchJobDescription error handling', () => {
66
- test('should throw error if invalid jobId is given', async () => {
67
- const requestBody = `fetchJobDescription('invalid_job_id');`;
68
- executeRequestAndTest(requestBody)
69
- });
70
- test('should throw error when given a valid but wrong jobId is given', async () => {
71
- const requestBody = `fetchJobDescription('1234567890');`;
72
- executeRequestAndTest(requestBody)
73
- });
74
- });
1
+ // const { executeApiRequest } = require('tests-utils');
2
+ // const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
3
+
4
+ // describe('Job details fetch from SR API Tests', () => {
5
+
6
+ // let positions;
7
+ // beforeAll(async () => {
8
+ // const requestBody = `fetchPositionsFromSRAPI();`;
9
+ // positions = await executeApiRequest(requestBody);
10
+ // });
11
+
12
+ // test('should successfully fetch job details from SR API', async () => {
13
+ // const randomPosition = getRandomPosition(positions.data.result.content);
14
+ // expect(positions.data.result.totalFound).toBeGreaterThan(0);
15
+ // expect(positions.data.result.content.length).toBeGreaterThan(0);
16
+ // expect(randomPosition.id.length).toBeGreaterThan(0);
17
+ // expect(randomPosition.name.length).toBeGreaterThan(0);
18
+ // expect(randomPosition.jobAdId.length).toBeGreaterThan(0);
19
+ // expect(randomPosition.location).toBeDefined();
20
+ // expect(randomPosition.department).toBeDefined();
21
+ // });
22
+
23
+ // test('should successfully fetch job description from SR API', async () => {
24
+ // const randomPosition = getRandomPosition(positions.data.result.content);
25
+ // const fetchJobDescriptionRequestBody = `fetchJobDescription(${randomPosition.id});`;
26
+ // const jobFetchResponse = await executeApiRequest(fetchJobDescriptionRequestBody);
27
+ // expect(jobFetchResponse.data.result.id).toBe(randomPosition.id);
28
+ // expect(jobFetchResponse.data.result.jobAd.sections.jobDescription).toBeDefined();
29
+ // expect(jobFetchResponse.data.result.jobAd.sections.jobDescription.text.length).toBeGreaterThan(0);
30
+ // expect(jobFetchResponse.data.result.applyUrl.length).toBeGreaterThan(0);
31
+ // expect(jobFetchResponse.data.result.location).toBeDefined();
32
+ // });
33
+ // });
34
+
35
+ // describe('fetchPositionsFromSRAPI error handling', () => {
36
+ // test('should throw error if invalid companyId is found', async () => {
37
+ // const requestBody = `fetchPositionsFromSRAPI('invalid_company_id');`;
38
+ // executeRequestAndTest(requestBody)
39
+ // });
40
+
41
+ // test('should throw error when a bad URL is used', async () => {
42
+ // const requestBody = `makeSmartRecruitersRequest('/v1/error/companyId/postings');`;
43
+ // executeRequestAndTest(requestBody)
44
+ // });
45
+
46
+
47
+
48
+ // });
49
+
50
+ // describe('fetchJobDescription error handling', () => {
51
+ // test('should throw error if invalid jobId is given', async () => {
52
+ // const requestBody = `fetchJobDescription('invalid_job_id');`;
53
+ // executeRequestAndTest(requestBody)
54
+ // });
55
+ // test('should throw error when given a valid but wrong jobId is given', async () => {
56
+ // const requestBody = `fetchJobDescription('1234567890');`;
57
+ // executeRequestAndTest(requestBody)
58
+ // });
59
+ // });
@@ -1,22 +1,24 @@
1
1
  const { executeApiRequest } = require('tests-utils');
2
+ const { items: wixData } = require('@wix/data');
2
3
  const { clearCollections } = require('./testsUtils');
3
4
  const { TEMPLATE_TYPE } = require('./consts');
5
+ const { COLLECTIONS } = require('./consts');
4
6
 
5
7
  beforeAll(async () => {
6
- clearCollections();
8
+ clearCollections(wixData);
7
9
  });
8
10
 
9
11
 
10
12
 
13
+
11
14
  it.each([
12
- { templateName: 'Internal', templateType: TEMPLATE_TYPE.INTERNAL },
13
- { templateName: 'External', templateType: TEMPLATE_TYPE.EXTERNAL },
14
- ])('should successfully mark template as $templateName', async ({ templateName,templateType }) => {
15
- const requestBody = `markTemplateAs${templateName}();`;
16
- const response = await executeApiRequest(requestBody);
17
- expect(response.status).toBe(200);
18
- expect(response.data).toBeDefined();
19
- expect(response.data.result.templateType).toBe(templateType);
15
+ { name: 'internal', templateType: TEMPLATE_TYPE.INTERNAL },
16
+ { name: 'external', templateType: TEMPLATE_TYPE.EXTERNAL },
17
+ ])('should successfully mark template as $name', async ({ templateType }) => {
18
+ const requestBody = `markTemplateAs${templateType}();`;
19
+ await executeApiRequest(requestBody);
20
+ const TemplateTypeFromCMS = await wixData.query(COLLECTIONS.TEMPLATE_TYPE).limit(1).find();
21
+ expect(TemplateTypeFromCMS.items[0].templateType).toBe(templateType);
20
22
  });
21
23
 
22
24
 
@@ -1,6 +1,5 @@
1
1
  const { executeApiRequest } = require('tests-utils');
2
2
  const { COLLECTIONS } = require('./consts');
3
- const { items: wixData } = require('@wix/data');
4
3
 
5
4
  function getRandomPosition(positions) {
6
5
  return positions[Math.floor(Math.random() * positions.length)];
@@ -14,7 +13,7 @@ async function executeRequestAndTest(requestBody) {
14
13
  }
15
14
  }
16
15
 
17
- async function clearCollections() {
16
+ async function clearCollections(wixData) {
18
17
 
19
18
  for (const collection of Object.values(COLLECTIONS)) {
20
19
  await wixData.truncate(collection);