sr-npm 1.7.419 → 1.7.421
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/data.js
CHANGED
|
@@ -8,13 +8,11 @@ async function makeSmartRecruitersRequest(path,templateType) {
|
|
|
8
8
|
const fullUrl = `${baseUrl}${path}`;
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
-
//if templatetype is internal make headers object with x-smarttoken
|
|
12
11
|
const headers = {
|
|
13
12
|
'Accept-Language': 'en',
|
|
14
13
|
'accept': 'application/json',
|
|
15
14
|
'Cookie': 'AWSALB=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d; AWSALBCORS=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d'
|
|
16
15
|
};
|
|
17
|
-
//here is the only place where we check templateType
|
|
18
16
|
if (templateType === TEMPLATE_TYPE.INTERNAL) {
|
|
19
17
|
const smartToken = await getTokenFromCMS(TOKEN_NAME.SMART_TOKEN);
|
|
20
18
|
headers['x-smarttoken'] = smartToken;
|
|
@@ -36,7 +34,7 @@ async function makeSmartRecruitersRequest(path,templateType) {
|
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
async function fetchPositionsFromSRAPI() {
|
|
37
|
+
async function fetchPositionsFromSRAPI(companyID=undefined) {
|
|
40
38
|
let allPositions = [];
|
|
41
39
|
let totalFound = 0;
|
|
42
40
|
let page = 0;
|
package/package.json
CHANGED
package/tests/consts.js
ADDED
|
@@ -1,35 +1,59 @@
|
|
|
1
|
-
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { getRandomPosition } = 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
|
-
|
|
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
|
+
// });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { executeApiRequest } = require('tests-utils');
|
|
2
|
+
const { items: wixData } = require('@wix/data');
|
|
3
|
+
const { clearCollections } = require('./testsUtils');
|
|
4
|
+
const { TEMPLATE_TYPE } = require('../backend/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
|
+
|
package/tests/testsUtils.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
const { executeApiRequest } = require('tests-utils');
|
|
2
|
+
const { COLLECTIONS } = require('./consts');
|
|
3
|
+
|
|
1
4
|
function getRandomPosition(positions) {
|
|
2
5
|
return positions[Math.floor(Math.random() * positions.length)];
|
|
3
6
|
}
|
|
7
|
+
async function executeRequestAndTest(requestBody) {
|
|
8
|
+
try{
|
|
9
|
+
response = await executeApiRequest(requestBody);
|
|
10
|
+
expect(response.status).not.toBe(500);
|
|
11
|
+
}catch(error){
|
|
12
|
+
expect(error.message).toBe('Request failed with status code 500');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function clearCollections(wixData) {
|
|
17
|
+
|
|
18
|
+
for (const collection of Object.values(COLLECTIONS)) {
|
|
19
|
+
await wixData.truncate(collection);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
4
22
|
|
|
5
23
|
module.exports = {
|
|
6
|
-
getRandomPosition
|
|
24
|
+
getRandomPosition,
|
|
25
|
+
executeRequestAndTest,
|
|
26
|
+
clearCollections
|
|
7
27
|
}
|