mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-09-17 08:36:25 +00:00
* fix(jobnet-search): fallback to search endpoint on detail 404 for external ads (#432) * fix(jobnet-search): mark external detail fallback degraded and omit unknown fields * changelog: add the #432 entry for the external-ad fallback Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013fqqLgQSnwgWkv98twQhHi --------- Co-authored-by: Mads Lorentzen <madslorentzen17@gmail.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
Mads Lorentzen
parent
ab5732138a
commit
f8c606fb3d
@@ -0,0 +1,88 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { mapSearchAdToDetail } from "../src/commands/detail"
|
||||
import type { JobAdRaw } from "../src/commands/search"
|
||||
|
||||
describe("mapSearchAdToDetail (Issue #432 external ad fallback)", () => {
|
||||
const sampleAd: JobAdRaw & { jobAdUrl?: string; jobAnnouncementTypeName?: string } = {
|
||||
jobAdId: "ext-123",
|
||||
title: "AI Technical Artist",
|
||||
hiringOrgName: "Tactile Games",
|
||||
occupation: "Programmør og systemudvikler",
|
||||
conceptUriDa: "http://data.star.dk/esco/occupation/8b6456a3-ae9a-45a0-a65b-fed797521753",
|
||||
jobAnnouncementTypeName: "Almindelige vilkår",
|
||||
workHourPartTime: false,
|
||||
jobAdUrl: "https://job-boards.eu.greenhouse.io/tactilegames/jobs/4890782101",
|
||||
hasLogo: true,
|
||||
logoUrl: "/bff/logo/123",
|
||||
workPlaceAddress: " Trekronergade 26 ",
|
||||
cvr: "32319882",
|
||||
description: "<p>Great job opening at Tactile.</p>",
|
||||
applicationDeadline: "2026-12-05T00:00:00+01:00",
|
||||
applicationDeadlineStatus: "ExpirationDate",
|
||||
country: "Danmark",
|
||||
municipality: "København",
|
||||
postalCode: 2500,
|
||||
postalDistrictName: "Valby",
|
||||
publicationDate: "2026-09-05T00:00:00+02:00",
|
||||
isExternal: true,
|
||||
isSeen: false,
|
||||
isFavorite: false,
|
||||
}
|
||||
|
||||
test("maps all key fields correctly to DetailApiResponse format", () => {
|
||||
const detail = mapSearchAdToDetail(sampleAd)
|
||||
|
||||
expect(detail.id).toBe("ext-123")
|
||||
expect(detail.title).toBe("AI Technical Artist")
|
||||
expect(detail.body).toBe("<p>Great job opening at Tactile.</p>")
|
||||
expect(detail.publicationDateTime).toBe("2026-09-05T00:00:00+02:00")
|
||||
expect(detail.isExternal).toBe(true)
|
||||
expect(detail.views).toBeNull()
|
||||
expect(detail.approvalStatus).toBeNull()
|
||||
expect(detail.isAnonymousEmployer).toBeNull()
|
||||
expect(detail.employer.name).toBe("Tactile Games")
|
||||
expect(detail.employer.cvrNumber).toBe("32319882")
|
||||
expect(detail.employer.hasCompanyLogo).toBe(true)
|
||||
expect(detail.job.type).toBe("Almindelige vilkår")
|
||||
expect(detail.job.address.streetName).toBe("Trekronergade 26")
|
||||
expect(detail.job.address.city).toBe("Valby")
|
||||
expect(detail.job.address.postalCode).toBe("2500")
|
||||
expect(detail.job.address.municipality).toBe("København")
|
||||
expect(detail.job.address.countryCode).toBe("DK")
|
||||
expect(detail.job.address.countryName).toBe("Danmark")
|
||||
expect(detail.job.isPartTime).toBe(false)
|
||||
expect(detail.job.noFixedWorkplace).toBeNull()
|
||||
expect(detail.job.isLimitedPeriod).toBeNull()
|
||||
expect(detail.job.isDisabilityFriendly).toBeNull()
|
||||
expect(detail.job.preferredLabelDa).toBe("Programmør og systemudvikler")
|
||||
expect(detail.job.conceptUriDa).toBe("http://data.star.dk/esco/occupation/8b6456a3-ae9a-45a0-a65b-fed797521753")
|
||||
expect(detail.application.deadlineDate).toBe("2026-12-05T00:00:00+01:00")
|
||||
expect(detail.application.availablePositions).toBeNull()
|
||||
expect(detail.application.url).toBe("https://job-boards.eu.greenhouse.io/tactilegames/jobs/4890782101")
|
||||
expect(detail.application.isApplicationDeadlineASAP).toBe(false)
|
||||
})
|
||||
|
||||
test("handles empty or whitespace address gracefully", () => {
|
||||
const detail = mapSearchAdToDetail({
|
||||
...sampleAd,
|
||||
workPlaceAddress: " ",
|
||||
postalDistrictName: null,
|
||||
municipality: null,
|
||||
postalCode: null,
|
||||
})
|
||||
|
||||
expect(detail.job.address.streetName).toBeNull()
|
||||
expect(detail.job.address.city).toBeNull()
|
||||
expect(detail.job.address.postalCode).toBeNull()
|
||||
expect(detail.job.address.municipality).toBeNull()
|
||||
})
|
||||
|
||||
test("flags undisclosed deadline as ASAP", () => {
|
||||
const detail = mapSearchAdToDetail({
|
||||
...sampleAd,
|
||||
applicationDeadlineStatus: "NotDisclosed",
|
||||
})
|
||||
|
||||
expect(detail.application.isApplicationDeadlineASAP).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user