feat: add assessment, privacy and support flows
This commit is contained in:
1 parent
ee3738ee73
commit
e4f24fa202
339 files changed
+56454
-1126
No files matched your search
@@ -2,8 +2,10 @@ 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 { assessmentQueryKeys } from "../../entities/assessment";
|
||||
import { getListMyConsentsQueryKey } from "../../shared/api/endpoints/consent/consent";
|
||||
import { getGetCurrentSessionQueryKey } from "../../shared/api/endpoints/identity/identity";
|
||||
import type { Session } from "../../shared/api/schemas";
|
||||
import { createQueryClient } from "../providers/query-client";
|
||||
import { routes } from "./routes";
|
||||
|
||||
@@ -20,7 +22,7 @@ async function render(path: string): Promise<string | Response> {
|
||||
const queryClient = createQueryClient();
|
||||
const scenario = path.startsWith("/employer") ? "employer" : "candidate";
|
||||
if (path.startsWith("/candidate") || path.startsWith("/employer")) {
|
||||
queryClient.setQueryData(getGetCurrentSessionQueryKey(), {
|
||||
const session = {
|
||||
account: {
|
||||
id: "11111111-1111-4111-8111-111111111111",
|
||||
email: "person@example.test",
|
||||
@@ -39,7 +41,17 @@ async function render(path: string): Promise<string | Response> {
|
||||
created_at: "2026-10-07T12:00:00Z",
|
||||
},
|
||||
csrf_token: "A".repeat(43),
|
||||
});
|
||||
} satisfies Session;
|
||||
queryClient.setQueryData(getGetCurrentSessionQueryKey(), session);
|
||||
if (path === "/candidate/assessment") {
|
||||
queryClient.setQueryData(assessmentQueryKeys.availability(session), { specializations: [] });
|
||||
queryClient.setQueryData(assessmentQueryKeys.questionnaire(session), {
|
||||
version: 0,
|
||||
specializations: [],
|
||||
work_context: null,
|
||||
updated_at: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (path.startsWith("/candidate/privacy")) {
|
||||
const hasMore = path.includes("history=partial");
|
||||
@@ -122,7 +134,23 @@ describe("route groups", () => {
|
||||
["/candidate/questionnaire", "Анкета", "Разделы кабинета кандидата"],
|
||||
["/candidate/onboarding", "Первые шаги", "Разделы кабинета кандидата"],
|
||||
["/candidate/privacy", "Согласия и настройки приватности", "Разделы кабинета кандидата"],
|
||||
["/candidate/assessment", "Проверка знаний", "Разделы кабинета кандидата"],
|
||||
[
|
||||
"/candidate/assessment/01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a80",
|
||||
"Попытка проверки",
|
||||
"Разделы кабинета кандидата",
|
||||
],
|
||||
["/employer/company", "Компания", "Разделы кабинета работодателя"],
|
||||
["/employer/needs", "Потребности", "Разделы кабинета работодателя"],
|
||||
["/candidate/support/cases", "Мои обращения", "Разделы кабинета кандидата"],
|
||||
["/candidate/support/cases/new", "Обратиться в поддержку", "Разделы кабинета кандидата"],
|
||||
[
|
||||
"/candidate/support/cases/manual-assessment",
|
||||
"Запросить ручную оценку",
|
||||
"Разделы кабинета кандидата",
|
||||
],
|
||||
["/employer/support/cases", "Мои обращения", "Разделы кабинета работодателя"],
|
||||
["/employer/support/cases/new", "Обратиться в поддержку", "Разделы кабинета работодателя"],
|
||||
["/employer/candidates", "Кандидаты", "Разделы кабинета работодателя"],
|
||||
])("renders %s in its shell with one h1 and landmarks", async (path, heading, navLabel) => {
|
||||
const html = await renderHtml(path);
|
||||
@@ -183,6 +211,14 @@ describe("route groups", () => {
|
||||
});
|
||||
|
||||
describe("product readiness", () => {
|
||||
it("keeps the training run available when no full-assessment category exists", async () => {
|
||||
const html = await renderHtml("/candidate/assessment");
|
||||
|
||||
expect(html).toContain("Сначала выберите специализацию");
|
||||
expect(html).toContain("Начать демонстрацию");
|
||||
expect(html).not.toContain("Начать полную проверку");
|
||||
});
|
||||
|
||||
it("presents the root page as a scaffold, not as a working product", async () => {
|
||||
const html = await renderHtml("/");
|
||||
|
||||
@@ -226,7 +262,7 @@ describe("product readiness", () => {
|
||||
});
|
||||
|
||||
it("labels the remaining cabinet scaffolds as placeholders", async () => {
|
||||
for (const path of ["/candidate", "/employer/needs"]) {
|
||||
for (const path of ["/candidate", "/employer/candidates"]) {
|
||||
expect(await renderHtml(path)).toContain("Экран будет реализован в одной из следующих задач");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
import { redirect, type RouteObject } from "react-router-dom";
|
||||
import { AssessmentAttemptPage, AssessmentPage } from "../../pages/assessment";
|
||||
import { LoginPage, RegisterPage, VerifyEmailPage } from "../../pages/auth";
|
||||
import { CandidateOnboardingPage } from "../../pages/candidate-onboarding";
|
||||
import { CompanyPage } from "../../pages/company";
|
||||
import { ConsentsPage } from "../../pages/consents";
|
||||
import { SessionGate } from "../../entities/session";
|
||||
import { NotFoundPage } from "../../pages/not-found";
|
||||
import { NeedEditorPage } from "../../pages/need-editor";
|
||||
import { NeedListPage } from "../../pages/needs";
|
||||
import { PlaceholderPage } from "../../pages/placeholder";
|
||||
import { ProfilePage } from "../../pages/profile";
|
||||
import { QuestionnairePage } from "../../pages/questionnaire";
|
||||
import { StatusPage } from "../../pages/status";
|
||||
import {
|
||||
CreateSupportCasePage,
|
||||
ManualAssessmentPage,
|
||||
SupportCaseDetailPage,
|
||||
SupportCasesPage,
|
||||
} from "../../pages/support-cases";
|
||||
import { WelcomePage } from "../../pages/welcome";
|
||||
import { paths } from "../../shared/config";
|
||||
import { CandidateShell } from "../../widgets/candidate-shell";
|
||||
@@ -17,6 +26,7 @@ import { PublicShell } from "../../widgets/public-shell";
|
||||
import { RootLayout } from "../ui/root-layout";
|
||||
import { RouteErrorPage } from "../ui/route-error-page";
|
||||
import { CandidateHomeRoute } from "./candidate-home-route";
|
||||
import { SupportRoute } from "./support-route";
|
||||
|
||||
/**
|
||||
* Route tree with public pages and role-specific cabinets. Protected shells
|
||||
@@ -34,7 +44,7 @@ export const routes: RouteObject[] = [
|
||||
{ path: paths.login, element: <LoginPage /> },
|
||||
{ path: paths.register, element: <RegisterPage /> },
|
||||
{ path: paths.verifyEmail, element: <VerifyEmailPage /> },
|
||||
{ path: paths.support, element: <PlaceholderPage screen="support" /> },
|
||||
{ path: paths.support, element: <SupportRoute /> },
|
||||
{ path: paths.status, element: <StatusPage /> },
|
||||
{ path: "*", element: <NotFoundPage /> },
|
||||
],
|
||||
@@ -58,7 +68,11 @@ export const routes: RouteObject[] = [
|
||||
},
|
||||
{
|
||||
path: paths.candidate.assessment,
|
||||
element: <PlaceholderPage screen="candidateAssessment" />,
|
||||
element: <AssessmentPage />,
|
||||
},
|
||||
{
|
||||
path: `${paths.candidate.assessment}/:attemptId`,
|
||||
element: <AssessmentAttemptPage />,
|
||||
},
|
||||
{
|
||||
path: paths.candidate.results,
|
||||
@@ -72,6 +86,13 @@ export const routes: RouteObject[] = [
|
||||
path: paths.candidate.privacy,
|
||||
element: <ConsentsPage />,
|
||||
},
|
||||
{ path: paths.candidate.supportCases, element: <SupportCasesPage /> },
|
||||
{ path: paths.candidate.supportNew, element: <CreateSupportCasePage /> },
|
||||
{ path: paths.candidate.supportManual, element: <ManualAssessmentPage /> },
|
||||
{
|
||||
path: `${paths.candidate.supportCases}/:caseId`,
|
||||
element: <SupportCaseDetailPage />,
|
||||
},
|
||||
{
|
||||
path: "*",
|
||||
element: (
|
||||
@@ -94,7 +115,15 @@ export const routes: RouteObject[] = [
|
||||
path: paths.employer.company,
|
||||
element: <CompanyPage />,
|
||||
},
|
||||
{ path: paths.employer.needs, element: <PlaceholderPage screen="employerNeeds" /> },
|
||||
{ path: paths.employer.needs, element: <NeedListPage /> },
|
||||
{ path: `${paths.employer.needs}/new`, element: <NeedEditorPage /> },
|
||||
{ path: `${paths.employer.needs}/:needId`, element: <NeedEditorPage /> },
|
||||
{ path: paths.employer.supportCases, element: <SupportCasesPage /> },
|
||||
{ path: paths.employer.supportNew, element: <CreateSupportCasePage /> },
|
||||
{
|
||||
path: `${paths.employer.supportCases}/:caseId`,
|
||||
element: <SupportCaseDetailPage />,
|
||||
},
|
||||
{
|
||||
path: paths.employer.candidates,
|
||||
element: <PlaceholderPage screen="employerCandidates" />,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Navigate, useLocation } from "react-router-dom";
|
||||
import { parseSupportCaseContext } from "../../entities/support-case";
|
||||
import { ApiRequestError } from "../../shared/api";
|
||||
import { useGetCurrentSession } from "../../shared/api/endpoints/identity/identity";
|
||||
import { paths } from "../../shared/config";
|
||||
import { ButtonLink, ErrorState, LoadingState, Page, Section } from "../../shared/ui";
|
||||
|
||||
/** Support remains reachable before completing either onboarding flow. */
|
||||
export function SupportRoute() {
|
||||
const session = useGetCurrentSession();
|
||||
const location = useLocation();
|
||||
if (session.isPending) {
|
||||
return (
|
||||
<Page title="Поддержка">
|
||||
<LoadingState label="Проверяем вход..." />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
if (session.isError) {
|
||||
if (session.error instanceof ApiRequestError && session.error.status === 401) {
|
||||
return (
|
||||
<Page title="Поддержка" lead="Войдите, чтобы отправить обращение и следить за ответом.">
|
||||
<Section title="Ваши обращения">
|
||||
<ButtonLink to={paths.login} state={{ returnTo: "support" }}>
|
||||
Войти и открыть поддержку
|
||||
</ButtonLink>
|
||||
</Section>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Page title="Поддержка">
|
||||
<ErrorState
|
||||
title="Не удалось открыть поддержку"
|
||||
error={session.error}
|
||||
isRetrying={session.isRefetching}
|
||||
onRetry={() => void session.refetch()}
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
const state: unknown = location.state;
|
||||
const context =
|
||||
state && typeof state === "object" && !Array.isArray(state)
|
||||
? parseSupportCaseContext((state as Record<string, unknown>).supportContext)
|
||||
: null;
|
||||
const cabinet = session.data.account.scenario === "candidate" ? paths.candidate : paths.employer;
|
||||
return (
|
||||
<Navigate
|
||||
to={context ? cabinet.supportNew : cabinet.supportCases}
|
||||
state={context ? { supportContext: context } : undefined}
|
||||
replace
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user