feat(candidate): add the candidate home, results and result history screens

This commit is contained in:
shira committed 2026-10-09 01:24:45 +03:00
1 parent 8277133712
commit 4761508f13
52 files changed
+5334 -81

No files matched your search

@@ -0,0 +1,44 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { renderToString } from "react-dom/server";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, it } from "vitest";
import { getGetCurrentSessionQueryKey } from "../../shared/api/endpoints/identity/identity";
import type { Session } from "../../shared/api/schemas";
import { CandidateHomeRoute } from "./candidate-home-route";
function render(step: Session["account"]["onboarding_step"]): string {
const queryClient = new QueryClient();
queryClient.setQueryData(getGetCurrentSessionQueryKey(), {
account: {
id: "11111111-1111-4111-8111-111111111111",
email: "person@example.test",
email_verified: true,
scenario: "candidate",
onboarding_step: step,
created_at: "2026-10-07T12:00:00Z",
},
csrf_token: "A".repeat(43),
} satisfies Session);
return renderToString(
<QueryClientProvider client={queryClient}>
<MemoryRouter>
<CandidateHomeRoute />
</MemoryRouter>
</QueryClientProvider>,
);
}
describe("CandidateHomeRoute", () => {
it.each([
"candidate_consents",
"candidate_profile",
"candidate_questionnaire",
"candidate_assessment",
"completed",
] as const)("shows the home at the saved step %s instead of redirecting", (step) => {
const html = render(step);
expect(html).toMatch(/<h1[^>]*>Главная<\/h1>/);
expect(html).toContain("Определяем следующий шаг...");
});
});
@@ -1,13 +1,9 @@
import { Navigate } from "react-router-dom";
import { getOnboardingDestination } from "../../entities/session";
import { PlaceholderPage } from "../../pages/placeholder";
import { useGetCurrentSession } from "../../shared/api/endpoints/identity/identity";
import { CandidateHomePage } from "../../pages/candidate-home";
/**
* The candidate home opens at every saved onboarding step: it shows the saved
* step and leads to the next action itself instead of redirecting away.
*/
export function CandidateHomeRoute() {
const session = useGetCurrentSession();
if (!session.data) return <PlaceholderPage screen="candidateHome" />;
if (session.data.account.onboarding_step !== "completed") {
return <Navigate to={getOnboardingDestination(session.data.account)} replace />;
}
return <PlaceholderPage screen="candidateHome" />;
return <CandidateHomePage />;
}
+1 -1
View File
@@ -283,7 +283,7 @@ describe("product readiness", () => {
});
it("labels the remaining cabinet scaffolds as placeholders", async () => {
for (const path of ["/candidate", "/employer/candidates"]) {
for (const path of ["/candidate/invitations", "/employer/candidates"]) {
expect(await renderHtml(path)).toContain("Экран будет реализован в одной из следующих задач");
}
});
+3 -4
View File
@@ -1,5 +1,6 @@
import { redirect, type RouteObject } from "react-router-dom";
import { AssessmentAttemptPage, AssessmentPage } from "../../pages/assessment";
import { AssessmentResultPage, AssessmentResultsPage } from "../../pages/assessment-result";
import { LoginPage, RegisterPage, VerifyEmailPage } from "../../pages/auth";
import { CandidateOnboardingPage } from "../../pages/candidate-onboarding";
import { CompanyPage } from "../../pages/company";
@@ -74,10 +75,8 @@ export const routes: RouteObject[] = [
path: `${paths.candidate.assessment}/:attemptId`,
element: <AssessmentAttemptPage />,
},
{
path: paths.candidate.results,
element: <PlaceholderPage screen="candidateResults" />,
},
{ path: paths.candidate.results, element: <AssessmentResultsPage /> },
{ path: `${paths.candidate.results}/:attemptId`, element: <AssessmentResultPage /> },
{
path: paths.candidate.invitations,
element: <PlaceholderPage screen="candidateInvitations" />,