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
2 changes: 1 addition & 1 deletion app/modules/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const JobFrontmatterSchema = z.object({
.string()
.regex(/^[A-Za-z0-9]+$/)
.optional(),
status: z.enum(['draft', 'published', 'closed']),
status: z.enum(['draft', 'published', 'unlisted', 'closed']),
publishedAt: CommonSchemas.dateString,
intro: CommonSchemas.nonEmptyString,
});
Expand Down
23 changes: 22 additions & 1 deletion app/routes/_main.($lang).jobs.$slug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 1. Redirect to `/{lang}/jobs` when slug is missing (FR and EN)
* 2. Redirect when `fetchJob` returns a non-200 status
* 3. Redirect when job status is `draft`
* 4. Redirect when job status is `closed`
* 4. Redirect when job status is `closed`; serve `unlisted` with noindex
* 5. Happy path FR: returns job data with correct lang and slug
* 6. Happy path EN: same with lang param `en`
*
Expand Down Expand Up @@ -148,6 +148,27 @@ describe('jobs detail loader', () => {
expect(outcome.response.headers.get('Location')).toBe('/fr/jobs');
});

it('serves an unlisted job by direct link, marked noindex', async () => {
const job = jobEntry({ status: 'unlisted' });
fetchJobMock.mockResolvedValueOnce([200, 'success', job]);
loadMemberRegistryMock.mockResolvedValueOnce({});
resolveMemberMock.mockReturnValueOnce(null);
extractJobSectionsMock.mockReturnValueOnce(fakeSections);
buildJobPostingLdMock.mockReturnValueOnce({});
serializeJsonLdMock.mockReturnValueOnce('{}');

const { loader, meta } = await import('./_main.($lang).jobs.$slug');
const outcome = await invokeLoader(loader, {
url: 'http://test.local/jobs/revops-consultant',
params: { slug: 'revops-consultant' },
});

expect(outcome.type).toBe('data');
if (outcome.type !== 'data') return;
const tags = meta({ data: outcome.data } as Parameters<typeof meta>[0]);
expect(tags).toContainEqual({ name: 'robots', content: 'noindex' });
});

it('returns job data with lang and slug on happy path (FR)', async () => {
const job = jobEntry();
fetchJobMock.mockResolvedValueOnce([200, 'success', job]);
Expand Down
5 changes: 4 additions & 1 deletion app/routes/_main.($lang).jobs.$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const loader = createHybridLoader(
return redirect(`/${lang}/jobs`);
}

if (job.frontmatter.status !== 'published') {
// `unlisted` jobs are off the jobs list but stay reachable by direct link.
const { status: jobStatus } = job.frontmatter;
if (jobStatus !== 'published' && jobStatus !== 'unlisted') {
return redirect(`/${lang}/jobs`);
}

Expand All @@ -70,6 +72,7 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
description: data.job.frontmatter.intro,
locale: data.lang as 'fr' | 'en',
type: 'website',
noIndex: data.job.frontmatter.status === 'unlisted',
});
};

Expand Down
Loading