sr-npm 1.7.432 → 1.7.434
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
|
@@ -346,21 +346,18 @@ async function clearCollections() {
|
|
|
346
346
|
|
|
347
347
|
async function markTemplateAsExternal() {
|
|
348
348
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
349
|
-
|
|
350
|
-
console.log("TEMPLATE_TYPE: ", TEMPLATE_TYPE);
|
|
351
|
-
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
349
|
+
const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
352
350
|
templateType: TEMPLATE_TYPE.EXTERNAL
|
|
353
351
|
});
|
|
352
|
+
return tempalte;
|
|
354
353
|
}
|
|
355
354
|
|
|
356
355
|
async function markTemplateAsInternal() {
|
|
357
356
|
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
358
|
-
|
|
359
|
-
console.log("COLLECTIONS: ", COLLECTIONS);
|
|
360
|
-
console.log("TEMPLATE_TYPE: ", TEMPLATE_TYPE);
|
|
361
|
-
await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
357
|
+
const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
362
358
|
templateType: TEMPLATE_TYPE.INTERNAL
|
|
363
359
|
});
|
|
360
|
+
return tempalte;
|
|
364
361
|
}
|
|
365
362
|
|
|
366
363
|
async function fillSecretManagerMirror() {
|
|
@@ -34,12 +34,18 @@ async function makeSmartRecruitersRequest(path,templateType) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
async function fetchPositionsFromSRAPI(
|
|
37
|
+
async function fetchPositionsFromSRAPI(testObject=undefined) {
|
|
38
38
|
let allPositions = [];
|
|
39
39
|
let totalFound = 0;
|
|
40
40
|
let page = 0;
|
|
41
41
|
const MAX_PAGES = 30 // Safety limit to prevent infinite loops
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
let companyId, templateType;
|
|
44
|
+
if (testObject) {
|
|
45
|
+
({ companyId, templateType } = testObject);
|
|
46
|
+
} else {
|
|
47
|
+
({ companyId, templateType } = await getApiKeys());
|
|
48
|
+
}
|
|
43
49
|
console.log('Starting to fetch all positions with pagination...');
|
|
44
50
|
let offset=0;
|
|
45
51
|
|
package/package.json
CHANGED
|
@@ -1,59 +1,64 @@
|
|
|
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 external template', async () => {
|
|
37
|
+
const requestBody = `fetchPositionsFromSRAPI({companyId: 'invalid_company_id',templateType: 'EXTERNAL'});`;
|
|
38
|
+
executeRequestAndTest(requestBody)
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('should throw error if invalid companyId is found internal template', async () => {
|
|
42
|
+
const requestBody = `fetchPositionsFromSRAPI({companyId: 'invalid_company_id',templateType: 'INTERNAL'});`;
|
|
43
|
+
executeRequestAndTest(requestBody)
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('should throw error when a bad URL is used', async () => {
|
|
47
|
+
const requestBody = `makeSmartRecruitersRequest('/v1/error/companyId/postings');`;
|
|
48
|
+
executeRequestAndTest(requestBody)
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('fetchJobDescription error handling', () => {
|
|
56
|
+
test('should throw error if invalid jobId is given', async () => {
|
|
57
|
+
const requestBody = `fetchJobDescription('invalid_job_id');`;
|
|
58
|
+
executeRequestAndTest(requestBody)
|
|
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
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const { executeApiRequest } = require('tests-utils');
|
|
2
|
-
const { items: wixData } = require('@wix/data');
|
|
3
2
|
const { clearCollections } = require('./testsUtils');
|
|
4
|
-
const { TEMPLATE_TYPE
|
|
3
|
+
const { TEMPLATE_TYPE } = require('./consts');
|
|
5
4
|
|
|
6
5
|
beforeAll(async () => {
|
|
7
|
-
clearCollections(
|
|
6
|
+
clearCollections();
|
|
8
7
|
});
|
|
9
8
|
|
|
10
9
|
|
|
@@ -13,9 +12,10 @@ it.each([
|
|
|
13
12
|
{ templateName: 'External', templateType: TEMPLATE_TYPE.EXTERNAL },
|
|
14
13
|
])('should successfully mark template as $templateName', async ({ templateName,templateType }) => {
|
|
15
14
|
const requestBody = `markTemplateAs${templateName}();`;
|
|
16
|
-
await executeApiRequest(requestBody);
|
|
17
|
-
|
|
18
|
-
expect(
|
|
15
|
+
const response = await executeApiRequest(requestBody);
|
|
16
|
+
expect(response.status).toBe(200);
|
|
17
|
+
expect(response.data).toBeDefined();
|
|
18
|
+
expect(response.data.result.templateType).toBe(templateType);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
|
package/tests/testsUtils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { executeApiRequest } = require('tests-utils');
|
|
2
2
|
const { COLLECTIONS } = require('./consts');
|
|
3
|
+
const { items: wixData } = require('@wix/data');
|
|
3
4
|
|
|
4
5
|
function getRandomPosition(positions) {
|
|
5
6
|
return positions[Math.floor(Math.random() * positions.length)];
|
|
@@ -13,7 +14,7 @@ async function executeRequestAndTest(requestBody) {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
async function clearCollections(
|
|
17
|
+
async function clearCollections() {
|
|
17
18
|
|
|
18
19
|
for (const collection of Object.values(COLLECTIONS)) {
|
|
19
20
|
await wixData.truncate(collection);
|