Skip to content

The job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.

test(portals): cover linkedin card date/location and jobindex parseSearchPage

Mads Lorentzen2edf8c41f159
diff --git a/.agents/skills/jobindex-search/cli/tests/search-page.test.ts b/.agents/skills/jobindex-search/cli/tests/search-page.test.ts
new file mode 100644
index 00000000..b9a2414f
--- /dev/null
+++ b/.agents/skills/jobindex-search/cli/tests/search-page.test.ts
@@ -0,0 +1,54 @@
+import { describe, expect, test } from "bun:test";
+import { parseSearchPage } from "../src/helpers";
+
+// parseSearchPage had no tests at all: mutating total to stop using
+// sr.hitcount survived the whole suite (review finding F35, 2026-08-19).
+// The fixture mirrors the real Stash nesting documented in helpers.ts:
+// jobsearch/result_app -> storeData -> searchResponse -> { hitcount, results[] }.
+function stashPage(searchResponse: object): string {
+ const stash = { jobsearch: { result_app: { storeData: { searchResponse } } } };
+ return `<html><head><script>var Stash = ${JSON.stringify(stash)};</script></head></html>`;
+}
+
+const RESULT = {
+ tid: "h1689961",
+ headline: "Softwareudvikler",
+ company: { name: "Acme A/S", homeurl: "https://acme.example" },
+ area: "Aarhus",
+ firstdate: "2026-08-10",
+ apply_deadline: "2026-09-11T00:00:00",
+};
+
+describe("parseSearchPage", () => {
+ test("total comes from hitcount, not the page's result count", () => {
+ const page = stashPage({ hitcount: 435, results: [RESULT] });
+ const parsed = parseSearchPage(page);
+ expect(parsed.total).toBe(435);
+ expect(parsed.results).toHaveLength(1);
+ });
+
+ test("total falls back to the result count when hitcount is absent", () => {
+ const page = stashPage({ results: [RESULT, { ...RESULT, tid: "h2" }] });
+ expect(parseSearchPage(page).total).toBe(2);
+ });
+
+ test("maps the contract fields from a Stash result", () => {
+ const [job] = parseSearchPage(stashPage({ hitcount: 1, results: [RESULT] })).results;
+ expect(job).toMatchObject({
+ id: "h1689961",
+ title: "Softwareudvikler",
+ company: "Acme A/S",
+ location: "Aarhus",
+ date: "2026-08-10",
+ deadline: "2026-09-11",
+ url: "https://www.jobindex.dk/jobannonce/h1689961",
+ });
+ });
+
+ test("falls back to lastdate when apply_deadline is absent", () => {
+ const [job] = parseSearchPage(
+ stashPage({ hitcount: 1, results: [{ ...RESULT, apply_deadline: undefined, lastdate: "2026-09-30" }] }),
+ ).results;
+ expect(job.deadline).toBe("2026-09-30");
+ });
+});
diff --git a/.agents/skills/linkedin-search/cli/tests/parsing.test.ts b/.agents/skills/linkedin-search/cli/tests/parsing.test.ts
index 93b44d18..4cfd98d8 100644
--- a/.agents/skills/linkedin-search/cli/tests/parsing.test.ts
+++ b/.agents/skills/linkedin-search/cli/tests/parsing.test.ts
@@ -14,6 +14,46 @@ function searchCard(id: string, title: string, company = "Acme"): string {
</li>`;
}
+// The /scrape contract fields beyond title/company. The original fixture had
+// no <time> or location element at all, so deleting the date extraction from
+// parseJobCards left every test green (review finding F35, 2026-08-19).
+function searchCardWithMeta(id: string, datetimeAttr: string, listdateClass = "job-search-card__listdate"): string {
+ return `<li>
+ <div data-entity-urn="urn:li:jobPosting:${id}">
+ <a class="base-card__full-link" href="https://www.linkedin.com/jobs/view/${id}"></a>
+ <h3 class="base-search-card__title">Data Engineer</h3>
+ <h4 class="base-search-card__subtitle"><a href="https://www.linkedin.com/company/acme">Acme</a></h4>
+ <span class="job-search-card__location">Copenhagen, Denmark</span>
+ <time class="${listdateClass}" datetime="${datetimeAttr}">3 days ago</time>
+ </div>
+ </li>`;
+}
+
+describe("parseJobCards contract fields", () => {
+ test("extracts date from the listdate <time> element", () => {
+ const [card] = parseJobCards(searchCardWithMeta("200", "2026-08-10"));
+ expect(card.date).toBe("2026-08-10");
+ });
+
+ test("extracts date from the listdate--new variant class", () => {
+ const [card] = parseJobCards(
+ searchCardWithMeta("201", "2026-08-15", "job-search-card__listdate--new"),
+ );
+ expect(card.date).toBe("2026-08-15");
+ });
+
+ test("extracts location from the location span", () => {
+ const [card] = parseJobCards(searchCardWithMeta("202", "2026-08-10"));
+ expect(card.location).toBe("Copenhagen, Denmark");
+ });
+
+ test("date and location are null when the elements are absent", () => {
+ const [card] = parseJobCards(searchCard("203", "Bare Card"));
+ expect(card.date).toBeNull();
+ expect(card.location).toBeNull();
+ });
+});
+
describe("decodeHtmlEntities (via parseJobCards)", () => {
test("decodes hexadecimal numeric entities (&#xE9;)", () => {
const [card] = parseJobCards(searchCard("123", "Caf&#xE9; Manager"));
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41b6d3dc..daae35f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,13 @@ per-file diff commands.
### Added
+- **Fixture coverage for linkedin's date/location and jobindex's `parseSearchPage`** -
+ linkedin's search-card fixture carried no `<time>` or location element, so deleting
+ the `date` extraction (a `/scrape` contract field on a default-ON portal) left every
+ test green; jobindex's Stash parser had no tests at all, so `meta.total` could stop
+ using `hitcount` unnoticed. Four new linkedin cases (both listdate class variants,
+ location, absent-element nulls) and a new jobindex `search-page.test.ts` (hitcount
+ vs page count, contract-field mapping, deadline fallbacks). Both mutation-verified.
- **Tests for `check_framework_version.py`** - the CI gate that stops a framework file
from being edited without a `framework_version` bump had zero tests, so the one-line
mutation `return meaningful_changes > 0` -> `return False` disabled it while the suite