feat(privacy): complete the publication, hiding and preview settings screen
This commit is contained in:
1 parent
c2a8d17195
commit
5edff21d2d
28 files changed
+2230
-428
No files matched your search
@@ -1,6 +1,11 @@
|
||||
export {
|
||||
cardAccessLabels,
|
||||
cardFieldLabels,
|
||||
contactAccessAfterVisibilityChange,
|
||||
describeAccessOrganization,
|
||||
describePublicationClosure,
|
||||
evidenceBasisLabels,
|
||||
evidenceCalibrationLabels,
|
||||
buildSearchStatusSubmission,
|
||||
buildPublicationSubmission,
|
||||
currentC2State,
|
||||
@@ -16,9 +21,13 @@ export {
|
||||
specializationLabels,
|
||||
} from "./model/presentation";
|
||||
export { candidateViewQueryKeys } from "./model/query-keys";
|
||||
export { EmployerCardPreview } from "./ui/employer-card-preview";
|
||||
export type {
|
||||
C2State,
|
||||
CandidateViewPresentation,
|
||||
EvidencePresentation,
|
||||
PublicationClosureNotice,
|
||||
SelfAssessmentPresentation,
|
||||
PublicationDraft,
|
||||
PublicationSubmission,
|
||||
PublishableCardField,
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { CardField, CardPreview } from "../../../shared/api/schemas";
|
||||
import { editableCardFields, presentCandidatePreview, publishableCardFields } from "./presentation";
|
||||
import {
|
||||
contactAccessAfterVisibilityChange,
|
||||
describeAccessOrganization,
|
||||
describePublicationClosure,
|
||||
editableCardFields,
|
||||
presentCandidatePreview,
|
||||
publishableCardFields,
|
||||
} from "./presentation";
|
||||
|
||||
function preview(card: NonNullable<CardPreview["card"]>): CardPreview {
|
||||
return {
|
||||
@@ -43,11 +50,99 @@ describe("candidate card presentation", () => {
|
||||
{
|
||||
specialization: "Сетевое администрирование",
|
||||
declaredGrade: "Middle",
|
||||
confirmed: false,
|
||||
confirmation: "Грейд не подтвержден",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("states the confirmation of every specialization on its own", () => {
|
||||
const result = presentCandidatePreview(
|
||||
preview({
|
||||
pseudonym: `cv1_${"b".repeat(43)}`,
|
||||
categories: [{ specialization: "backend", grade: "middle", strength: "strong" }],
|
||||
stack: null,
|
||||
self_assessment: [
|
||||
{ specialization: "backend", confirmation_status: "confirmed", declared_grade: "middle" },
|
||||
{
|
||||
specialization: "network_engineer",
|
||||
confirmation_status: "unconfirmed",
|
||||
declared_grade: "junior",
|
||||
},
|
||||
{ specialization: "qa", confirmation_status: "unconfirmed", declared_grade: null },
|
||||
],
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(
|
||||
result?.selfAssessments?.map((item) => [
|
||||
item.specialization,
|
||||
item.confirmed,
|
||||
item.confirmation,
|
||||
]),
|
||||
).toEqual([
|
||||
["Backend", true, "Грейд подтвержден"],
|
||||
["Сетевое администрирование", false, "Грейд не подтвержден"],
|
||||
["Тестирование", false, "Грейд не подтвержден"],
|
||||
]);
|
||||
expect(result?.selfAssessments?.[2]?.declaredGrade).toBeNull();
|
||||
});
|
||||
|
||||
it("restates the evidence basis and calibration the server reports", () => {
|
||||
const result = presentCandidatePreview({
|
||||
...preview({
|
||||
pseudonym: `cv1_${"c".repeat(43)}`,
|
||||
categories: [{ specialization: "backend", grade: "middle", strength: "standard" }],
|
||||
stack: null,
|
||||
self_assessment: null,
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
}),
|
||||
evidence: {
|
||||
items: [
|
||||
{
|
||||
skill: "backend",
|
||||
grade: "middle",
|
||||
trust: 1,
|
||||
basis: "synthetic_demo",
|
||||
calibration_status: "uncalibrated",
|
||||
observed_year: 2026,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(result?.evidence).toEqual([
|
||||
{
|
||||
title: "Backend: Middle",
|
||||
trust: "partial",
|
||||
trustLabel: "Онлайн-результат без подтверждения личности",
|
||||
observedYear: 2026,
|
||||
basisLabel: "Синтетическая демонстрация, не проверенное измерение",
|
||||
calibrationLabel: "Пороги не откалиброваны",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps an empty evidence list apart from a closed card", () => {
|
||||
const published = presentCandidatePreview(
|
||||
preview({
|
||||
pseudonym: `cv1_${"d".repeat(43)}`,
|
||||
categories: null,
|
||||
stack: null,
|
||||
self_assessment: null,
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
}),
|
||||
);
|
||||
expect(published?.evidence).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not present a closed preview as an empty published card", () => {
|
||||
expect(
|
||||
presentCandidatePreview({
|
||||
@@ -82,3 +177,42 @@ describe("editable card fields", () => {
|
||||
expect(editableCardFields(stored)).toEqual(["categories", "work_formats"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("publication closure explanation", () => {
|
||||
it("explains a revoked C2 as closed future reads and a new C4 for a former company", () => {
|
||||
const notice = describePublicationClosure({
|
||||
state: "closed",
|
||||
closed_reason: "consent_revoked",
|
||||
});
|
||||
const text = [notice?.title, ...(notice?.points ?? [])].join(" ");
|
||||
|
||||
expect(text).toContain("Будущие чтения карточки компаниями закрыты");
|
||||
expect(text).toContain("Новое согласие C2 не откроет карточку само");
|
||||
expect(text).toContain("новое приглашение и новое согласие C4");
|
||||
});
|
||||
|
||||
it("explains a closing by the candidate and says nothing about a published or new card", () => {
|
||||
expect(
|
||||
describePublicationClosure({
|
||||
state: "closed",
|
||||
closed_reason: "closed_by_candidate",
|
||||
})?.points.join(" "),
|
||||
).toContain("не восстанавливает прежний доступ к контактам");
|
||||
expect(describePublicationClosure({ state: "published", closed_reason: null })).toBeNull();
|
||||
expect(
|
||||
describePublicationClosure({ state: "closed", closed_reason: "never_published" }),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("never promises that an unhide or a republish restores a contact grant", () => {
|
||||
expect(contactAccessAfterVisibilityChange).toContain("не восстанавливают прежний доступ");
|
||||
expect(contactAccessAfterVisibilityChange).toContain("новое согласие C4");
|
||||
});
|
||||
});
|
||||
|
||||
describe("card access organization", () => {
|
||||
it("does not invent a name for an organization the server cannot present", () => {
|
||||
expect(describeAccessOrganization(null)).toBe("Организация не раскрывается");
|
||||
expect(describeAccessOrganization({ name: "Компания А" })).toBe("Компания А");
|
||||
});
|
||||
});
|
||||
@@ -5,14 +5,20 @@ import type {
|
||||
CardPreview,
|
||||
CardSelfAssessment,
|
||||
CandidateExperienceBand,
|
||||
EvidenceBasis,
|
||||
EvidenceCalibrationStatus,
|
||||
EvidenceSkillCode,
|
||||
CandidateSalaryCompatibility,
|
||||
CandidateWorkFormat,
|
||||
ConsentRecord,
|
||||
HiddenOrganization,
|
||||
OrganizationEvidenceFact,
|
||||
PrivacySettings,
|
||||
Publication,
|
||||
PublicationUpdate,
|
||||
SearchStatusUpdate,
|
||||
} from "../../../shared/api/schemas";
|
||||
import type { TrustLevelValue } from "../../../shared/ui";
|
||||
|
||||
export const publishableCardFields = [
|
||||
"categories",
|
||||
@@ -196,9 +202,21 @@ export type CategoryPresentation = {
|
||||
export type SelfAssessmentPresentation = {
|
||||
specialization: string;
|
||||
declaredGrade: string | null;
|
||||
/** True only when the server says this specialization has a confirmed grade. */
|
||||
confirmed: boolean;
|
||||
confirmation: string;
|
||||
};
|
||||
|
||||
export type EvidencePresentation = {
|
||||
/** Skill and passed grade, for example "Backend: Middle". */
|
||||
title: string;
|
||||
trust: TrustLevelValue;
|
||||
trustLabel: string;
|
||||
observedYear: number;
|
||||
basisLabel: string;
|
||||
calibrationLabel: string;
|
||||
};
|
||||
|
||||
export type CandidateViewPresentation = {
|
||||
pseudonym: string;
|
||||
categories: readonly CategoryPresentation[] | null;
|
||||
@@ -207,6 +225,11 @@ export type CandidateViewPresentation = {
|
||||
experience: string | null;
|
||||
workFormats: readonly string[] | null;
|
||||
salaryCompatibility: string | null;
|
||||
/**
|
||||
* Supporting assessment facts as an organization reads them. Null while the
|
||||
* card is closed; an empty list when no visible fact supports a category.
|
||||
*/
|
||||
evidence: readonly EvidencePresentation[] | null;
|
||||
};
|
||||
|
||||
function categoryPresentation(category: CardCategory): CategoryPresentation {
|
||||
@@ -222,11 +245,53 @@ function selfAssessmentPresentation(item: CardSelfAssessment): SelfAssessmentPre
|
||||
return {
|
||||
specialization: specializationLabels[item.specialization],
|
||||
declaredGrade: item.declared_grade ? gradeLabels[item.declared_grade] : null,
|
||||
confirmed: item.confirmation_status === "confirmed",
|
||||
confirmation:
|
||||
item.confirmation_status === "confirmed" ? "Грейд подтвержден" : "Грейд не подтвержден",
|
||||
};
|
||||
}
|
||||
|
||||
const evidenceSkillLabels: Readonly<Record<EvidenceSkillCode, string>> = {
|
||||
...specializationLabels,
|
||||
...stackLabels,
|
||||
};
|
||||
|
||||
// The shape of a mark follows the strength of the confirmation, and the label
|
||||
// always names the exact meaning of the level so it never depends on the shape.
|
||||
type EvidenceTrustView = { level: TrustLevelValue; label: string };
|
||||
|
||||
const claimedEvidence: EvidenceTrustView = {
|
||||
level: "claimed",
|
||||
label: "Заявлено, не подтверждено отдельно",
|
||||
};
|
||||
|
||||
const evidenceTrust: Readonly<Record<number, EvidenceTrustView>> = {
|
||||
0: claimedEvidence,
|
||||
1: { level: "partial", label: "Онлайн-результат без подтверждения личности" },
|
||||
2: { level: "confirmed", label: "Результат привязан к подтвержденной личности" },
|
||||
3: { level: "confirmed", label: "Очная проверка" },
|
||||
};
|
||||
|
||||
export const evidenceBasisLabels: Readonly<Record<EvidenceBasis, string>> = {
|
||||
synthetic_demo: "Синтетическая демонстрация, не проверенное измерение",
|
||||
};
|
||||
|
||||
export const evidenceCalibrationLabels: Readonly<Record<EvidenceCalibrationStatus, string>> = {
|
||||
uncalibrated: "Пороги не откалиброваны",
|
||||
};
|
||||
|
||||
function evidencePresentation(fact: OrganizationEvidenceFact): EvidencePresentation {
|
||||
const trust = evidenceTrust[fact.trust] ?? claimedEvidence;
|
||||
return {
|
||||
title: `${evidenceSkillLabels[fact.skill]}: ${gradeLabels[fact.grade]}`,
|
||||
trust: trust.level,
|
||||
trustLabel: trust.label,
|
||||
observedYear: fact.observed_year,
|
||||
basisLabel: evidenceBasisLabels[fact.basis],
|
||||
calibrationLabel: evidenceCalibrationLabels[fact.calibration_status],
|
||||
};
|
||||
}
|
||||
|
||||
export function presentCandidatePreview(preview: CardPreview): CandidateViewPresentation | null {
|
||||
const card = preview.card;
|
||||
if (!card) return null;
|
||||
@@ -241,6 +306,7 @@ export function presentCandidatePreview(preview: CardPreview): CandidateViewPres
|
||||
salaryCompatibility: card.salary_compatibility
|
||||
? salaryCompatibilityLabels[card.salary_compatibility]
|
||||
: null,
|
||||
evidence: preview.evidence ? preview.evidence.items.map(evidencePresentation) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -269,3 +335,49 @@ export const cardAccessLabels = {
|
||||
card_viewed: "Просмотрена карточка профиля",
|
||||
contact_read: "Открыты контактные данные",
|
||||
} as const;
|
||||
|
||||
export type PublicationClosureNotice = {
|
||||
title: string;
|
||||
points: readonly string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Explains a closed card to its owner. The text restates the server reason and
|
||||
* the contract rules: a closed card is unreadable at once, and neither a new
|
||||
* C2 nor an unhide reopens an earlier contact grant. A former company reads
|
||||
* contacts again only after a new invitation and a new C4. The notice is
|
||||
* absent while the card is published and for a card that was never published.
|
||||
*/
|
||||
export function describePublicationClosure(
|
||||
publication: Pick<Publication, "state" | "closed_reason">,
|
||||
): PublicationClosureNotice | null {
|
||||
if (publication.state === "published") return null;
|
||||
if (publication.closed_reason === "consent_revoked") {
|
||||
return {
|
||||
title: "Согласие C2 отозвано, карточка закрыта",
|
||||
points: [
|
||||
"Будущие чтения карточки компаниями закрыты сразу, без ожидания обновления поиска.",
|
||||
"Новое согласие C2 не откроет карточку само: выберите поля и включите публикацию отдельным действием.",
|
||||
"Прежний доступ к контактам не возвращается. Компании, которая уже получала контакты, нужны новое приглашение и новое согласие C4.",
|
||||
],
|
||||
};
|
||||
}
|
||||
if (publication.closed_reason === "closed_by_candidate") {
|
||||
return {
|
||||
title: "Вы закрыли карточку",
|
||||
points: [
|
||||
"Будущие чтения карточки компаниями закрыты.",
|
||||
"Повторная публикация не восстанавливает прежний доступ к контактам: компании, которая уже получала контакты, нужны новое приглашение и новое согласие C4.",
|
||||
],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Wording about contact access that follows a hide, an unhide or a republish. */
|
||||
export const contactAccessAfterVisibilityChange =
|
||||
"Скрытие закрывает будущие чтения этой компании. Снятие скрытия и повторная публикация не восстанавливают прежний доступ к контактам: бывшей компании нужны новое приглашение и новое согласие C4.";
|
||||
|
||||
export function describeAccessOrganization(organization: { name: string } | null): string {
|
||||
return organization ? organization.name : "Организация не раскрывается";
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
.preview {
|
||||
display: grid;
|
||||
gap: var(--space-5);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.alias {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.note,
|
||||
.hint {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.925rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-block-start: var(--space-3);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.grid section {
|
||||
min-width: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
.grid h3 {
|
||||
margin: 0 0 var(--space-3);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.grid p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.grid .hint {
|
||||
margin-block-start: var(--space-3);
|
||||
}
|
||||
|
||||
.list {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* A declared grade and a confirmed grade differ by mark shape and text, not by color. */
|
||||
.assessment,
|
||||
.evidence {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
min-width: 0;
|
||||
padding-block-end: var(--space-3);
|
||||
border-block-end: var(--line-thin) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.list > li:last-child {
|
||||
padding-block-end: 0;
|
||||
border-block-end: 0;
|
||||
}
|
||||
|
||||
.assessment-name {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.declared {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-size-s);
|
||||
}
|
||||
|
||||
.evidence-facts,
|
||||
.facts {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr);
|
||||
gap: 0.35rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.evidence-facts dt,
|
||||
.facts dt {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.evidence-facts dd,
|
||||
.facts dd {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.facts {
|
||||
grid-template-columns: minmax(9rem, auto) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
@media (width < 48rem) {
|
||||
.grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.evidence-facts,
|
||||
.facts {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.evidence-facts dd + dt,
|
||||
.facts dd + dt {
|
||||
margin-block-start: 0.6rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { CardPreview } from "../../../shared/api/schemas";
|
||||
import { EmployerCardPreview } from "./employer-card-preview";
|
||||
|
||||
const pseudonym = `cv1_${"a".repeat(43)}`;
|
||||
|
||||
function published(overrides: Partial<CardPreview> = {}): CardPreview {
|
||||
return {
|
||||
state: "published",
|
||||
fields: ["categories", "self_assessment"],
|
||||
card: {
|
||||
pseudonym,
|
||||
categories: [{ specialization: "backend", grade: "middle", strength: "standard" }],
|
||||
stack: null,
|
||||
self_assessment: [
|
||||
{ specialization: "backend", confirmation_status: "confirmed", declared_grade: "middle" },
|
||||
{
|
||||
specialization: "network_engineer",
|
||||
confirmation_status: "unconfirmed",
|
||||
declared_grade: "junior",
|
||||
},
|
||||
{ specialization: "qa", confirmation_status: "unconfirmed", declared_grade: null },
|
||||
],
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
},
|
||||
evidence: {
|
||||
items: [
|
||||
{
|
||||
skill: "backend",
|
||||
grade: "middle",
|
||||
trust: 1,
|
||||
basis: "synthetic_demo",
|
||||
calibration_status: "uncalibrated",
|
||||
observed_year: 2026,
|
||||
},
|
||||
],
|
||||
},
|
||||
generated_at: "2026-10-03T10:00:00Z",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function render(
|
||||
preview: CardPreview | undefined,
|
||||
extra: { isLoading?: boolean; error?: unknown } = {},
|
||||
) {
|
||||
return renderToStaticMarkup(
|
||||
<EmployerCardPreview
|
||||
preview={preview}
|
||||
isLoading={extra.isLoading ?? false}
|
||||
error={extra.error ?? null}
|
||||
onRetry={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("employer card preview", () => {
|
||||
it("keeps the owner alias apart from organization aliases", () => {
|
||||
const markup = render(published());
|
||||
|
||||
expect(markup).toContain("Предварительный псевдоним");
|
||||
expect(markup).toContain(pseudonym);
|
||||
expect(markup).toContain("Это отдельный псевдоним предпросмотра");
|
||||
});
|
||||
|
||||
it("states the confirmation of each specialization separately", () => {
|
||||
const markup = render(published());
|
||||
|
||||
expect(markup).toContain("Backend: Middle, стандартное подтверждение");
|
||||
expect(markup.match(/Грейд подтвержден/g)).toHaveLength(1);
|
||||
expect(markup.match(/Грейд не подтвержден/g)).toHaveLength(2);
|
||||
expect(markup).toContain("Заявлено: Junior");
|
||||
expect(markup).toContain("Уровень не указан");
|
||||
// The mark of a confirmed grade and the mark of an unconfirmed one differ in markup.
|
||||
expect(markup).toContain('data-level="confirmed"');
|
||||
expect(markup).toContain('data-level="none"');
|
||||
expect(markup).toContain("неудачные попытки компании не видят");
|
||||
});
|
||||
|
||||
it("shows the unconfirmed state per specialization when no category exists", () => {
|
||||
const markup = render(
|
||||
published({
|
||||
fields: ["self_assessment"],
|
||||
card: {
|
||||
pseudonym,
|
||||
categories: null,
|
||||
stack: null,
|
||||
self_assessment: [
|
||||
{
|
||||
specialization: "backend",
|
||||
confirmation_status: "unconfirmed",
|
||||
declared_grade: "middle",
|
||||
},
|
||||
{
|
||||
specialization: "network_engineer",
|
||||
confirmation_status: "unconfirmed",
|
||||
declared_grade: "junior",
|
||||
},
|
||||
],
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
},
|
||||
evidence: { items: [] },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(markup).toContain("Подтвержденных категорий в карточке нет.");
|
||||
expect(markup.match(/Грейд не подтвержден/g)).toHaveLength(2);
|
||||
expect(markup).not.toContain("Грейд подтвержден");
|
||||
expect(markup).toContain("Для опубликованных категорий нет видимого подтверждающего факта.");
|
||||
});
|
||||
|
||||
it("labels the evidence basis and calibration the way the server states them", () => {
|
||||
const markup = render(published());
|
||||
|
||||
expect(markup).toContain("Подтверждающие факты оценки");
|
||||
expect(markup).toContain("Онлайн-результат без подтверждения личности");
|
||||
expect(markup).toContain("Синтетическая демонстрация, не проверенное измерение");
|
||||
expect(markup).toContain("Пороги не откалиброваны");
|
||||
expect(markup).toContain("2026");
|
||||
});
|
||||
|
||||
it("explains a closed card without offering to open it", () => {
|
||||
const markup = render({
|
||||
state: "closed",
|
||||
fields: [],
|
||||
card: null,
|
||||
evidence: null,
|
||||
generated_at: "2026-10-03T10:00:00Z",
|
||||
});
|
||||
|
||||
expect(markup).toContain("Карточка закрыта");
|
||||
expect(markup).toContain("Новый C2 не откроет ее автоматически");
|
||||
expect(markup).not.toContain("Подтверждающие факты оценки");
|
||||
});
|
||||
|
||||
it("renders the loading, error and missing states", () => {
|
||||
expect(render(undefined, { isLoading: true })).toContain("Загружаем предварительный просмотр");
|
||||
expect(render(undefined, { error: new Error("failed") })).toContain(
|
||||
"Не удалось загрузить предварительный просмотр",
|
||||
);
|
||||
expect(render(undefined)).toContain("Предварительный просмотр пока недоступен");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,178 @@
|
||||
import type { CardPreview } from "../../../shared/api/schemas";
|
||||
import { EmptyState, ErrorState, LoadingState, TrustLevel } from "../../../shared/ui";
|
||||
import {
|
||||
presentCandidatePreview,
|
||||
type CandidateViewPresentation,
|
||||
type EvidencePresentation,
|
||||
type SelfAssessmentPresentation,
|
||||
} from "../model/presentation";
|
||||
import styles from "./employer-card-preview.module.css";
|
||||
|
||||
type EmployerCardPreviewProps = {
|
||||
preview: CardPreview | undefined;
|
||||
isLoading: boolean;
|
||||
error: unknown;
|
||||
onRetry: () => void;
|
||||
};
|
||||
|
||||
function SelfAssessmentItem({ item }: { item: SelfAssessmentPresentation }) {
|
||||
return (
|
||||
<li className={styles.assessment} data-confirmed={item.confirmed}>
|
||||
<strong className={styles["assessment-name"]}>{item.specialization}</strong>
|
||||
<span className={styles.declared}>
|
||||
{item.declaredGrade ? `Заявлено: ${item.declaredGrade}` : "Уровень не указан"}
|
||||
</span>
|
||||
<TrustLevel level={item.confirmed ? "confirmed" : "none"} label={item.confirmation} />
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function EvidenceItem({ item }: { item: EvidencePresentation }) {
|
||||
return (
|
||||
<li className={styles.evidence}>
|
||||
<strong>{item.title}</strong>
|
||||
<TrustLevel level={item.trust} label={item.trustLabel} />
|
||||
<dl className={styles["evidence-facts"]}>
|
||||
<dt>Год оценки</dt>
|
||||
<dd>{item.observedYear}</dd>
|
||||
<dt>Основа</dt>
|
||||
<dd>{item.basisLabel}</dd>
|
||||
<dt>Калибровка</dt>
|
||||
<dd>{item.calibrationLabel}</dd>
|
||||
</dl>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function OtherGroups({ card }: { card: CandidateViewPresentation }) {
|
||||
const hasValues = card.stack || card.experience || card.workFormats || card.salaryCompatibility;
|
||||
return (
|
||||
<section aria-labelledby="preview-other-title">
|
||||
<h3 id="preview-other-title">Другие выбранные группы</h3>
|
||||
{hasValues ? (
|
||||
<dl className={styles.facts}>
|
||||
{card.stack ? (
|
||||
<>
|
||||
<dt>Технологии</dt>
|
||||
<dd>{card.stack.join(", ") || "Нет данных"}</dd>
|
||||
</>
|
||||
) : null}
|
||||
{card.experience ? (
|
||||
<>
|
||||
<dt>Общий опыт</dt>
|
||||
<dd>{card.experience}</dd>
|
||||
</>
|
||||
) : null}
|
||||
{card.workFormats ? (
|
||||
<>
|
||||
<dt>Форматы работы</dt>
|
||||
<dd>{card.workFormats.join(", ") || "Нет данных"}</dd>
|
||||
</>
|
||||
) : null}
|
||||
{card.salaryCompatibility ? (
|
||||
<>
|
||||
<dt>Совместимость ожиданий</dt>
|
||||
<dd>{card.salaryCompatibility}</dd>
|
||||
</>
|
||||
) : null}
|
||||
</dl>
|
||||
) : (
|
||||
<p>Другие группы не содержат значений.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The anonymous card the way the owner's private preview returns it. It shows
|
||||
* each specialization on its own: a confirmed category and a declared grade
|
||||
* that is still unconfirmed are never merged or ranked together, and the
|
||||
* evidence block restates the basis and calibration the server reports.
|
||||
*/
|
||||
export function EmployerCardPreview({
|
||||
preview,
|
||||
isLoading,
|
||||
error,
|
||||
onRetry,
|
||||
}: EmployerCardPreviewProps) {
|
||||
if (isLoading && !preview) return <LoadingState label="Загружаем предварительный просмотр..." />;
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorState
|
||||
error={error}
|
||||
onRetry={onRetry}
|
||||
title="Не удалось загрузить предварительный просмотр"
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (!preview) return <EmptyState title="Предварительный просмотр пока недоступен" />;
|
||||
|
||||
const card = presentCandidatePreview(preview);
|
||||
if (!card) {
|
||||
return (
|
||||
<EmptyState
|
||||
title="Карточка закрыта"
|
||||
description="Компании не видят карточку. Новый C2 не откроет ее автоматически: публикацию нужно включить отдельно."
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.preview}>
|
||||
<p className={styles.alias}>
|
||||
Предварительный псевдоним: <strong>{card.pseudonym}</strong>
|
||||
</p>
|
||||
<p className={styles.note}>
|
||||
Это отдельный псевдоним предпросмотра. В каждой организации используется свой псевдоним, а
|
||||
ее фильтры и проверка размера группы могут дополнительно скрыть или обобщить данные.
|
||||
</p>
|
||||
<div className={styles.grid}>
|
||||
<section aria-labelledby="preview-confirmed-title">
|
||||
<h3 id="preview-confirmed-title">Подтвержденные категории</h3>
|
||||
{card.categories?.length ? (
|
||||
<ul className={styles.list}>
|
||||
{card.categories.map((category) => (
|
||||
<li key={`${category.specialization}-${category.grade}`}>
|
||||
{category.specialization}: {category.grade}, {category.strength.toLowerCase()}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Подтвержденных категорий в карточке нет.</p>
|
||||
)}
|
||||
</section>
|
||||
<section aria-labelledby="preview-self-title">
|
||||
<h3 id="preview-self-title">Самооценка по направлениям</h3>
|
||||
{card.selfAssessments?.length ? (
|
||||
<ul className={styles.list}>
|
||||
{card.selfAssessments.map((item) => (
|
||||
<SelfAssessmentItem key={item.specialization} item={item} />
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Самооценка не опубликована или отсутствует.</p>
|
||||
)}
|
||||
<p className={styles.hint}>
|
||||
Статус подтверждения задается для каждой специализации отдельно. Причины его отсутствия
|
||||
и неудачные попытки компании не видят.
|
||||
</p>
|
||||
</section>
|
||||
{card.evidence ? (
|
||||
<section aria-labelledby="preview-evidence-title">
|
||||
<h3 id="preview-evidence-title">Подтверждающие факты оценки</h3>
|
||||
{card.evidence.length > 0 ? (
|
||||
<ul className={styles.list}>
|
||||
{card.evidence.map((item) => (
|
||||
<EvidenceItem key={item.title} item={item} />
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Для опубликованных категорий нет видимого подтверждающего факта.</p>
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
<OtherGroups card={card} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user