sr-npm 1.7.400 → 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 =
|
|
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
|
|
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(
|
|
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
|
-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { getRandomPosition
|
|
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
|
-
|
|
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
|
+
});
|
package/tests/testsUtils.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
function getRandomPosition(positions) {
|
|
2
2
|
return positions[Math.floor(Math.random() * positions.length)];
|
|
3
3
|
}
|
|
4
|
-
async function executeRequestAndTest(requestBody) {
|
|
5
|
-
try{
|
|
6
|
-
response = await executeApiRequest(requestBody);
|
|
7
|
-
expect(response.status).not.toBe(500);
|
|
8
|
-
}catch(error){
|
|
9
|
-
expect(error.message).toBe('Request failed with status code 500');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
4
|
|
|
13
5
|
module.exports = {
|
|
14
|
-
getRandomPosition
|
|
6
|
+
getRandomPosition
|
|
15
7
|
}
|