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,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("Показана вся история");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user