Compare commits

..

1 Commits

Author SHA1 Message Date
cesnimda 47f241c7f7 fix(i18n): preserve stored company and job calendar days
CI and Deploy / test (pull_request) Failing after 4m7s
CI and Deploy / deploy (pull_request) Has been skipped
2026-12-03 18:13:52 +01:00
10 changed files with 108 additions and 73 deletions
+18 -37
View File
@@ -93,45 +93,26 @@ jobs:
# The Debian runner omits pip and python3-venv. Use pip's official
# zipapp and install into the checkout so CI remains isolated without
# sudo or a mutable runner-global Python environment.
python_tmp="$(mktemp -d)"
trap 'rm -rf -- "$python_tmp"' EXIT
curl -fsSLo "$python_tmp/pip.pyz" https://bootstrap.pypa.io/pip/pip.pyz
install_locked() {
local interpreter="$1" destination="$2" attempt scratch
shift 2
for attempt in 1 2 3; do
scratch="$(mktemp -d "$python_tmp/install.XXXXXX")"
if PIP_CACHE_DIR="$scratch/cache" "$interpreter" "$python_tmp/pip.pyz" install \
--target "$scratch/site" --require-hashes "$@"; then
mv "$scratch/site" "$destination"
return
fi
echo "Locked Python dependency install attempt $attempt failed."
done
return 1
curl -fsSLo /tmp/pip.pyz https://bootstrap.pypa.io/pip/pip.pyz
install_parser_dependencies() {
rm -rf .python-ci
parser_pip_cache="$(mktemp -d)"
PIP_CACHE_DIR="$parser_pip_cache" python3 /tmp/pip.pyz install --target .python-ci --require-hashes \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r requirements-linux.lock
}
parser_install_succeeded=false
for attempt in 1 2 3; do
if install_parser_dependencies; then
parser_install_succeeded=true
break
fi
echo "Parser dependency install attempt $attempt failed — retrying with a fresh isolated cache..."
done
test "$parser_install_succeeded" = true
PIP_CACHE_DIR="$parser_pip_cache" python3 /tmp/pip.pyz install --upgrade --target .python-ci pytest==8.3.5 httpx2==2.12.0
python3 --version
install_locked python3 "$python_tmp/sidecar" --extra-index-url https://download.pytorch.org/whl/cpu \
-r requirements-dev-linux.lock
PYTHONFAULTHANDLER=1 PYTHONPATH="$python_tmp/sidecar" AI_SERVICE_SKIP_MODEL_LOAD=1 \
python3 -m pytest -q --ignore=tests/test_document_extractor.py
# The CV parser uses a separate dependency set. Its lock already pins
# pluggy and pygments; add the remaining hashed pytest requirements.
# The Docling lock targets Python 3.12, while the Debian runner uses 3.11.
cv_archive="$python_tmp/cv-python.tar.gz"
curl -fsSL --retry 2 -o "$cv_archive" \
'https://github.com/astral-sh/python-build-standalone/releases/download/20250517/cpython-3.12.10%2B20250517-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz'
echo "0356bd1db292781a20e011d789f0c41ea5ec04731c8236c8185b53a54faf2871 $cv_archive" | sha256sum -c -
tar -xzf "$cv_archive" -C "$python_tmp"
cv_python="$python_tmp/python/bin/python3"
"$cv_python" --version
awk '/^[^[:space:]#]/ { include = /^(iniconfig|packaging|pytest)==/ }
include && !/^[[:space:]]*#/ { print }' requirements-dev-linux.lock > "$python_tmp/cv-test-tools.lock"
test "$(grep -Ec '^(iniconfig|packaging|pytest)==' "$python_tmp/cv-test-tools.lock")" -eq 3
install_locked "$cv_python" "$python_tmp/cv-parser" -r requirements-cv-import.lock -r "$python_tmp/cv-test-tools.lock"
PYTHONFAULTHANDLER=1 PYTHONPATH="$python_tmp/cv-parser" OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 \
"$cv_python" -m pytest -q tests/test_document_extractor.py
PYTHONFAULTHANDLER=1 PYTHONPATH="$PWD/.python-ci" AI_SERVICE_SKIP_MODEL_LOAD=1 python3 -m pytest -q
- name: Restore backend
# The runner/proxy has occasionally supplied checksum-invalid NuGet cache entries (NU3008).
+14 -14
View File
@@ -30,7 +30,7 @@
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-grid-layout": "2.3.0",
"react-router-dom": "^7.18.5",
"react-router-dom": "^7.18.2",
"typescript": "^5.9.3",
"web-vitals": "^2.1.4"
},
@@ -6285,9 +6285,9 @@
}
},
"node_modules/cross-spawn": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.2.tgz",
"integrity": "sha512-8BPK2r+sKWC8sDinRwLwrFMq2lXTBBwzYYEB9LiCznfMurOi4FOvQflq3XOLGG+HPdMSVpe+k/s96+AtDEOgPg==",
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -11055,9 +11055,9 @@
}
},
"node_modules/react-router": {
"version": "7.18.5",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.5.tgz",
"integrity": "sha512-dTgvcXDOrLPrlLHrcZAqWveiK1hMSqN+rGAJzegP8HtmNkfRxOoshGWBNX3ZJ0cZjOHkRdlUJtaIhZMLLyGyPw==",
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.2.tgz",
"integrity": "sha512-aUVMjFm3GAPTTZL7oYr5E7ETiqfQCHRLH+B+5afnICvf0r7kkK4eR6SMuwbSTJw/7t+12khT/Kahij49fqOCIg==",
"license": "MIT",
"dependencies": {
"cookie": "^1.0.1",
@@ -11077,12 +11077,12 @@
}
},
"node_modules/react-router-dom": {
"version": "7.18.5",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.5.tgz",
"integrity": "sha512-9HcfDMU6JJ/fp6gJZYGwNE6RknVGS4kBjH1HkNw959mCJi70TVwdipQWv2FEol9uGpi+SZTFtVpJPtEQfayeOw==",
"version": "7.18.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.2.tgz",
"integrity": "sha512-AIKJ/jgGlFb3EbfCXk5Gzshiwt+l3mqbCrNjmEWMMjqQxNJ3svBa6bgzFyCC2Sw3RA0VWF1kg3uQf2OFhxb8hw==",
"license": "MIT",
"dependencies": {
"react-router": "7.18.5"
"react-router": "7.18.2"
},
"engines": {
"node": ">=20.0.0"
@@ -12749,9 +12749,9 @@
}
},
"node_modules/ws": {
"version": "8.23.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.23.1.tgz",
"integrity": "sha512-1rzWDSN0NOi3tpwgHsQExjWRoKUGtjCkJ2gZRaaRtzhYLboMytOI9pj9PU7yCgY37auqdd4OyLofZDbkeuZmPA==",
"version": "8.21.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz",
"integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==",
"dev": true,
"license": "MIT",
"engines": {
+1 -1
View File
@@ -25,7 +25,7 @@
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-grid-layout": "2.3.0",
"react-router-dom": "^7.18.5",
"react-router-dom": "^7.18.2",
"typescript": "^5.9.3",
"web-vitals": "^2.1.4"
},
+15
View File
@@ -0,0 +1,15 @@
import { parseISO } from "date-fns";
export function storedCalendarDay(value?: string | null): string {
if (!value || !/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(value) || Number.isNaN(+parseISO(value))) return "";
return value.slice(0, 10);
}
export function formatStoredCalendarDay(value: string | null | undefined, locale: string): string {
const day = storedCalendarDay(value);
return day ? new Date(day).toLocaleDateString(locale, { timeZone: "UTC" }) : "";
}
export function saveCalendarDay(day: string, original?: string | null): string | null {
return day ? (day === storedCalendarDay(original) ? original! : day) : null;
}
@@ -19,6 +19,31 @@ beforeEach(() => {
window.localStorage.clear();
});
test.each([
"2026-11-23",
"2026-11-23T23:30:00Z",
"2026-11-23T00:30:00+14:00",
"2026-11-23T00:00:00",
null,
"2026-02-30",
])("preserves the stored company day in the table and editor for %s", async nextContactAt => {
const company = { id: 3, name: "Acme", nextContactAt };
const day = nextContactAt?.startsWith("2026-11-23") ? "2026-11-23" : "";
mockedApi.get.mockResolvedValue({ data: [company] });
mockedApi.put.mockResolvedValue({ data: company });
render(<I18nProvider><ToastProvider><MemoryRouter><CompaniesTable /></MemoryRouter></ToastProvider></I18nProvider>);
const edit = await screen.findByRole("button", { name: "Edit: Acme" });
const table = screen.getByRole("row", { name: /Acme/ });
if (day) expect(table).toHaveTextContent("11/23/2026");
else expect(table).not.toHaveTextContent(/Invalid Date|3\/2\/2026/);
fireEvent.click(edit);
const dialog = await screen.findByRole("dialog");
expect(within(dialog).getByLabelText("Next contact")).toHaveValue(day);
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => expect(mockedApi.put).toHaveBeenCalledWith("/companies/3",
expect.objectContaining({ nextContactAt: day ? nextContactAt : null })));
});
test("opens one company relationship view with applications and recent contact", async () => {
const company = { id: 3, name: "Acme", recruiterName: "Rita", recruiterEmail: "rita@example.test" };
mockedApi.get.mockImplementation((url) => Promise.resolve({ data: String(url).endsWith("/relationship") ? {
@@ -42,7 +67,7 @@ test.each(["en", "nb"])("company contact dates follow the %s UI locale", async (
const nextContactAt = "2026-11-23T12:00:00Z";
mockedApi.get.mockResolvedValue({ data: [{ id: 3, name: "Acme", nextContactAt, pipelineStage: "Interview" }] });
render(<I18nProvider><ToastProvider><MemoryRouter><CompaniesTable /></MemoryRouter></ToastProvider></I18nProvider>);
const expected = new Date(nextContactAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en");
const expected = new Date(nextContactAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en", { timeZone: "UTC" });
await screen.findByRole("button", { name: `${language === "nb" ? "Rediger" : "Edit"}: Acme` });
expect(screen.getByRole("row", { name: /Acme/ })).toHaveTextContent(expected);
expect(screen.getByRole("row", { name: /Acme/ })).toHaveTextContent("Interview");
@@ -24,6 +24,7 @@ import {
import useMediaQuery from "@mui/material/useMediaQuery";
import { api, getApiErrorMessage } from "../api";
import { formatStoredCalendarDay, saveCalendarDay, storedCalendarDay } from "../calendarDay";
import ViewStateNotice from "./ViewStateNotice";
import { Company } from "../types";
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
@@ -107,8 +108,8 @@ export default function CompaniesTable() {
setRecruiterEmail(c.recruiterEmail ?? "");
setRecruiterLinkedIn(c.recruiterLinkedIn ?? "");
setPipelineStage(c.pipelineStage ?? "");
setLastContactedAt((c.lastContactedAt ?? "").slice(0, 10));
setNextContactAt((c.nextContactAt ?? "").slice(0, 10));
setLastContactedAt(storedCalendarDay(c.lastContactedAt));
setNextContactAt(storedCalendarDay(c.nextContactAt));
setEditOpen(true);
};
@@ -156,8 +157,8 @@ export default function CompaniesTable() {
recruiterEmail: recruiterEmail.trim() || null,
recruiterLinkedIn: recruiterLinkedIn.trim() || null,
pipelineStage: pipelineStage.trim() || null,
lastContactedAt: lastContactedAt || null,
nextContactAt: nextContactAt || null,
lastContactedAt: saveCalendarDay(lastContactedAt, editing.lastContactedAt),
nextContactAt: saveCalendarDay(nextContactAt, editing.nextContactAt),
});
companiesResource.setData((prev) => prev.map((x) => (x.id === res.data.id ? res.data : x)));
@@ -212,7 +213,7 @@ export default function CompaniesTable() {
{renderCompanyMeta(t("companiesSource"), c.source)}
{renderCompanyMeta(t("companiesPipeline"), c.pipelineStage)}
{renderCompanyMeta(t("companiesRecruiter"), [c.recruiterName, c.recruiterEmail].filter(Boolean).join(" · "))}
{renderCompanyMeta(t("companiesNextContact"), c.nextContactAt ? new Date(c.nextContactAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : null)}
{renderCompanyMeta(t("companiesNextContact"), formatStoredCalendarDay(c.nextContactAt, language === "nb" ? "nb-NO" : "en") || null)}
</Box>
</Stack>
</Paper>
@@ -248,7 +249,7 @@ export default function CompaniesTable() {
{c.recruiterName ?? ""}
{c.recruiterEmail ? ` (${c.recruiterEmail})` : ""}
</TableCell>
<TableCell sx={{ whiteSpace: "nowrap" }}>{c.nextContactAt ? new Date(c.nextContactAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : ""}</TableCell>
<TableCell sx={{ whiteSpace: "nowrap" }}>{formatStoredCalendarDay(c.nextContactAt, language === "nb" ? "nb-NO" : "en")}</TableCell>
<TableCell align="right" sx={{ whiteSpace: "nowrap" }}>
<IconButton size="small" data-company-relationship={c.id} aria-label={`${t("companiesRelationship")}: ${c.name}`} onClick={() => void openRelationship(c)}>
<PeopleAltOutlinedIcon fontSize="small" />
@@ -368,8 +369,8 @@ export default function CompaniesTable() {
<Stack spacing={2} sx={{ mt: 0.5 }}>
<Box sx={{ display: "grid", gridTemplateColumns: { xs: "1fr", sm: "repeat(3, minmax(0, 1fr))" }, gap: 1.5 }}>
{renderCompanyMeta(t("companiesRecruiter"), [relationship.company.recruiterName, relationship.company.recruiterEmail].filter(Boolean).join(" · "))}
{renderCompanyMeta(t("companiesLastContacted"), relationship.company.lastContactedAt ? new Date(relationship.company.lastContactedAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : null)}
{renderCompanyMeta(t("companiesNextContact"), relationship.company.nextContactAt ? new Date(relationship.company.nextContactAt).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : null)}
{renderCompanyMeta(t("companiesLastContacted"), formatStoredCalendarDay(relationship.company.lastContactedAt, language === "nb" ? "nb-NO" : "en") || null)}
{renderCompanyMeta(t("companiesNextContact"), formatStoredCalendarDay(relationship.company.nextContactAt, language === "nb" ? "nb-NO" : "en") || null)}
</Box>
<Box>
<Typography component="h3" variant="sectionTitle" sx={{ mb: 1 }}>{t("companiesApplications")}</Typography>
@@ -19,6 +19,7 @@ import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { format, parseISO } from "date-fns";
import { api } from "../api";
import { saveCalendarDay, storedCalendarDay } from "../calendarDay";
import { Company, JobApplication } from "../types";
import { useToast } from "../toast";
import { useCompanies } from "../hooks/useCompanies";
@@ -74,6 +75,7 @@ export default function EditJobDialog({ open, jobId, onClose, onSaved }: Props)
const [version, setVersion] = useState<number | null>(null);
const session = useRef(0);
const saving = useRef(false);
const originalDates = useRef<Pick<JobApplication, "dateApplied" | "deadline"> | null>(null);
const { companies } = useCompanies();
const [company, setCompany] = useState<Company | null>(null);
@@ -114,13 +116,14 @@ export default function EditJobDialog({ open, jobId, onClose, onSaved }: Props)
api.get<JobApplication>(`/jobapplications/${jobId}`).then((r) => {
if (current !== session.current) return;
const j = r.data;
originalDates.current = { dateApplied: j.dateApplied, deadline: j.deadline };
setVersion(j.version);
setCompany(j.company ?? null);
setJobTitle(j.jobTitle ?? "");
setStatus(j.status ?? "Applied");
setInitialStatus(j.status ?? "Applied");
setStatusChangedAt(new Date().toISOString().slice(0, 10));
setDateApplied(toDateInputValue(j.dateApplied ?? undefined));
setDateApplied(storedCalendarDay(j.dateApplied));
setLocation(j.location ?? "");
setSalary(j.salary ?? "");
setSalaryMin(j.salaryMin != null ? String(j.salaryMin) : "");
@@ -135,7 +138,7 @@ export default function EditJobDialog({ open, jobId, onClose, onSaved }: Props)
setTranslatedDescription((j as any).translatedDescription ?? "");
setDescriptionLanguage((j as any).descriptionLanguage ?? "");
setTags(parseTags((j as any).tags));
setDeadline((j as any).deadline ? toDateInputValue((j as any).deadline) : "");
setDeadline(storedCalendarDay(j.deadline));
setCoverLetterText(j.coverLetterText ?? "");
setResponseReceived(Boolean(j.responseReceived));
setResponseDate(j.responseDate ? toDateInputValue(j.responseDate) : "");
@@ -180,9 +183,9 @@ export default function EditJobDialog({ open, jobId, onClose, onSaved }: Props)
translatedDescription: translatedDescription || null,
descriptionLanguage: descriptionLanguage || null,
tags: tags.length ? JSON.stringify(tags) : null,
deadline: deadline || null,
deadline: saveCalendarDay(deadline, originalDates.current?.deadline),
coverLetterText: coverLetterText || null,
dateApplied: dateApplied || null,
dateApplied: saveCalendarDay(dateApplied, originalDates.current?.dateApplied),
jobUrl: jobUrl.trim() || null,
});
if (current !== session.current) return;
+3 -2
View File
@@ -38,6 +38,7 @@ import SearchIcon from "@mui/icons-material/Search";
import WorkOutlineIcon from "@mui/icons-material/WorkOutline";
import { api } from "../api";
import { formatStoredCalendarDay } from "../calendarDay";
import ViewStateNotice from "./ViewStateNotice";
import { useCompanies } from "../hooks/useCompanies";
import { useDebouncedValue } from "../hooks/useDebouncedValue";
@@ -488,7 +489,7 @@ export default function JobTable({ refreshToken, pageSize, onPageSizeChange, col
toneName: statusTone(job.status),
tags: parseTags(job.tags),
actionSignals: actionSignal ? [actionSignal] : [],
appliedDateLabel: job.dateApplied ? new Date(job.dateApplied).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : "—",
appliedDateLabel: formatStoredCalendarDay(job.dateApplied, language === "nb" ? "nb-NO" : "en") || "—",
isSelected: selectedIdSet.has(job.id),
};
}), [buildWorkflowActionSignal, filteredJobs, selectedIdSet, language]);
@@ -915,7 +916,7 @@ export default function JobTable({ refreshToken, pageSize, onPageSizeChange, col
{columns.status ? <TableCell><Chip label={statusLabel(t, job.status)} size="small" color={toneName as any} variant="outlined" sx={{ fontWeight: 600 }} /></TableCell> : null}
{columns.dateApplied ? <TableCell>{appliedDateLabel}</TableCell> : null}
{columns.daysSince ? <TableCell>{job.daysSince ?? "—"}</TableCell> : null}
<TableCell>{job.deadline ? new Date(job.deadline).toLocaleDateString(language === "nb" ? "nb-NO" : "en") : "—"}</TableCell>
<TableCell>{formatStoredCalendarDay(job.deadline, language === "nb" ? "nb-NO" : "en") || "—"}</TableCell>
{columns.jobUrl ? <TableCell>{job.jobUrl ? <Link href={job.jobUrl} target="_blank" rel="noreferrer" underline="always">{t("jobTableLink")}</Link> : ""}</TableCell> : null}
<TableCell align="right">{rowActions(job)}</TableCell>
</TableRow>
@@ -108,10 +108,19 @@ test.each(["en", "nb"] as const)("%s Edit date-only picker round trip preserves
await waitFor(() => expect(client.put).toHaveBeenCalledWith("/jobapplications/1", expect.objectContaining({ expectedVersion: 7, dateApplied: "2026-11-23", deadline: "2026-11-23", followUpAt: "2026-11-23", responseDate: "2026-11-23" })));
});
test("Edit retains its existing UTC calendar-day loading policy for a legacy offset timestamp", async () => {
client.get.mockResolvedValue({ data: { ...job, deadline: "2026-11-23T23:30:00-08:00" } } as any);
test.each([
"2026-11-23",
"2026-11-23T23:30:00Z",
"2026-11-23T23:30:00-08:00",
"2026-11-23T00:00:00",
])("Edit displays the stored day and submits the original value when unchanged (%s)", async original => {
client.get.mockResolvedValue({ data: { ...job, dateApplied: original, deadline: original } } as any);
render(wrap(<EditJobDialog open jobId={1} onClose={jest.fn()} onSaved={jest.fn()} />));
await screen.findByDisplayValue("Teacher");
expect(screen.getByLabelText(translations.en.editJobDeadline)).toHaveTextContent("2026-11-24");
expect(client.put).not.toHaveBeenCalled();
expect(screen.getByLabelText(translations.en.editJobAppliedOn)).toHaveTextContent("2026-11-23");
expect(screen.getByLabelText(translations.en.editJobDeadline)).toHaveTextContent("2026-11-23");
fireEvent.click(screen.getByRole("button", { name: translations.en.save }));
await waitFor(() => expect(client.put).toHaveBeenCalledWith("/jobapplications/1", expect.objectContaining({
expectedVersion: 7, dateApplied: original, deadline: original,
})));
});
@@ -216,8 +216,8 @@ test("Bokmål display localizes standard statuses without changing API values or
const row = await screen.findByRole("row", { name: /platform engineer/i });
expect(lastParams().status).toBe("Custom review");
expect(within(row).getByText(translations.nb.statusInterview)).toBeVisible();
expect(within(row).getByText(new Date(standardJob.dateApplied).toLocaleDateString("nb-NO"))).toBeVisible();
expect(within(row).getByText(new Date(standardJob.deadline).toLocaleDateString("nb-NO"))).toBeVisible();
expect(within(row).getByText(new Date(standardJob.dateApplied).toLocaleDateString("nb-NO", { timeZone: "UTC" }))).toBeVisible();
expect(within(row).getByText(new Date(standardJob.deadline).toLocaleDateString("nb-NO", { timeZone: "UTC" }))).toBeVisible();
expect(screen.getByRole("combobox", { name: translations.nb.jobTableStatus })).toHaveTextContent("Custom review");
fireEvent.click(within(row).getByRole("button", { name: `${translations.nb.jobTableActions}: ${job.jobTitle}` }));
fireEvent.click(await screen.findByRole("menuitem", { name: translations.nb.jobTableSetStatus.replace("{status}", translations.nb.statusOffer) }));