feat(consent): add privacy settings and scoped revocation flow
This commit is contained in:
1 parent
b2322bc178
commit
3ab6bd91a3
19 files changed
+1868
-8
No files matched your search
@@ -2,6 +2,7 @@ import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { StaticRouterProvider, createStaticHandler, createStaticRouter } from "react-router-dom";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getListMyConsentsQueryKey } from "../../shared/api/endpoints/consent/consent";
|
||||
import { getGetCurrentSessionQueryKey } from "../../shared/api/endpoints/identity/identity";
|
||||
import { createQueryClient } from "../providers/query-client";
|
||||
import { routes } from "./routes";
|
||||
@@ -40,6 +41,50 @@ async function render(path: string): Promise<string | Response> {
|
||||
csrf_token: "A".repeat(43),
|
||||
});
|
||||
}
|
||||
if (path.startsWith("/candidate/privacy")) {
|
||||
const hasMore = path.includes("history=partial");
|
||||
queryClient.setQueryData(getListMyConsentsQueryKey({ limit: 100 }), {
|
||||
pages: [
|
||||
{
|
||||
items: [
|
||||
{
|
||||
id: "01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a80",
|
||||
purpose: "c2",
|
||||
state: "active",
|
||||
text_version: "c2-2026-10-01",
|
||||
source: "consent_settings",
|
||||
granted_at: "2026-10-02T09:00:00Z",
|
||||
revoked_at: null,
|
||||
revocation_source: null,
|
||||
organization: null,
|
||||
fields: null,
|
||||
invitation_id: null,
|
||||
invitation_terms_version: null,
|
||||
},
|
||||
{
|
||||
id: "01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a81",
|
||||
purpose: "c4",
|
||||
state: "active",
|
||||
text_version: "c4-2026-10-01",
|
||||
source: "invitation_acceptance",
|
||||
granted_at: "2026-10-03T09:00:00Z",
|
||||
revoked_at: null,
|
||||
revocation_source: null,
|
||||
organization: {
|
||||
id: "01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01",
|
||||
name: "Первая тестовая компания",
|
||||
},
|
||||
fields: ["email"],
|
||||
invitation_id: "01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60",
|
||||
invitation_terms_version: 1,
|
||||
},
|
||||
],
|
||||
page: { has_more: hasMore, next_cursor: hasMore ? "next-page" : null },
|
||||
},
|
||||
],
|
||||
pageParams: [undefined],
|
||||
});
|
||||
}
|
||||
return renderToString(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<StaticRouterProvider router={router} context={context} hydrate={false} />
|
||||
@@ -75,6 +120,7 @@ describe("route groups", () => {
|
||||
["/candidate", "Главная", "Разделы кабинета кандидата"],
|
||||
["/candidate/profile", "Профиль", "Разделы кабинета кандидата"],
|
||||
["/candidate/onboarding", "Первые шаги", "Разделы кабинета кандидата"],
|
||||
["/candidate/privacy", "Согласия и настройки приватности", "Разделы кабинета кандидата"],
|
||||
["/employer/company", "Компания и команда", "Разделы кабинета работодателя"],
|
||||
["/employer/candidates", "Кандидаты", "Разделы кабинета работодателя"],
|
||||
])("renders %s in its shell with one h1 and landmarks", async (path, heading, navLabel) => {
|
||||
@@ -101,6 +147,7 @@ describe("route groups", () => {
|
||||
it("marks the active cabinet section with aria-current", async () => {
|
||||
expect(currentLinkText(await renderHtml("/candidate"))).toEqual(["Главная"]);
|
||||
expect(currentLinkText(await renderHtml("/candidate/results"))).toEqual(["Результаты"]);
|
||||
expect(currentLinkText(await renderHtml("/candidate/privacy"))).toEqual(["Приватность"]);
|
||||
expect(currentLinkText(await renderHtml("/employer/invitations"))).toEqual(["Приглашения"]);
|
||||
});
|
||||
|
||||
@@ -151,8 +198,34 @@ describe("product readiness", () => {
|
||||
expect(html).toContain("Это не показатель готовности продукта");
|
||||
});
|
||||
|
||||
it("labels every cabinet screen as a placeholder", async () => {
|
||||
for (const path of ["/candidate", "/candidate/privacy", "/employer/needs"]) {
|
||||
it("renders the consent settings route with server-backed history", async () => {
|
||||
const html = await renderHtml("/candidate/privacy");
|
||||
|
||||
expect(html).toContain("Публикация карточки кандидата");
|
||||
expect(html).toContain("c2-2026-10-01");
|
||||
expect(html).toContain("Первая тестовая компания");
|
||||
expect(html).toContain("Электронная почта");
|
||||
});
|
||||
|
||||
it("does not call a purpose empty while older history pages remain", async () => {
|
||||
const html = await renderHtml("/candidate/privacy?history=partial");
|
||||
|
||||
expect(html).toContain("В загруженной части истории записей C3 пока нет");
|
||||
expect(html).toContain("Показать более ранние записи");
|
||||
expect(html).not.toContain("Записей C3 пока нет.");
|
||||
});
|
||||
|
||||
it("links the saved candidate consent step to the same settings screen", async () => {
|
||||
const html = await renderHtml("/candidate/onboarding");
|
||||
|
||||
expect(html).toContain("Состояние шага хранится на сервере");
|
||||
expect(html).toMatch(
|
||||
/<a[^>]*href="\/candidate\/privacy"[^>]*>Открыть согласия и настройки приватности<\/a>/,
|
||||
);
|
||||
});
|
||||
|
||||
it("labels the remaining cabinet scaffolds as placeholders", async () => {
|
||||
for (const path of ["/candidate", "/employer/needs"]) {
|
||||
expect(await renderHtml(path)).toContain("Экран будет реализован в одной из следующих задач");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { redirect, type RouteObject } from "react-router-dom";
|
||||
import { LoginPage, RegisterPage, VerifyEmailPage } from "../../pages/auth";
|
||||
import { CandidateOnboardingPage } from "../../pages/candidate-onboarding";
|
||||
import { ConsentsPage } from "../../pages/consents";
|
||||
import { SessionGate } from "../../entities/session";
|
||||
import { NotFoundPage } from "../../pages/not-found";
|
||||
import { PlaceholderPage } from "../../pages/placeholder";
|
||||
@@ -62,7 +63,7 @@ export const routes: RouteObject[] = [
|
||||
},
|
||||
{
|
||||
path: paths.candidate.privacy,
|
||||
element: <PlaceholderPage screen="candidatePrivacy" />,
|
||||
element: <ConsentsPage />,
|
||||
},
|
||||
{
|
||||
path: "*",
|
||||
|
||||
Reference in new issue
Block a user