feat(frontend): complete candidate flow and public pages

This commit is contained in:
TakuyaYagam1 committed 2026-10-11 22:37:07 +03:00
1 parent a69b1a79bb
commit e4be4a3956
63 files changed
+1903 -746

No files matched your search

+54 -9
View File
@@ -443,30 +443,48 @@ test.describe("minimal path states with a stubbed API", () => {
"GET /api/v1/identity/sessions/current": { status: 200, body: candidateSession() },
"GET /api/v1/me/assessment-availability": () =>
failing ? problem("internal_error", 500) : { status: 200, body: { specializations: [] } },
"GET /api/v1/me/profile": {
status: 200,
body: { version: 0, confirmed_categories: [] },
},
"GET /api/v1/me/questionnaire": {
status: 200,
body: { version: 0, specializations: [], work_context: null, updated_at: null },
},
"GET /api/v1/me/assessment-results": {
status: 200,
body: { items: [], page: { has_more: false, next_cursor: null } },
},
});
await page.goto("/candidate/assessment");
await expect(page.getByRole("alert")).toContainText(
const availabilityRegion = page.getByRole("region", { name: "Доступность проверки" });
await expect(availabilityRegion.getByRole("alert")).toContainText(
"Не удалось загрузить состояние проверки",
{ timeout: 15_000 },
);
const progressAlert = page
.getByRole("alert")
.filter({ hasText: "Не удалось загрузить прогресс" });
await expect(progressAlert).toBeVisible();
await expectNoHorizontalOverflow(page, width);
failing = false;
await tabTo(page, page.getByRole("button", { name: "Повторить" }));
await tabTo(page, availabilityRegion.getByRole("button", { name: "Повторить" }));
await page.keyboard.press("Enter");
await expect(page.getByText("Сначала выберите специализацию")).toBeVisible();
await expect(page.getByRole("link", { name: "Открыть анкету" })).toBeVisible();
await tabTo(page, progressAlert.getByRole("button", { name: "Повторить" }));
await page.keyboard.press("Enter");
await expect(page.getByRole("heading", { name: "Профиль, анкета и тест" })).toBeVisible();
await expect(page.getByRole("alert")).toHaveCount(0);
await expectNoHorizontalOverflow(page, width);
});
test(`candidate profile at ${width}px: loading, an error with a retry, and access denied`, async ({
page,
}) => {
// The profile query does not retry, so the state changes only when the
// candidate presses the retry button: the second answer is a 403.
// Hold every profile read until the form's loading state is visible.
// The form retry then answers with a 403 while the journey error remains
// independently retryable.
const release = deferred<void>();
let stage: "error" | "forbidden" = "error";
await mockApi(page, {
@@ -475,17 +493,44 @@ test.describe("minimal path states with a stubbed API", () => {
await release.promise;
return stage === "error" ? problem("internal_error", 500) : problem("forbidden", 403);
},
"GET /api/v1/me/questionnaire": {
status: 200,
body: { version: 0, specializations: [], work_context: null, updated_at: null },
},
"GET /api/v1/me/assessment-availability": {
status: 200,
body: { specializations: [] },
},
"GET /api/v1/me/assessment-results": {
status: 200,
body: { items: [], page: { has_more: false, next_cursor: null } },
},
"GET /api/v1/me/privacy/preview": {
status: 200,
body: {
state: "closed",
fields: [],
card: null,
evidence: null,
generated_at: "2026-10-09T10:00:00Z",
},
},
});
await page.goto("/candidate/profile");
await expect(page.getByText("Загружаем профиль кандидата...")).toBeVisible();
await expect(page.getByText("Загружаем профиль кандидата...", { exact: true })).toBeVisible();
await expectNoHorizontalOverflow(page, width);
release.resolve();
await expect(page.getByRole("alert")).toContainText("Не удалось загрузить профиль");
const profileAlert = page
.getByRole("alert")
.filter({ hasText: "Не удалось загрузить профиль" });
await expect(profileAlert).toContainText("Не удалось загрузить профиль");
stage = "forbidden";
await tabTo(page, page.getByRole("button", { name: "Повторить" }));
await tabTo(page, profileAlert.getByRole("button", { name: "Повторить" }));
await page.keyboard.press("Enter");
await expect(page.getByText("Профиль недоступен")).toBeVisible();
await expect(page.getByRole("button", { name: "Повторить" })).toHaveCount(0);
const profileForbidden = page.getByRole("status").filter({ hasText: "Профиль недоступен" });
await expect(profileForbidden).toBeVisible();
await expect(profileForbidden.getByRole("button", { name: "Повторить" })).toHaveCount(0);
await expect(profileForbidden.locator("input, textarea, select")).toHaveCount(0);
await expectNoHorizontalOverflow(page, width);
});
}