feat: add candidate profile, questionnaire and company forms

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 16:07:02 +03:00
1 parent 3a61a8e8bb
commit f81cd0ae09
68 files changed
+9517 -54

No files matched your search

@@ -0,0 +1,115 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import type { CandidateQuestionnaire, SpecializationCatalog } from "../../../shared/api/schemas";
import {
changeQuestionnaireSpecialization,
patchQuestionnaireSpecialization,
toQuestionnaireDraft,
} from "../model/questionnaire-form";
import { QuestionnaireForm } from "./questionnaire-form";
const catalog: SpecializationCatalog = {
directions: [
{
code: "development",
title: "Разработка",
specializations: [
{
code: "backend",
title: "Backend",
test_availability: {
status: "available",
grades: ["junior"],
task_languages: ["python", "go"],
note: null,
},
},
],
},
{
code: "data",
title: "Данные",
specializations: [
{
code: "ds_ml",
title: "DS/ML",
test_availability: {
status: "in_development",
grades: [],
task_languages: [],
note: "Банк заданий готовится.",
},
},
],
},
],
grades: [
{ code: "intern", title: "Стажер" },
{ code: "junior", title: "Junior" },
{ code: "middle", title: "Middle" },
{ code: "senior", title: "Senior" },
],
};
const emptyQuestionnaire: CandidateQuestionnaire = {
version: 0,
specializations: [],
work_context: null,
updated_at: null,
};
function renderQuestionnaireForm(specialization: "backend" | "ds_ml"): string {
const base = toQuestionnaireDraft(emptyQuestionnaire);
const first = base.specializations[0];
if (!first) throw new Error("Expected the questionnaire to have one editing row.");
const selected = changeQuestionnaireSpecialization(base, first.id, specialization);
const draft = patchQuestionnaireSpecialization(selected, first.id, {
selfAssessedGrade: specialization === "backend" ? "junior" : "senior",
taskLanguages: specialization === "backend" ? ["go"] : [],
});
return renderToStaticMarkup(
<QuestionnaireForm
draft={draft}
catalog={catalog}
issues={[]}
isSaving={false}
isForbidden={false}
isConflict={false}
canRetry={false}
onDraftChange={() => undefined}
onIssue={() => undefined}
onSubmit={() => undefined}
/>,
);
}
describe("questionnaire form", () => {
it("renders current Backend task language and grade options with associated hints", () => {
const markup = renderQuestionnaireForm("backend");
const ids = new Set([...markup.matchAll(/\sid="([^"]+)"/g)].map((match) => match[1]));
const descriptions = [...markup.matchAll(/aria-describedby="([^"]+)"/g)].flatMap((match) =>
(match[1] ?? "").split(/\s+/),
);
expect(markup).toContain("Проверка опубликована для уровней: Junior.");
expect(markup).toContain("Python");
expect(markup).toContain("Go");
expect(markup).toContain("При смене выбора самооценка");
expect(descriptions.length).toBeGreaterThan(0);
expect(descriptions.every((id) => ids.has(id))).toBe(true);
expect(markup).not.toMatch(/ФСП|confirmed_grade|подтвержденный грейд/i);
});
it("allows an in-development specialization as a self-assessed claim without an assessment action", () => {
const markup = renderQuestionnaireForm("ds_ml");
expect(markup).toContain("Проверка: в разработке");
expect(markup).toContain(
"Эту специализацию можно сохранить. Начать проверку по ней пока нельзя.",
);
expect(markup).toContain("Банк заданий готовится.");
expect(markup).toContain('value="senior" selected=""');
expect(markup).not.toMatch(/<button\b[^>]*>[^<]*(?:Перейти|Начать) проверку/);
});
});