sr-npm 1.7.401 → 1.7.402

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.
@@ -54,7 +54,8 @@ const COLLECTIONS_FIELDS = {
54
54
  {key:'remote', type: 'BOOLEAN'},
55
55
  {key:'jobDescription', type: 'OBJECT'},
56
56
  {key:'cityText', type: 'TEXT'},
57
- {key:'applyLink', type: 'URL'},
57
+ {key:'applyLink', type: 'URL'},
58
+ {key:'referFriendLink', type: 'URL'},
58
59
  {key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT } } },
59
60
  {key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CITIES } } },
60
61
  { key: 'image', type: 'IMAGE' },
package/backend/data.js CHANGED
@@ -120,7 +120,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
120
120
  try {
121
121
  const jobDetails = await fetchJobDescription(job._id);
122
122
  const jobLocation = fetchJobLocation(jobDetails);
123
- const applyLink = fetchApplyLink(jobDetails);
123
+ const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
124
124
 
125
125
 
126
126
  const updatedJob = {
@@ -128,6 +128,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlToCMS() {
128
128
  locationAddress: jobLocation,
129
129
  jobDescription: jobDetails.jobAd.sections,
130
130
  applyLink: applyLink,
131
+ referFriendLink: referFriendLink,
131
132
  };
132
133
  await wixData.update(COLLECTIONS.JOBS, updatedJob);
133
134
  return { success: true, jobId: job._id, title: job.title };
@@ -258,8 +259,8 @@ async function referenceJobsToField({ referenceField, sourceCollection, jobField
258
259
  return { success: true, updated: jobsToUpdate.length };
259
260
  }
260
261
 
261
- function fetchApplyLink(jobDetails) {
262
- return jobDetails.applyUrl;
262
+ function fetchApplyAndReferFriendLink(jobDetails) {
263
+ return {applyLink: jobDetails.applyUrl, referFriendLink: jobDetails.referralUrl};
263
264
  }
264
265
 
265
266
  function fetchJobLocation(jobDetails) {
@@ -1,6 +1,7 @@
1
1
  const { fetch } = require('wix-fetch');
2
2
  const { items: wixData } = require('@wix/data');
3
3
  const { COLLECTIONS } = require('./collectionConsts');
4
+ const secretsData = require('./secretsData');
4
5
  async function makeSmartRecruitersRequest(path) {
5
6
  const baseUrl = 'https://api.smartrecruiters.com';
6
7
  const fullUrl = `${baseUrl}${path}`;
@@ -27,16 +28,12 @@ async function makeSmartRecruitersRequest(path) {
27
28
  }
28
29
  }
29
30
 
30
- async function fetchPositionsFromSRAPI(companyID=undefined) {
31
+ async function fetchPositionsFromSRAPI() {
31
32
  let allPositions = [];
32
33
  let totalFound = 0;
33
34
  let page = 0;
34
35
  const MAX_PAGES = 30 // Safety limit to prevent infinite loops
35
- let companyId=companyID
36
- if(!companyID)
37
- {
38
- companyId = await getCompanyIdFromCMS();
39
- }
36
+ const companyId = await getCompanyIdFromCMS();
40
37
  console.log('Starting to fetch all positions with pagination...');
41
38
  let offset=0;
42
39
 
@@ -115,6 +112,5 @@ async function getCompanyIdFromCMS() {
115
112
  module.exports = {
116
113
  fetchPositionsFromSRAPI,
117
114
  fetchJobDescription,
118
- getCompanyIdFromCMS,
119
- makeSmartRecruitersRequest
115
+ getCompanyIdFromCMS
120
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.401",
3
+ "version": "1.7.402",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  const { executeApiRequest } = require('tests-utils');
2
- const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
2
+ const { getRandomPosition } = require('./testsUtils');
3
3
 
4
4
  describe('Job details fetch from SR API Tests', () => {
5
5
 
@@ -30,30 +30,6 @@ describe('Job details fetch from SR API Tests', () => {
30
30
  expect(jobFetchResponse.data.result.applyUrl.length).toBeGreaterThan(0);
31
31
  expect(jobFetchResponse.data.result.location).toBeDefined();
32
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 found', async () => {
52
- const requestBody = `fetchJobDescription('invalid_job_id');`;
53
- executeRequestAndTest(requestBody)
54
- });
55
- test('should throw error when given a valid jobId but no jobAdId is found', async () => {
56
- const requestBody = `fetchJobDescription('1234567890');`;
57
- executeRequestAndTest(requestBody)
58
- });
59
- });
33
+
34
+
35
+ });
@@ -1,17 +1,7 @@
1
- const { executeApiRequest } = require('tests-utils');
2
-
3
1
  function getRandomPosition(positions) {
4
2
  return positions[Math.floor(Math.random() * positions.length)];
5
3
  }
6
- async function executeRequestAndTest(requestBody) {
7
- try{
8
- response = await executeApiRequest(requestBody);
9
- expect(response.status).not.toBe(500);
10
- }catch(error){
11
- expect(error.message).toBe('Request failed with status code 500');
12
- }
13
- }
14
4
 
15
5
  module.exports = {
16
- getRandomPosition, executeRequestAndTest
6
+ getRandomPosition
17
7
  }