sr-npm 1.7.433 → 1.7.435

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.
@@ -34,12 +34,18 @@ async function makeSmartRecruitersRequest(path,templateType) {
34
34
  }
35
35
  }
36
36
 
37
- async function fetchPositionsFromSRAPI(companyID=undefined) {
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
- const {companyId,templateType} = await getApiKeys();
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,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.433",
3
+ "version": "1.7.435",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,59 +1,64 @@
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
- // let positions;
7
- // beforeAll(async () => {
8
- // const requestBody = `fetchPositionsFromSRAPI();`;
9
- // positions = await executeApiRequest(requestBody);
10
- // });
6
+ let positions;
7
+ beforeAll(async () => {
8
+ const requestBody = `fetchPositionsFromSRAPI();`;
9
+ positions = await executeApiRequest(requestBody);
10
+ });
11
11
 
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
- // });
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,21 +1,22 @@
1
1
  const { executeApiRequest } = require('tests-utils');
2
- const { items: wixData } = require('@wix/data');
3
2
  const { clearCollections } = require('./testsUtils');
4
- const { TEMPLATE_TYPE, COLLECTIONS } = require('./consts');
3
+ const { TEMPLATE_TYPE } = require('./consts');
5
4
 
6
5
  beforeAll(async () => {
7
- clearCollections(wixData);
6
+ clearCollections();
8
7
  });
9
8
 
10
9
 
10
+
11
11
  it.each([
12
12
  { templateName: 'Internal', templateType: TEMPLATE_TYPE.INTERNAL },
13
13
  { templateName: 'External', templateType: TEMPLATE_TYPE.EXTERNAL },
14
14
  ])('should successfully mark template as $templateName', async ({ templateName,templateType }) => {
15
15
  const requestBody = `markTemplateAs${templateName}();`;
16
16
  const response = await executeApiRequest(requestBody);
17
- console.log("response: ", response);
18
17
  expect(response.status).toBe(200);
18
+ expect(response.data).toBeDefined();
19
+ expect(response.data.result.templateType).toBe(templateType);
19
20
  });
20
21
 
21
22
 
@@ -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(wixData) {
17
+ async function clearCollections() {
17
18
 
18
19
  for (const collection of Object.values(COLLECTIONS)) {
19
20
  await wixData.truncate(collection);