sr-npm 1.7.452 → 1.7.453
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 +0 -13
- package/backend/data.js +2 -1
- package/backend/fetchPositionsFromSRAPI.js +1 -2
- package/backend/index.js +0 -1
- package/backend/secretsData.js +1 -1
- package/package.json +1 -1
- package/tests/fetchPositionsFromSRApiTest.spec.js +56 -56
- package/tests/testsUtils.js +1 -11
- package/tests/consts.js +0 -12
- package/tests/markTemplateTest.spec.js +0 -27
|
@@ -71,17 +71,6 @@ const COLLECTIONS_FIELDS = {
|
|
|
71
71
|
],
|
|
72
72
|
};
|
|
73
73
|
|
|
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
|
-
|
|
84
|
-
|
|
85
74
|
|
|
86
75
|
module.exports = {
|
|
87
76
|
COLLECTIONS,
|
|
@@ -89,6 +78,4 @@ TOKEN_NAME = {
|
|
|
89
78
|
JOBS_COLLECTION_FIELDS,
|
|
90
79
|
AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS,
|
|
91
80
|
CITIES_COLLECTION_FIELDS,
|
|
92
|
-
TEMPLATE_TYPE,
|
|
93
|
-
TOKEN_NAME,
|
|
94
81
|
};
|
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
|
|
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) {
|
package/backend/index.js
CHANGED
package/backend/secretsData.js
CHANGED
|
@@ -11,7 +11,7 @@ function getSmartToken() {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function getCompanyId() {
|
|
14
|
-
console.log("Getting
|
|
14
|
+
console.log("Getting th#@$$#@@#$e company ID from the secrets");
|
|
15
15
|
return getSecretValue("companyID")
|
|
16
16
|
.then((secret) => {
|
|
17
17
|
return secret;
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { executeApiRequest } = require('tests-utils');
|
|
2
|
+
const { getRandomPosition, executeRequestAndTest } = require('./testsUtils');
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
});
|
package/tests/testsUtils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { COLLECTIONS } = require('./consts');
|
|
3
2
|
|
|
4
3
|
function getRandomPosition(positions) {
|
|
5
4
|
return positions[Math.floor(Math.random() * positions.length)];
|
|
@@ -13,15 +12,6 @@ async function executeRequestAndTest(requestBody) {
|
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
async function clearCollections(wixData) {
|
|
17
|
-
|
|
18
|
-
for (const collection of Object.values(COLLECTIONS)) {
|
|
19
|
-
await wixData.truncate(collection);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
15
|
module.exports = {
|
|
24
|
-
getRandomPosition,
|
|
25
|
-
executeRequestAndTest,
|
|
26
|
-
clearCollections
|
|
16
|
+
getRandomPosition, executeRequestAndTest
|
|
27
17
|
}
|
package/tests/consts.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { items: wixData } = require('@wix/data');
|
|
3
|
-
const { clearCollections } = require('./testsUtils');
|
|
4
|
-
const { TEMPLATE_TYPE } = require('./consts');
|
|
5
|
-
const { COLLECTIONS } = require('./consts');
|
|
6
|
-
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
clearCollections(wixData);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
it.each([
|
|
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);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|