feat: add candidate privacy controls
This commit is contained in:
1 parent
e6bd66c560
commit
95b8e566c4
20 files changed
+2592
-11
No files matched your search
@@ -0,0 +1 @@
|
||||
export { PrivacyPage } from "./ui/privacy-page";
|
||||
@@ -0,0 +1,155 @@
|
||||
.preview,
|
||||
.organization-columns {
|
||||
display: grid;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
|
||||
.preview-alias {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.note {
|
||||
margin: 0.75rem 0 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.925rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.preview-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.preview-grid section,
|
||||
.organization-columns 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);
|
||||
}
|
||||
|
||||
.preview-grid h3,
|
||||
.organization-columns h3 {
|
||||
margin: 0 0 var(--space-3);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.preview-grid ul {
|
||||
margin: 0;
|
||||
padding-inline-start: 1.25rem;
|
||||
}
|
||||
|
||||
.preview-facts {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(9rem, auto) minmax(0, 1fr);
|
||||
gap: 0.45rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.preview-facts dt {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.preview-facts dd {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.organization-columns {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.organization-list,
|
||||
.history-list {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.organization-list li,
|
||||
.history-list li {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2) var(--space-4);
|
||||
padding-block: var(--space-3);
|
||||
border-block-end: var(--line-thin) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.organization-list li > div,
|
||||
.history-list li {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.organization-list li > div {
|
||||
display: grid;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.organization-list time,
|
||||
.history-list time,
|
||||
.history-list span {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.history-list li {
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.history-list strong,
|
||||
.history-list span {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.preview-grid li + li {
|
||||
margin-block-start: 0.4rem;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: var(--space-2);
|
||||
margin-block-start: var(--space-3);
|
||||
}
|
||||
|
||||
.pagination .note {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin-block-start: var(--space-3);
|
||||
padding: var(--space-3);
|
||||
border-inline-start: var(--line-strong) solid var(--color-danger);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.message {
|
||||
margin-block-start: var(--space-3);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
@media (width < 48rem) {
|
||||
.preview-grid,
|
||||
.organization-columns {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.preview-facts {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.preview-facts dd + dt {
|
||||
margin-block-start: 0.75rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type {
|
||||
CardAccess,
|
||||
CardPreview,
|
||||
HiddenOrganization,
|
||||
PrivacyEventList,
|
||||
} from "../../../shared/api/schemas";
|
||||
import {
|
||||
CardAccessHistory,
|
||||
OrganizationVisibility,
|
||||
PrivacyHistory,
|
||||
PrivacyPreview,
|
||||
} from "./privacy-page";
|
||||
|
||||
const orgA = {
|
||||
id: "00000000-0000-4000-8000-000000000001",
|
||||
name: "Компания А",
|
||||
};
|
||||
const orgB = {
|
||||
id: "00000000-0000-4000-8000-000000000002",
|
||||
name: "Компания Б",
|
||||
};
|
||||
|
||||
function accessRecord(
|
||||
id: string,
|
||||
organization: typeof orgA | null,
|
||||
kind: CardAccess["kind"] = "card_viewed",
|
||||
): CardAccess {
|
||||
return {
|
||||
id,
|
||||
kind,
|
||||
occurred_at: "2026-10-01T10:00:00Z",
|
||||
organization,
|
||||
};
|
||||
}
|
||||
|
||||
function hiddenOrganization(organization: typeof orgA): HiddenOrganization {
|
||||
return { organization, hidden_at: "2026-10-02T10:00:00Z" };
|
||||
}
|
||||
|
||||
describe("privacy page sections", () => {
|
||||
it("keeps the owner preview alias separate from organization aliases and category evidence", () => {
|
||||
const preview: CardPreview = {
|
||||
state: "published",
|
||||
fields: ["categories", "self_assessment"],
|
||||
card: {
|
||||
pseudonym: `cv1_${"a".repeat(43)}`,
|
||||
categories: [{ specialization: "backend", grade: "junior", strength: "standard" }],
|
||||
stack: null,
|
||||
self_assessment: [
|
||||
{
|
||||
specialization: "frontend",
|
||||
confirmation_status: "unconfirmed",
|
||||
declared_grade: "middle",
|
||||
},
|
||||
],
|
||||
experience_band: null,
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
},
|
||||
generated_at: "2026-10-03T10:00:00Z",
|
||||
};
|
||||
const markup = renderToStaticMarkup(
|
||||
<PrivacyPreview preview={preview} isLoading={false} error={null} onRetry={vi.fn()} />,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Предварительный псевдоним");
|
||||
expect(markup).toContain("Это отдельный псевдоним предпросмотра");
|
||||
expect(markup).toContain("Подтвержденные категории");
|
||||
expect(markup).toContain("Backend: Junior");
|
||||
expect(markup).toContain("Самооценка по направлениям");
|
||||
expect(markup).toContain("Frontend: Middle; грейд не подтвержден");
|
||||
});
|
||||
|
||||
it("does not offer hide actions until the hidden list is fully loaded", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OrganizationVisibility
|
||||
accessRecords={[accessRecord("00000000-0000-4000-8000-000000000011", orgA)]}
|
||||
accessLoading={false}
|
||||
accessError={null}
|
||||
accessHasMore={false}
|
||||
accessFetching={false}
|
||||
onLoadAccess={vi.fn()}
|
||||
hiddenOrganizations={[hiddenOrganization(orgB)]}
|
||||
hiddenLoading={false}
|
||||
hiddenError={null}
|
||||
hiddenHasMore
|
||||
hiddenFetching={false}
|
||||
onLoadHidden={vi.fn()}
|
||||
pendingAction={null}
|
||||
actionError={null}
|
||||
actionMessage={null}
|
||||
onHide={vi.fn()}
|
||||
onUnhide={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Компания Б");
|
||||
expect(markup).toContain("Снова разрешить просмотр");
|
||||
expect(markup).toContain(
|
||||
"Список действий появится после загрузки всех страниц скрытых компаний",
|
||||
);
|
||||
expect(markup).not.toContain("Скрыть профиль</button>");
|
||||
expect(markup).toContain("не восстанавливает C4");
|
||||
});
|
||||
|
||||
it("shows only organizations from access history as hide candidates", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<OrganizationVisibility
|
||||
accessRecords={[
|
||||
accessRecord("00000000-0000-4000-8000-000000000011", orgA),
|
||||
accessRecord("00000000-0000-4000-8000-000000000012", orgB),
|
||||
accessRecord("00000000-0000-4000-8000-000000000013", null),
|
||||
]}
|
||||
accessLoading={false}
|
||||
accessError={null}
|
||||
accessHasMore
|
||||
accessFetching={false}
|
||||
onLoadAccess={vi.fn()}
|
||||
hiddenOrganizations={[]}
|
||||
hiddenLoading={false}
|
||||
hiddenError={null}
|
||||
hiddenHasMore={false}
|
||||
hiddenFetching={false}
|
||||
onLoadHidden={vi.fn()}
|
||||
pendingAction={null}
|
||||
actionError={null}
|
||||
actionMessage={null}
|
||||
onHide={vi.fn()}
|
||||
onUnhide={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Компания А");
|
||||
expect(markup).toContain("Компания Б");
|
||||
expect(markup).toContain("Скрыть профиль");
|
||||
expect(markup).toContain("Загрузить ранние записи");
|
||||
expect(markup).toContain("Снятие скрытия само по себе не восстанавливает C4");
|
||||
});
|
||||
|
||||
it("does not describe a partial history page as the complete history", () => {
|
||||
const event: PrivacyEventList["items"][number] = {
|
||||
id: "00000000-0000-4000-8000-000000000021",
|
||||
kind: "publication_opened",
|
||||
occurred_at: "2026-10-04T10:00:00Z",
|
||||
fields: ["categories"],
|
||||
consent_id: "00000000-0000-4000-8000-000000000031",
|
||||
organization: null,
|
||||
};
|
||||
const privacyMarkup = renderToStaticMarkup(
|
||||
<PrivacyHistory
|
||||
events={[event]}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
hasMore
|
||||
isFetching={false}
|
||||
onLoad={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
const accessMarkup = renderToStaticMarkup(
|
||||
<CardAccessHistory
|
||||
records={[accessRecord("00000000-0000-4000-8000-000000000041", orgA)]}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
hasMore
|
||||
isFetching={false}
|
||||
onLoad={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(privacyMarkup).toContain("Показана только загруженная часть истории");
|
||||
expect(privacyMarkup).not.toContain("Показана вся история");
|
||||
expect(accessMarkup).toContain("Показана только загруженная часть истории");
|
||||
expect(accessMarkup).not.toContain("Показана вся история");
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user