Skip to content

Commit

Permalink
feat: add jobPosting support for 'confidential' (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilhsmith committed Apr 1, 2023
1 parent 76ca1e4 commit db70100
Show file tree
Hide file tree
Showing 6 changed files with 10,253 additions and 7,102 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1658,15 +1658,15 @@ export default Page;

**Required properties**

| Property | Info |
| --------------------------- | ------------------------------------------------------------------------------------------------------ |
| `datePosted` | The original date that employer posted the job in ISO 8601 format |
| `description` | The full description of the job in HTML format |
| `hiringOrganization` | |
| `hiringOrganization.name` | Name of the company offering the job position |
| `hiringOrganization.sameAs` | URL of a reference Web page |
| `title` | The title of the job (not the title of the posting) |
| `validThrough` | The date when the job posting will expire in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) |
| Property | Info |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `datePosted` | The original date that employer posted the job in ISO 8601 format |
| `description` | The full description of the job in HTML format |
| `hiringOrganization` | An object containing information about the company hiring with the following fields or the string `'confidential'` when hiring anonymously |
| `hiringOrganization.name` | Name of the company offering the job position |
| `hiringOrganization.sameAs` | URL of a reference Web page |
| `title` | The title of the job (not the title of the posting) |
| `validThrough` | The date when the job posting will expire in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) |

**Supported properties**

Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/jobPosting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ describe('Job Posting JSON-LD', () => {
cy.visit('http://localhost:3000/jsonld/jobPosting');
cy.get('head script[type="application/ld+json"]').then(tags => {
const jsonLD = JSON.parse(tags[0].innerHTML);
const confidentialHiringJsonLD = JSON.parse(tags[2].innerHTML);
assertSchema(schemas)('Job Posting', '1.0.0')(jsonLD);
assertSchema(schemas)('Job Posting', '1.1.0')(confidentialHiringJsonLD);
});
});

Expand Down Expand Up @@ -118,4 +120,21 @@ describe('Job Posting JSON-LD', () => {
});
});
});

it('Third Job Posting (With Anonymous Organization) Matches', () => {
cy.visit('http://localhost:3000/jsonld/jobPosting');
cy.get('head script[type="application/ld+json"]').then(tags => {
const jsonLD = JSON.parse(tags[2].innerHTML);

expect(jsonLD).to.deep.equal({
'@context': 'https://schema.org',
'@type': 'JobPosting',
datePosted: '2020-01-06T03:37:40Z',
description: 'Company is looking for another software developer....',
hiringOrganization: 'confidential',
validThrough: '2020-01-06',
title: 'Job Title #3',
});
});
});
});
57 changes: 56 additions & 1 deletion cypress/schemas/job-posting-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,5 +385,60 @@ const jobPosting100 = {
},
};

const jobPostingVersions = versionSchemas(jobPosting100);
const jobPosting101 = {
version: {
major: 1,
minor: 1,
patch: 0,
},
schema: {
type: 'object',
title: 'Job Posting',
description: 'An example schema describing JSON-LD for type: Job Posting',
properties: {
'@context': {
type: 'string',
description: 'Schema.org context',
},
'@type': {
type: 'string',
description: 'JSON-LD Type',
},
datePosted: {
type: 'string',
description: 'posted date of the job offer',
},
description: {
type: 'string',
description: 'description of the job offer',
},
hiringOrganization: {
type: 'string',
description: "the string 'confidential' when hiring anonymously",
},
validThrough: {
type: 'string',
description: 'job valid untill',
},
title: {
type: 'string',
description: 'title of the job offer',
},
},
required: true,
additionalProperties: false,
example: {
'@context': 'https://schema.org',
'@type': 'JobPosting',
datePosted: '2020-06-12',
description:
'<p>Maespirit is looking for a software developer for ....</p>',
hiringOrganization: 'confidential',
validThrough: '2020-12-12',
title: 'Software developer',
},
},
};

const jobPostingVersions = versionSchemas(jobPosting100, jobPosting101);
export default jobPostingVersions;
9 changes: 9 additions & 0 deletions e2e/pages/jsonld/jobPosting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ function JobPosting() {
applicantLocationRequirements="FR"
keyOverride="second-job-posting-with-salary-range"
/>

<JobPostingJsonLd
datePosted="2020-01-06T03:37:40Z"
description="Company is looking for another software developer...."
hiringOrganization="confidential"
title="Job Title #3"
validThrough="2020-01-06"
keyOverride="third-job-posting-with-anonymous-hiring"
/>
</>
);
}
Expand Down
8 changes: 6 additions & 2 deletions src/jsonld/jobPosting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface JobPostingJsonLdProps extends JsonLdProps {
keyOverride?: string;
datePosted: string;
description: string;
hiringOrganization: HiringOrganization;
hiringOrganization: HiringOrganization | 'confidential';
title: string;
validThrough?: string;
applicantLocationRequirements?: string;
Expand Down Expand Up @@ -101,7 +101,11 @@ function JobPostingJsonLd({
return undefined;
}

function setHiringOrganization(org: HiringOrganization) {
function setHiringOrganization(org: HiringOrganization | 'confidential') {
if (org === 'confidential') {
return 'confidential';
}

return {
'@type': 'Organization',
name: org.name,
Expand Down
Loading

0 comments on commit db70100

Please sign in to comment.