feat: add candidate privacy controls

This commit is contained in:
TakuyaYagam1 committed 2026-10-08 08:43:11 +03:00
1 parent e6bd66c560
commit 95b8e566c4
20 files changed
+2592 -11

No files matched your search

@@ -0,0 +1,82 @@
import { describe, expect, it } from "vitest";
import type { CardField, CardPreview } from "../../../shared/api/schemas";
import { editableCardFields, presentCandidatePreview, publishableCardFields } from "./presentation";
function preview(card: NonNullable<CardPreview["card"]>): CardPreview {
return {
state: "published",
fields: ["categories", "self_assessment", "stack", "experience", "work_formats"],
card,
generated_at: "2026-10-06T12:00:00Z",
};
}
describe("candidate card presentation", () => {
it("keeps confirmed categories separate from declared grades", () => {
const result = presentCandidatePreview(
preview({
pseudonym: `cv1_${"a".repeat(43)}`,
categories: [{ specialization: "backend", grade: "junior", strength: "standard" }],
stack: ["go"],
self_assessment: [
{
specialization: "network_engineer",
confirmation_status: "unconfirmed",
declared_grade: "middle",
},
],
experience_band: "1_3",
work_formats: ["remote"],
salary_compatibility: null,
}),
);
expect(result?.categories).toEqual([
{
specialization: "Backend",
grade: "Junior",
strength: "Стандартное подтверждение",
},
]);
expect(result?.selfAssessments).toEqual([
{
specialization: "Сетевое администрирование",
declaredGrade: "Middle",
confirmation: "Грейд не подтвержден",
},
]);
});
it("does not present a closed preview as an empty published card", () => {
expect(
presentCandidatePreview({
state: "closed",
fields: [],
card: null,
generated_at: "2026-10-06T12:00:00Z",
}),
).toBeNull();
});
});
describe("editable card fields", () => {
it("exposes only safe groups supported by the anonymous-card contract", () => {
const stored: CardField[] = [
"categories",
"soft_skills",
"location",
"relocation",
"work_formats",
];
expect(publishableCardFields).toEqual([
"categories",
"self_assessment",
"stack",
"experience",
"work_formats",
"salary_compatibility",
]);
expect(editableCardFields(stored)).toEqual(["categories", "work_formats"]);
});
});