fix(jobdanmark-search): normalize the detail command's HTML fallback branch

The JSON-LD and rendered-HTML branches returned structurally different
records: the fallback emitted raw DD-MM-YYYY page text as datePosted,
free text (including the literal "Loebende") as validThrough, and a
hardcoded null addressLocality. Overview dates now convert to ISO,
Loebende maps to null, and the locality derives from the workplace
address via the same exported extractCity search uses. Review finding
F25 (2026-08-19).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mads Lorentzen
2026-08-19 20:53:24 +02:00
co-authored by Claude Opus 5
parent bcba687fbf
commit dab215073e
4 changed files with 46 additions and 7 deletions
@@ -40,16 +40,31 @@ describe("parseJobPostingFromHtml", () => {
);
expect(parsed.title).toBe("Journalistisk udvikler søges");
expect(parsed.datePosted).toBe("03-07-2026");
expect(parsed.validThrough).toBe("02-08-2026 23.59");
// The fallback must emit the same shapes as the JSON-LD branch: contract
// dates, not the page's raw DD-MM-YYYY text (review finding F25, 2026-08-19).
expect(parsed.datePosted).toBe("2026-07-03");
expect(parsed.validThrough).toBe("2026-08-02");
expect(parsed.employmentType).toEqual(["Fuldtid"]);
expect(parsed.hiringOrganization.name).toBe("JFM");
expect(parsed.hiringOrganization.logo).toBe("https://jobdanmark.dk/media/jfm-logo.png?width=100");
expect(parsed.jobLocation.streetAddress).toBe("Banegårdspladsen 1, 5000 Odense C");
expect(parsed.jobLocation.addressLocality).toBe("Odense C");
expect(parsed.description).toContain("identificere relevante datasæt");
expect(parsed.applyUrl).toBe("https://jfm.career.emply.com/da/apply/example");
});
test("maps a rolling deadline (Løbende) to null in the HTML fallback", () => {
// "Løbende" is free text meaning rolling/ongoing - jobbank's parser maps
// its equivalent to null, and a stored "Løbende" deadline would hit every
// date-arithmetic consumer (review finding F25, 2026-08-19).
const html = HTML_WITHOUT_JSON_LD.replace(
"<li><strong>Ansøgningsfrist:</strong> 02-08-2026 23.59</li>",
"<li><strong>Ansøgningsfrist:</strong> Løbende</li>",
);
const parsed = parseJobPostingFromHtml(html, "s", "https://jobdanmark.dk/job/s");
expect(parsed.validThrough).toBeNull();
});
test("does not reject titles containing '404' mid-phrase", () => {
const htmlWith404InTitle = HTML_WITHOUT_JSON_LD.replace(
"<title>Journalistisk udvikler s&#xF8;ges | jobdanmark</title>",