feat(frontend): redesign the candidate cabinet with step-by-step profile and questionnaire forms

This commit is contained in:
shira committed 2026-10-10 09:50:27 +03:00
1 parent 15590d127c
commit c836d02ea3
77 files changed
+5409 -1618

No files matched your search

+32
View File
@@ -131,11 +131,18 @@ async function grantC3(page: Page): Promise<void> {
async function saveAssessmentQuestionnaire(page: Page): Promise<void> {
await page.goto("/candidate/questionnaire");
await expect(page.getByRole("heading", { name: "Ответы кандидата" })).toBeVisible();
// The questionnaire is a form in steps; "Далее" moves the focus to the next heading.
await page.getByLabel("Специализация", { exact: true }).selectOption("backend");
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Уровень и опыт$/ })).toBeFocused();
await page.getByLabel("Моя оценка уровня").selectOption("junior");
await page.getByRole("checkbox", { name: "Go", exact: true }).check();
await page.getByRole("checkbox", { name: "Python", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Формат работы$/ })).toBeFocused();
await page.getByRole("checkbox", { name: "Удаленно", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Проверка и сохранение$/ })).toBeFocused();
const response = page.waitForResponse(
(item) =>
item.request().method() === "PUT" &&
@@ -369,6 +376,31 @@ test("candidate can review, resume, and finish separate assessment modes", async
const firstExpressSnapshot = (await startExpressResponse.json()) as AttemptSnapshot;
expect(firstExpressSnapshot.current_item?.id).toBeTruthy();
// An unfinished express run is resumed: after a full reload of the
// assessment page, a new start answers 409, and the page replays the start
// with the key stored in this tab, which returns the stored 201 of the run.
await page.goto("/candidate/assessment");
await expect(page.getByRole("button", { name: "Начать демонстрацию" })).toBeVisible();
const expressStarts: { status: number; key: string | null }[] = [];
const recordExpressStart = (response: Response) => {
if (
response.request().method() === "POST" &&
new URL(response.url()).pathname === "/api/v1/me/assessment-attempts"
) {
expressStarts.push({
status: response.status(),
key: response.request().headers()["idempotency-key"] ?? null,
});
}
};
page.on("response", recordExpressStart);
await page.getByRole("button", { name: "Начать демонстрацию" }).click();
await expect(page).toHaveURL(new RegExp(`/candidate/assessment/${expressAttempt.id}$`));
await expect(page.getByText("Незавершенная демонстрация продолжена")).toBeVisible();
page.off("response", recordExpressStart);
expect(expressStarts.map((start) => start.status)).toEqual([409, 201]);
expect(expressStarts[0]?.key).not.toBe(expressStarts[1]?.key);
await navigateInApp(page, `/candidate/assessment/${realAttempt.id}`);
await expect(page.getByRole("heading", { name: "Результат с сервера" })).toBeVisible();
await expect(page.getByRole("button", { name: "Начать или продолжить" })).toHaveCount(0);
+13
View File
@@ -159,6 +159,13 @@ test.describe("candidate home with the real backend", () => {
await page.getByRole("link", { name: "Заполнить профиль", exact: true }).first().click();
await expect(page.getByRole("heading", { name: "Профиль", level: 1 })).toBeVisible();
await page.getByLabel("Имя и фамилия").fill("Тестовый кандидат");
// The profile is a form in steps: walk to the review step, then save.
for (const heading of ["Роли", "Опыт", "Навыки", "Условия", "Проверка"]) {
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(
page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) }),
).toBeFocused();
}
const profileSaved = page.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
@@ -173,9 +180,15 @@ test.describe("candidate home with the real backend", () => {
await page.getByRole("link", { name: "Заполнить анкету", exact: true }).first().click();
await expect(page.getByRole("heading", { name: "Ответы кандидата" })).toBeVisible();
await page.getByLabel("Специализация", { exact: true }).selectOption("backend");
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Уровень и опыт$/ })).toBeFocused();
await page.getByLabel("Моя оценка уровня").selectOption("middle");
await page.getByRole("checkbox", { name: "Python", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Формат работы$/ })).toBeFocused();
await page.getByRole("checkbox", { name: "Удаленно", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Проверка и сохранение$/ })).toBeFocused();
const questionnaireSaved = page.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
+7
View File
@@ -606,11 +606,18 @@ async function grantC3(page: Page): Promise<void> {
async function saveAssessmentQuestionnaire(page: Page): Promise<void> {
await page.goto("/candidate/questionnaire");
await expect(page.getByRole("heading", { name: "Ответы кандидата" })).toBeVisible();
// The questionnaire is a form in steps; "Далее" moves the focus to the next heading.
await page.getByLabel("Специализация", { exact: true }).selectOption("backend");
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Уровень и опыт$/ })).toBeFocused();
await page.getByLabel("Моя оценка уровня").selectOption("junior");
await page.getByRole("checkbox", { name: "Go", exact: true }).check();
await page.getByRole("checkbox", { name: "Python", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Формат работы$/ })).toBeFocused();
await page.getByRole("checkbox", { name: "Удаленно", exact: true }).check();
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Проверка и сохранение$/ })).toBeFocused();
const response = page.waitForResponse(
(item) =>
item.request().method() === "PUT" &&
+9
View File
@@ -394,12 +394,21 @@ test.describe("candidate without a confirmed grade with the real backend", () =>
// Two declared specializations in the profile, none confirmed by a test.
await page.goto("/candidate/profile");
await page.getByLabel("Имя и фамилия").fill("Тестовый кандидат");
// The profile is a form in steps: roles are the second step.
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Роли$/ })).toBeFocused();
await page.getByRole("button", { name: "Добавить специализацию" }).click();
await page.getByRole("button", { name: "Добавить специализацию" }).click();
await page.getByLabel("Специализация").nth(0).selectOption("backend");
await page.getByLabel("Специализация").nth(1).selectOption("network_engineer");
await page.getByLabel("Моя оценка уровня").nth(0).selectOption("middle");
await page.getByLabel("Моя оценка уровня").nth(1).selectOption("junior");
for (const heading of ["Опыт", "Навыки", "Условия", "Проверка"]) {
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(
page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) }),
).toBeFocused();
}
const profileSaved = page.waitForResponse(apiResponse("PUT", "/api/v1/me/profile"));
await page.getByRole("button", { name: "Сохранить профиль" }).click();
expect((await profileSaved).status()).toBe(200);
+56 -5
View File
@@ -109,7 +109,36 @@ test.describe("candidate profile", () => {
}
}
// The profile is a form in steps. "Далее" checks the visible step and moves
// the focus to the heading of the next one; the save is on the last step.
async function nextStep(page: Page, heading: string): Promise<void> {
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) })).toBeFocused();
}
async function editStep(page: Page, step: string, heading: string): Promise<void> {
await page.getByRole("button", { name: `Изменить: ${step}` }).click();
await expect(page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) })).toBeFocused();
}
async function openReview(page: Page): Promise<void> {
const save = page.getByRole("button", { name: /Сохранить профиль|Сохраняем профиль/ });
const jump = page.getByRole("button", { name: "К проверке и сохранению" });
if (await save.isVisible()) return;
if (await jump.isVisible()) {
await jump.click();
await expect(page.getByRole("heading", { name: /\. Проверка$/ })).toBeFocused();
return;
}
for (const heading of ["Роли", "Опыт", "Навыки", "Условия", "Проверка"]) {
if (await save.isVisible()) break;
await nextStep(page, heading);
}
await expect(save).toBeVisible();
}
async function saveProfile(page: Page, expectedStatus = 200): Promise<void> {
await openReview(page);
const responsePromise = page.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
@@ -182,29 +211,47 @@ test.describe("candidate profile", () => {
await page.getByLabel("Телефон").fill("+79990000000");
await page.getByLabel("Telegram").fill("@candidate_123");
await expect(page.getByText("Шаг 1 из 6", { exact: true })).toBeVisible();
await nextStep(page, "Роли");
await page.getByRole("button", { name: "Добавить специализацию" }).click();
await page.getByLabel("Специализация").selectOption("backend");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await nextStep(page, "Опыт");
await page.getByRole("button", { name: "Добавить место работы" }).click();
await page.getByRole("button", { name: "Добавить место работы" }).click();
const experienceSpecialization = page.getByLabel("Специализация").filter({ visible: true });
await page.getByLabel("Компания").nth(0).fill("Первая компания");
await page.getByLabel("Компания").nth(1).fill("Вторая компания");
await page.getByLabel("Специализация").nth(0).selectOption("backend");
await page.getByLabel("Специализация").nth(1).selectOption("frontend");
await experienceSpecialization.nth(0).selectOption("backend");
await experienceSpecialization.nth(1).selectOption("frontend");
await page.getByLabel("Начало работы").nth(0).fill("2024-01");
await page.getByLabel("Окончание работы").nth(0).fill("2024-12");
await page.getByLabel("Начало работы").nth(1).fill("2024-06");
await page.getByLabel("Окончание работы").nth(1).fill("2025-01");
// The overlapping periods block the step until they are confirmed.
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(
page.getByRole("alert").filter({ hasText: "действительно шли параллельно" }),
).toBeFocused();
await page.getByRole("checkbox", { name: /Подтверждаю, что места работы 1 и 2/ }).check();
await page.getByRole("button", { name: "Добавить специализацию" }).click();
await page.getByLabel("Специализация").nth(2).selectOption("backend");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await nextStep(page, "Навыки");
await page.getByRole("button", { name: "Добавить навык" }).click();
await page.getByLabel("Навык 1", { exact: true }).fill("Go");
await page.getByRole("button", { name: "Добавить гибкий навык" }).click();
await page.getByLabel("Гибкий навык 1", { exact: true }).fill("Коммуникация");
await nextStep(page, "Условия");
await page.getByLabel("Желаемое место работы").fill("Москва");
await page.getByLabel("Готовность к переезду").selectOption("true");
await page.getByLabel("Минимальная зарплата, рублей в месяц").fill("150000");
await page.getByLabel("Сумма до или после налога").selectOption("gross");
await nextStep(page, "Проверка");
// Back keeps the entered data.
await page.getByRole("button", { name: "Назад", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Условия$/ })).toBeFocused();
await expect(page.getByLabel("Желаемое место работы")).toHaveValue("Москва");
await nextStep(page, "Проверка");
const pausedSave = await pauseProfileSave(page);
try {
@@ -226,6 +273,7 @@ test.describe("candidate profile", () => {
).toBeVisible();
await expect(page.getByText("Сохраненный шаг аккаунта: Согласия.")).toBeVisible();
await expect(page.getByLabel("Имя и фамилия")).toHaveValue(name);
await editStep(page, "опыт", "Опыт");
await expect(
page.getByText(/Параллельная работа в местах 1 и 2 подтверждена ранее/),
).toBeVisible();
@@ -287,9 +335,11 @@ test.describe("candidate profile", () => {
await page.getByRole("button", { name: "Заменить черновик актуальной версией" }).click();
await latestRead;
await expect(page.getByLabel("Имя и фамилия")).toHaveValue(secondVersionName);
await editStep(page, "контакты", "Контакты");
await page.getByLabel("Имя и фамилия").fill(staleName);
await saveProfile(page);
await expect(page.getByLabel("Имя и фамилия")).toHaveValue(staleName);
await editStep(page, "контакты", "Контакты");
await expectResponsiveKeyboardFlow(page);
await page.reload();
@@ -303,6 +353,7 @@ test.describe("candidate profile", () => {
const firstAccount = await registerCandidate(page);
const firstProfileName = `Первый профиль ${crypto.randomUUID().slice(0, 8)}`;
await page.getByLabel("Имя и фамилия").fill(firstProfileName);
await openReview(page);
const pausedSave = await pauseProfileSave(page);
try {
+63 -11
View File
@@ -170,6 +170,30 @@ async function saveFromKeyboard(page: Page, expectedStatus: number): Promise<voi
expect((await responsePromise).status()).toBe(expectedStatus);
}
// The questionnaire is a form in steps. "Далее" checks the visible step and
// moves the focus to the heading of the next one.
async function nextStep(page: Page, heading: string): Promise<void> {
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) })).toBeFocused();
}
async function editStep(page: Page, step: string, heading: string): Promise<void> {
await page.getByRole("button", { name: `Изменить: ${step}` }).click();
await expect(page.getByRole("heading", { name: new RegExp(`\\. ${heading}$`) })).toBeFocused();
}
async function fillAnswers(
page: Page,
answers: { specialization: string; grade: string; formats: string[] },
): Promise<void> {
await page.getByLabel("Специализация", { exact: true }).selectOption(answers.specialization);
await nextStep(page, "Уровень и опыт");
await page.getByLabel("Моя оценка уровня").selectOption(answers.grade);
await nextStep(page, "Формат работы");
for (const format of answers.formats) await page.getByLabel(format).check();
await nextStep(page, "Проверка и сохранение");
}
async function createSecondSession(browser: Browser, email: string): Promise<Page> {
const context = await browser.newContext({ baseURL: baseUrl(), locale: "ru-RU" });
const page = await context.newPage();
@@ -228,25 +252,44 @@ test.describe("candidate questionnaire", () => {
expect(initial.version).toBe(0);
const specialization = page.getByLabel("Специализация", { exact: true });
await expect(page.getByText("Шаг 1 из 4", { exact: true })).toBeVisible();
await specialization.selectOption("ds_ml");
await expect(page.getByText("Проверка: в разработке")).toBeVisible();
await expect(
page.getByText("Эту специализацию можно сохранить. Начать проверку по ней пока нельзя."),
).toBeVisible();
await expect(page.getByRole("button", { name: /проверку/i })).toHaveCount(0);
// A step with a missing answer does not let the form move on.
await nextStep(page, "Уровень и опыт");
await page.getByRole("button", { name: "Далее", exact: true }).click();
await expect(
page.getByRole("alert").filter({ hasText: "Укажите свою оценку уровня." }),
).toBeFocused();
await expect(page.getByLabel("Моя оценка уровня")).toHaveAttribute("aria-invalid", "true");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await nextStep(page, "Формат работы");
await page.getByLabel("Удаленно").check();
await nextStep(page, "Проверка и сохранение");
// Going back keeps what was entered.
await page.getByRole("button", { name: "Назад", exact: true }).click();
await expect(page.getByRole("heading", { name: /\. Формат работы$/ })).toBeFocused();
await expect(page.getByLabel("Удаленно")).toBeChecked();
await nextStep(page, "Проверка и сохранение");
await saveFromKeyboard(page, 200);
await expect(
page.getByText(/Анкета сохранена\. Сервер подтвердил шаг аккаунта:/),
).toBeVisible();
await expect(page.getByText(/Шаг аккаунта на сервере: Согласия\./)).toBeVisible();
await editStep(page, "направления", "Направления");
await specialization.selectOption("backend");
await nextStep(page, "Уровень и опыт");
await page.getByLabel("Моя оценка уровня").selectOption("junior");
await page.getByRole("checkbox", { name: "Go", exact: true }).check();
await page.getByLabel("Стек технологий").fill("Go");
await page.getByRole("button", { name: "Добавить технологию" }).click();
await nextStep(page, "Формат работы");
await nextStep(page, "Проверка и сохранение");
const backendSave = page.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
@@ -267,9 +310,13 @@ test.describe("candidate questionnaire", () => {
]);
await expect(page.getByText(/Анкета сохранена/)).toBeVisible();
await page.reload();
// A reload restores the server record and opens the first step.
await expect(page.getByText("Шаг 1 из 4", { exact: true })).toBeVisible();
await expect(page.getByLabel("Специализация", { exact: true })).toHaveValue("backend");
await expect(page.getByLabel("Моя оценка уровня")).toHaveValue("junior");
await expect(page.getByRole("checkbox", { name: "Go", exact: true })).toBeChecked();
await expect(
page.getByRole("checkbox", { name: "Go", exact: true, includeHidden: true }),
).toBeChecked();
await expect(page.getByLabel("Стек технологий")).toHaveValue("");
await expect(page.getByText(/Шаг аккаунта на сервере: Согласия\./)).toBeVisible();
await page.screenshot({
@@ -280,7 +327,10 @@ test.describe("candidate questionnaire", () => {
const secondPage = await createSecondSession(browser, email);
try {
await secondPage.getByLabel("Специализация", { exact: true }).selectOption("ds_ml");
await nextStep(secondPage, "Уровень и опыт");
await secondPage.getByLabel("Моя оценка уровня").selectOption("senior");
await nextStep(secondPage, "Формат работы");
await nextStep(secondPage, "Проверка и сохранение");
const concurrentSave = secondPage.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
@@ -289,8 +339,11 @@ test.describe("candidate questionnaire", () => {
await secondPage.getByRole("button", { name: "Сохранить анкету" }).click();
expect((await concurrentSave).status()).toBe(200);
await nextStep(page, "Уровень и опыт");
await nextStep(page, "Формат работы");
await page.getByLabel("Удаленно").uncheck();
await page.getByLabel("В офисе").check();
await nextStep(page, "Проверка и сохранение");
const staleSave = page.waitForResponse(
(response) =>
response.request().method() === "PUT" &&
@@ -319,6 +372,7 @@ test.describe("candidate questionnaire", () => {
await expect(secondPage.getByLabel("В офисе")).toBeChecked();
await expect(secondPage.getByLabel("Удаленно")).not.toBeChecked();
await editStep(page, "направления", "Направления");
await checkResponsiveLayout(page);
} finally {
await secondPage.context().close();
@@ -361,9 +415,7 @@ test.describe("candidate questionnaire", () => {
);
await registerVerifiedCandidate(page);
await page.getByLabel("Специализация", { exact: true }).selectOption("ds_ml");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await page.getByLabel("Удаленно").check();
await fillAnswers(page, { specialization: "ds_ml", grade: "senior", formats: ["Удаленно"] });
await page.route("**/api/v1/me/questionnaire", async (route) => {
if (route.request().method() === "PUT") {
await fulfillProblem(route, 403, "forbidden");
@@ -393,9 +445,7 @@ test.describe("candidate questionnaire", () => {
);
await registerVerifiedCandidate(page);
await page.getByLabel("Специализация", { exact: true }).selectOption("ds_ml");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await page.getByLabel("Удаленно").check();
await fillAnswers(page, { specialization: "ds_ml", grade: "senior", formats: ["Удаленно"] });
let rejectSessionRefresh = false;
await page.route("**/api/v1/identity/sessions/current", async (route) => {
if (rejectSessionRefresh) {
@@ -455,9 +505,7 @@ test.describe("candidate questionnaire", () => {
}
await registerVerifiedCandidate(page);
await page.getByLabel("Специализация", { exact: true }).selectOption("ds_ml");
await page.getByLabel("Моя оценка уровня").selectOption("senior");
await page.getByLabel("Удаленно").check();
await fillAnswers(page, { specialization: "ds_ml", grade: "senior", formats: ["Удаленно"] });
let releaseOldResponse: () => void = () => undefined;
let markOldRequestHeld: () => void = () => undefined;
@@ -517,7 +565,11 @@ test.describe("candidate questionnaire", () => {
expect((await oldSaveResponse).status()).toBe(200);
await expect(page.getByLabel("Специализация", { exact: true })).toHaveValue("");
await expect(page.getByLabel("Моя оценка уровня")).toHaveValue("");
await expect(page.getByRole("button", { name: "Сохранить анкету" })).toBeEnabled();
// The new account's editor opens at its first step and is not saving:
// the fields and the step action are enabled.
await expect(page.getByText("Шаг 1 из 4", { exact: true })).toBeVisible();
await expect(page.getByLabel("Специализация", { exact: true })).toBeEnabled();
await expect(page.getByRole("button", { name: "Далее", exact: true })).toBeEnabled();
await expect(page.getByRole("button", { name: "Сохраняем анкету..." })).toHaveCount(0);
} finally {
cleanupStarted = true;