Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions data/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
type EmploymentType = "FULL_TIME" | "PART_TIME" | "CONTRACTOR" | "INTERN";

interface JobLocation {
addressLocality: string;
addressRegion?: string;
postalCode?: string;
addressCountry: string;
}

export interface Job {
slug: string;
title: string;
category: string;
domain: string;
description: string;
datePosted: string;
validThrough?: string;
employmentType: EmploymentType;
jobLocation: JobLocation;
jobLocationType?: "TELECOMMUTE";
directApply?: boolean;
experienceRequirements?: { monthsOfExperience: number };
educationRequirements?: string;
skills?: string[];
}

interface Domain {
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/components/cards/JobCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import JobCard from "@/components/cards/JobCard";
import { Job } from "@/../data/jobs";

const mockJob: Job = {
slug: "dev-symfony",
title: "Dev Symfony",
category: "Développement",
domain: "developpement",
description: "Poste de dev Symfony senior.",
datePosted: "2026-04-01",
employmentType: "FULL_TIME",
jobLocation: { addressLocality: "Lille", addressCountry: "FR" },
};

describe("JobCard", () => {
Expand Down
18 changes: 15 additions & 3 deletions src/__tests__/data/jobs.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { getJobsByDomain, domains, jobs, spontaneousEmail } from "../../../data/jobs";
import { getJobsByDomain, domains, jobs, spontaneousEmail, type Job } from "../../../data/jobs";

const sampleJob = (overrides: Partial<Job> = {}): Job => ({
slug: "dev-symfony",
title: "Dev Symfony",
category: "CDI",
domain: "developpement",
description: "desc",
datePosted: "2026-04-01",
employmentType: "FULL_TIME",
jobLocation: { addressLocality: "Lille", addressCountry: "FR" },
...overrides,
});

describe("getJobsByDomain", () => {
it("returns an empty array for an unknown domain", () => {
Expand All @@ -11,8 +23,8 @@ describe("getJobsByDomain", () => {

it("filters jobs matching the domain slug", () => {
jobs.push(
{ title: "Dev Symfony", category: "CDI", domain: "developpement", description: "desc" },
{ title: "Commercial", category: "CDI", domain: "business", description: "desc" },
sampleJob({ slug: "dev-symfony", title: "Dev Symfony", domain: "developpement" }),
sampleJob({ slug: "commercial", title: "Commercial", domain: "business" }),
);
const result = getJobsByDomain("developpement");
expect(result).toHaveLength(1);
Expand Down
58 changes: 57 additions & 1 deletion src/__tests__/lib/structured-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { howToJsonLd, reviewsJsonLd, serviceJsonLd, eventJsonLd } from "@/lib/structured-data";
import { howToJsonLd, reviewsJsonLd, serviceJsonLd, eventJsonLd, jobPostingJsonLd } from "@/lib/structured-data";
import { categorySlugMap } from "@/lib/blog";
import type { Job } from "@/../data/jobs";

describe("howToJsonLd", () => {
it("returns correct schema with steps", () => {
Expand Down Expand Up @@ -85,3 +86,58 @@ describe("categorySlugMap", () => {
expect(Object.keys(categorySlugMap).length).toBeGreaterThan(0);
});
});

describe("jobPostingJsonLd", () => {
const baseJob: Job = {
slug: "dev-symfony",
title: "Dev Symfony",
category: "CDI",
domain: "developpement",
description: "Rejoignez une équipe Symfony senior à Lille.",
datePosted: "2026-04-01",
employmentType: "FULL_TIME",
jobLocation: { addressLocality: "Lille", addressCountry: "FR" },
};

it("returns the minimal valid JobPosting schema", () => {
const result = jobPostingJsonLd(baseJob);
expect(result["@type"]).toBe("JobPosting");
expect(result.title).toBe("Dev Symfony");
expect(result.datePosted).toBe("2026-04-01");
expect(result.employmentType).toBe("FULL_TIME");
expect(result.url).toContain("/ta-carriere#dev-symfony");
expect(result.hiringOrganization).toEqual({ "@id": expect.stringContaining("/#organization") });
expect(result.directApply).toBeUndefined();
expect(result.validThrough).toBeUndefined();
expect(result.jobLocationType).toBeUndefined();
expect(result.experienceRequirements).toBeUndefined();
expect(result.educationRequirements).toBeUndefined();
expect(result.skills).toBeUndefined();
});

it("includes optional fields when provided", () => {
const result = jobPostingJsonLd({
...baseJob,
validThrough: "2026-10-01",
jobLocationType: "TELECOMMUTE",
experienceRequirements: { monthsOfExperience: 36 },
educationRequirements: "Bac+5",
skills: ["Symfony", "PHP", "Doctrine"],
directApply: true,
});
expect(result.validThrough).toBe("2026-10-01");
expect(result.jobLocationType).toBe("TELECOMMUTE");
expect(result.experienceRequirements).toEqual({
"@type": "OccupationalExperienceRequirements",
monthsOfExperience: 36,
});
expect(result.educationRequirements).toBe("Bac+5");
expect(result.skills).toBe("Symfony, PHP, Doctrine");
expect(result.directApply).toBe(true);
});

it("omits skills when array is empty", () => {
const result = jobPostingJsonLd({ ...baseJob, skills: [] });
expect(result.skills).toBeUndefined();
});
});
53 changes: 51 additions & 2 deletions src/__tests__/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,65 @@ jest.mock("@/../data/jobs", () => ({
},
}));

let mockJobs: Array<{ title: string; contract: string; location: string; domain: string; url: string }> | null = null;
import type { Job } from "@/../data/jobs";

let mockJobs: Job[] | null = null;

describe("Ta carrière with jobs", () => {
afterEach(() => {
mockJobs = null;
});

it("renders job cards when jobs exist", () => {
mockJobs = [{ title: "Dev Symfony", contract: "CDI", location: "Lille", domain: "dev", url: "/job/dev" }];
mockJobs = [
{
slug: "dev-symfony",
title: "Dev Symfony",
category: "CDI",
domain: "developpement",
description: "Rejoignez une équipe Symfony senior à Lille.",
datePosted: "2026-04-01",
employmentType: "FULL_TIME",
jobLocation: { addressLocality: "Lille", addressCountry: "FR" },
},
];
render(<TaCarriere />);
expect(screen.getByText("Dev Symfony")).toBeInTheDocument();
});

it("emits a JobPosting JSON-LD when jobs exist", () => {
mockJobs = [
{
slug: "dev-symfony",
title: "Dev Symfony",
category: "CDI",
domain: "developpement",
description: "Rejoignez une équipe Symfony senior à Lille.",
datePosted: "2026-04-01",
validThrough: "2026-10-01",
employmentType: "FULL_TIME",
jobLocation: { addressLocality: "Lille", addressCountry: "FR" },
skills: ["Symfony", "PHP"],
},
];
const { container } = render(<TaCarriere />);
const scripts = container.querySelectorAll('script[type="application/ld+json"]');
const jobPosting = Array.from(scripts)
.map((s) => JSON.parse(s.innerHTML))
.find((json) => json["@type"] === "JobPosting");
expect(jobPosting).toBeDefined();
expect(jobPosting.title).toBe("Dev Symfony");
expect(jobPosting.validThrough).toBe("2026-10-01");
expect(jobPosting.skills).toBe("Symfony, PHP");
});

it("emits no JobPosting when jobs list is empty", () => {
mockJobs = [];
const { container } = render(<TaCarriere />);
const scripts = container.querySelectorAll('script[type="application/ld+json"]');
const jobPosting = Array.from(scripts)
.map((s) => JSON.parse(s.innerHTML))
.find((json) => json["@type"] === "JobPosting");
expect(jobPosting).toBeUndefined();
});
});
11 changes: 9 additions & 2 deletions src/app/ta-carriere/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { jobs, domains, spontaneousEmail } from "@/../data/jobs";
import Link from "next/link";
import FadeIn from "@/components/ui/FadeIn";
import Breadcrumb from "@/components/ui/Breadcrumb";
import { breadcrumbJsonLd, webPageJsonLd, pageGraphJsonLd } from "@/lib/structured-data";
import { breadcrumbJsonLd, webPageJsonLd, pageGraphJsonLd, jobPostingJsonLd } from "@/lib/structured-data";
import RelatedLinks from "@/components/sections/RelatedLinks";
import type { RelatedLink } from "@/components/sections/RelatedLinks";
import CallToAction from "@/components/sections/CallToAction";
Expand Down Expand Up @@ -43,6 +43,13 @@ export default function TaCarriere() {
return (
<>
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(pageGraphJsonLd(breadcrumb, webPage)) }} />
{jobs.map((job) => (
<script
key={job.slug}
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jobPostingJsonLd(job)) }}
/>
))}
<main>
<section className="bg-light-gray py-16 md:py-24">
<Container className="text-center">
Expand Down Expand Up @@ -83,7 +90,7 @@ export default function TaCarriere() {
{jobs.length > 0 ? (
<div className="grid gap-6 md:grid-cols-2">
{jobs.map((job) => (
<JobCard key={job.title} job={job} />
<JobCard key={job.slug} job={job} />
))}
</div>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/components/cards/JobCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface JobCardProps {

export default function JobCard({ job }: JobCardProps) {
return (
<div className="rounded-lg border border-border bg-white p-6">
<div id={job.slug} className="rounded-lg border border-border bg-white p-6">
<span className="text-xs font-medium uppercase text-primary">
{job.category}
</span>
Expand Down
32 changes: 32 additions & 0 deletions src/lib/structured-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BASE_URL, SITE_NAME } from "@/lib/metadata";
import type { AuthorSchema } from "@/data/authors";
import type { FaqItem, ProficiencyLevel } from "@/types/blog";
import type { Job } from "@/../data/jobs";

interface BreadcrumbItem {
name: string;
Expand Down Expand Up @@ -336,3 +337,34 @@ export function eventJsonLd(event: EventSchema) {
url: event.url,
};
}

export function jobPostingJsonLd(job: Job) {
return {
"@context": "https://schema.org",
"@type": "JobPosting",
title: job.title,
description: job.description,
datePosted: job.datePosted,
...(job.validThrough && { validThrough: job.validThrough }),
employmentType: job.employmentType,
hiringOrganization: { "@id": `${BASE_URL}/#organization` },
jobLocation: {
"@type": "Place",
address: {
"@type": "PostalAddress",
...job.jobLocation,
},
},
...(job.jobLocationType && { jobLocationType: job.jobLocationType }),
...(job.experienceRequirements && {
experienceRequirements: {
"@type": "OccupationalExperienceRequirements",
monthsOfExperience: job.experienceRequirements.monthsOfExperience,
},
}),
...(job.educationRequirements && { educationRequirements: job.educationRequirements }),
...(job.skills && job.skills.length > 0 && { skills: job.skills.join(", ") }),
url: `${BASE_URL}/ta-carriere#${job.slug}`,
...(job.directApply !== undefined && { directApply: job.directApply }),
};
}
Loading