sr-npm 1.7.450 → 1.7.452
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/backend/collectionConsts.js +10 -9
- package/backend/consts.js +10 -0
- package/backend/data.js +2 -4
- package/backend/fetchPositionsFromSRAPI.js +5 -10
- package/backend/secretsData.js +1 -0
- package/package.json +1 -1
- package/tests/fetchPositionsFromSRApiTest.spec.js +56 -61
- package/tests/markTemplateTest.spec.js +11 -9
- package/tests/testsUtils.js +1 -2
|
@@ -71,16 +71,17 @@ const COLLECTIONS_FIELDS = {
|
|
|
71
71
|
],
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
TEMPLATE_TYPE = {
|
|
75
|
+
INTERNAL: 'INTERNAL',
|
|
76
|
+
EXTERNAL: 'PUBLIC',
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
TOKEN_NAME = {
|
|
80
|
+
COMPANY_ID: 'companyId',
|
|
81
|
+
SMART_TOKEN: 'x-smarttoken',
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
|
|
79
|
-
const TOKEN_NAME = {
|
|
80
|
-
COMPANY_ID: 'companyId',
|
|
81
|
-
SMART_TOKEN: 'x-smarttoken',
|
|
82
|
-
}
|
|
83
|
-
|
|
84
85
|
|
|
85
86
|
module.exports = {
|
|
86
87
|
COLLECTIONS,
|
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
|
@@ -344,18 +344,16 @@ async function clearCollections() {
|
|
|
344
344
|
|
|
345
345
|
async function markTemplateAsExternal() {
|
|
346
346
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
347
|
-
|
|
347
|
+
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
348
348
|
templateType: TEMPLATE_TYPE.EXTERNAL
|
|
349
349
|
});
|
|
350
|
-
return tempalte;
|
|
351
350
|
}
|
|
352
351
|
|
|
353
352
|
async function markTemplateAsInternal() {
|
|
354
353
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
355
|
-
|
|
354
|
+
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
356
355
|
templateType: TEMPLATE_TYPE.INTERNAL
|
|
357
356
|
});
|
|
358
|
-
return tempalte;
|
|
359
357
|
}
|
|
360
358
|
|
|
361
359
|
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
|
|
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(
|
|
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
|
|
|
@@ -104,7 +100,6 @@ async function fetchPositionsFromSRAPI(testObject=undefined) {
|
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
async function fetchJobDescription(jobId) {
|
|
107
|
-
|
|
108
103
|
const {companyId,templateType} = await getApiKeys();
|
|
109
104
|
return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
|
|
110
105
|
}
|
package/backend/secretsData.js
CHANGED
package/package.json
CHANGED
|
@@ -1,64 +1,59 @@
|
|
|
1
|
-
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
|
|
1
|
+
// const { executeApiRequest } = require('tests-utils');
|
|
2
|
+
// const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
|
|
3
3
|
|
|
4
|
-
describe('Job details fetch from SR API Tests', () => {
|
|
4
|
+
// describe('Job details fetch from SR API Tests', () => {
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
// let positions;
|
|
7
|
+
// beforeAll(async () => {
|
|
8
|
+
// const requestBody = `fetchPositionsFromSRAPI();`;
|
|
9
|
+
// positions = await executeApiRequest(requestBody);
|
|
10
|
+
// });
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe('fetchPositionsFromSRAPI error handling', () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
test('should throw error when given a valid but wrong jobId is given', async () => {
|
|
61
|
-
const requestBody = `fetchJobDescription('1234567890');`;
|
|
62
|
-
executeRequestAndTest(requestBody)
|
|
63
|
-
});
|
|
64
|
-
});
|
|
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
|
-
{
|
|
13
|
-
{
|
|
14
|
-
])('should successfully mark template as $
|
|
15
|
-
const requestBody = `markTemplateAs${
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
expect(
|
|
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
|
|
package/tests/testsUtils.js
CHANGED
|
@@ -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);
|