-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into hotfix/add-button-job-page
- Loading branch information
Showing
35 changed files
with
6,788 additions
and
1,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,10 @@ jobs: | |
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 | ||
|
||
- name: Create coverage report | ||
run: npx jest --coverage | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { request, APIRequestContext } from '@playwright/test'; | ||
import { config } from './config'; | ||
|
||
const baseURL = `${config.BASE_URL}/api/job-posting`; | ||
|
||
// Function to validate job properties | ||
const validateJobProperties = (job: any) => { | ||
expect(job).toHaveProperty('_id'); | ||
// Uncomment the properties you want to validate | ||
// expect(job).toHaveProperty('jobTitle'); | ||
// expect(job).toHaveProperty('datePosted'); | ||
// expect(job).toHaveProperty('hiringOrganization'); | ||
// expect(job).toHaveProperty('streetAddress'); | ||
// expect(job).toHaveProperty('addressLocality'); | ||
// expect(job).toHaveProperty('addressRegion'); | ||
// expect(job).toHaveProperty('minCompValue'); | ||
// expect(job).toHaveProperty('maxCompValue'); | ||
// expect(job).toHaveProperty('compTimeUnit'); | ||
// expect(job).toHaveProperty('workHours'); | ||
// expect(job).toHaveProperty('specialCommitments'); | ||
// expect(job).toHaveProperty('email'); | ||
// expect(job).toHaveProperty('jobPageId'); | ||
// expect(job).toHaveProperty('employmentType'); | ||
// expect(job).toHaveProperty('employmentSubType'); | ||
// expect(job).toHaveProperty('startTime'); | ||
// expect(job).toHaveProperty('benefits'); | ||
// expect(job).toHaveProperty('vacancies'); | ||
// expect(job).toHaveProperty('verified'); | ||
// expect(job).toHaveProperty('validThrough'); | ||
// expect(job).toHaveProperty('description'); | ||
// expect(job).toHaveProperty('site1'); | ||
// expect(job).toHaveProperty('site2'); | ||
// expect(job).toHaveProperty('site3'); | ||
// expect(job).toHaveProperty('site4'); | ||
// expect(job).toHaveProperty('__v'); | ||
// expect(job).toHaveProperty('sent'); | ||
}; | ||
|
||
// Function to test the endpoints | ||
const testEndpoint = async (context: APIRequestContext, endpoint: string) => { | ||
const response = await context.get(`${baseURL}/${endpoint}?page_num=1`); | ||
expect(response.status()).toBe(200); | ||
const data = await response.json(); | ||
|
||
for (const joblist in data) { | ||
for (const job of data[joblist]) { | ||
validateJobProperties(job); | ||
} | ||
expect(data[joblist].length).toBeGreaterThan(0); | ||
} | ||
}; | ||
|
||
describe('API Job Postings', () => { | ||
let context: APIRequestContext; | ||
|
||
beforeAll(async () => { | ||
context = await request.newContext(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await context.dispose(); | ||
}); | ||
|
||
const endpoints = [ | ||
// 'newcomers', | ||
// 'disabled', | ||
// 'indigenous', | ||
// 'students', | ||
'asylum-refugees', | ||
]; | ||
|
||
endpoints.forEach(endpoint => { | ||
it(`API: ${endpoint.charAt(0).toUpperCase() + endpoint.slice(1)} Postings`, async () => { | ||
await testEndpoint(context, endpoint); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { request, APIRequestContext } from '@playwright/test'; | ||
import { config } from './config'; | ||
|
||
const baseURL = `${config.BASE_URL}/api/job-posting`; | ||
|
||
// Function to validate job properties | ||
const validateJobProperties = (job: any) => { | ||
expect(job).toHaveProperty('_id'); | ||
// Add other properties if needed | ||
}; | ||
|
||
// Function to test the endpoints | ||
const testEndpoint = async ( | ||
context: APIRequestContext, | ||
endpoint: string, | ||
sortOrder: string | ||
) => { | ||
const response = await context.get( | ||
`${baseURL}/${endpoint}?sort=${sortOrder}&page_num=1` | ||
); | ||
expect(response.status()).toBe(200); | ||
|
||
let data; | ||
try { | ||
data = await response.json(); | ||
} catch (error) { | ||
throw new Error( | ||
`Error parsing JSON response for ${endpoint} with sort ${sortOrder}: ${error}` | ||
); | ||
} | ||
|
||
if (typeof data !== 'object' || Array.isArray(data)) { | ||
throw new Error( | ||
`Unexpected response format for ${endpoint} with sort ${sortOrder}` | ||
); | ||
} | ||
for (const joblist in data) { | ||
for (const job of data[joblist]) { | ||
validateJobProperties(job); | ||
} | ||
expect(data[joblist].length).toBeGreaterThan(0); | ||
} | ||
}; | ||
|
||
describe('API Job Postings', () => { | ||
let context: APIRequestContext; | ||
|
||
beforeAll(async () => { | ||
context = await request.newContext(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await context.dispose(); | ||
}); | ||
|
||
const endpoints = [ | ||
// 'newcomers', | ||
// 'disabled', | ||
// 'indigenous', | ||
// 'students', | ||
'asylum-refugees', | ||
]; | ||
|
||
const sortOrders = [ | ||
'a', // ascending | ||
'd', // descending | ||
]; | ||
|
||
endpoints.forEach(endpoint => { | ||
sortOrders.forEach(sortOrder => { | ||
test(`API: ${endpoint.charAt(0).toUpperCase() + endpoint.slice(1)} Postings sorted ${sortOrder === 'a' ? 'ascending' : 'descending'}`, async () => { | ||
await testEndpoint(context, endpoint, sortOrder); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.