import { describe, expect, test } from "bun:test"; import { parseDetailPage } from "../src/commands/detail"; // Jobindex redesigned its detail pages; every selector the old parser used // (job-text, jix-info, jix_robotjob--area, jix-toolbar-top__company) is gone // from live pages, so detail returned null company/location/date, CSS-comment // text as the deadline, and an external ATS URL as its own id/url - exit 0, // nothing signalling breakage (review finding F14, 2026-08-19, measured on // 5/5 live postings). These fixtures are trimmed from live pages captured // 2026-08-19: the jobindex-native "jd-*" shape and the external-ATS // (hr-manager/Talentech) passthrough shape. const NATIVE_PAGE = ` VELLIV - Udvikler til Camunda/AWS

Udvikler til Camunda/AWS

En virksomhed med mere end 100 års historie, der samtidig er cloud-only, er ikke hverdagskost.

Hos Velliv får du mulighed for at arbejde med Camunda, AWS og automatisering af processer.

Jobtype:

Fast

Arbejdstid:

Fuldtid

Arbejdsdage:

Dag

Ansøgningsfrist:

13. september 2026

Arbejdssted:

Ballerup

`; // The external shape: an employer's ATS-hosted ad served through jobindex. // og:url points at the ATS (NOT the posting), og:site_name is the ATS brand, // and the only occurrence of the deadline label outside the widget is inside // a CSS comment - the exact text the old regex captured as the deadline. const EXTERNAL_PAGE = ` Talentech - C#-udvikler til kritiske analyseløsninger i elnettet

C#-udvikler til kritiske analyseløsninger i elnettet

Vil du være med til at udvikle og drifte de systemer, der understøtter udbygningen af Danmarks kommende elnet? Vi arbejder i krydsfeltet mellem IT og energi.

Workplace
Fredericia
Application due
21-09-2026
`; const JOBANNONCE_URL = "https://www.jobindex.dk/jobannonce/"; describe("parseDetailPage - jobindex-native (jd-*) shape", () => { const job = parseDetailPage(NATIVE_PAGE, `${JOBANNONCE_URL}h1690934`, "h1690934"); test("extracts the contract fields", () => { expect(job).toMatchObject({ id: "h1690934", title: "Udvikler til Camunda/AWS", company: "VELLIV", location: "Ballerup", deadline: "2026-09-13", url: `${JOBANNONCE_URL}h1690934`, }); }); test("converts the Danish long date to ISO", () => { expect(job.deadline).toBe("2026-09-13"); }); test("extracts employment metadata and the description body", () => { expect(job.employmentType).toBe("Fast"); expect(job.hours).toBe("Fuldtid"); expect(job.description).toContain("Camunda, AWS og automatisering"); }); }); describe("parseDetailPage - external ATS passthrough shape", () => { const job = parseDetailPage(EXTERNAL_PAGE, `${JOBANNONCE_URL}h1690445`, "h1690445"); test("keeps the jobindex id and jobannonce URL, never the ATS og:url", () => { expect(job.id).toBe("h1690445"); expect(job.url).toBe(`${JOBANNONCE_URL}h1690445`); expect(job.url).not.toContain("hr-manager.net"); }); test("extracts the title and never reports the ATS brand as the company", () => { expect(job.title).toBe("C#-udvikler til kritiske analyseløsninger i elnettet"); expect(job.company).toBeNull(); }); test("extracts the workplace widget location", () => { expect(job.location).toBe("Fredericia"); }); test("finds the real deadline, not the CSS comment", () => { expect(job.deadline).toBe("2026-09-21"); }); test("description is readable body text, not a stylesheet", () => { expect(job.description).toContain("udbygningen af Danmarks kommende elnet"); expect(job.description).not.toContain("padding-bottom"); }); test("deadline is null when only the CSS comment mentions the label", () => { const noDueWidget = EXTERNAL_PAGE.replace( /
[\s\S]*?
<\/div>/, "", ); const parsed = parseDetailPage(noDueWidget, `${JOBANNONCE_URL}h9`, "h9"); expect(parsed.deadline).toBeNull(); }); });