fix(assessment): add the missing result summary and format imports
This commit is contained in:
1 parent
5c52fd8b91
commit
6bfd7098c3
3 files changed
+144
-1
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { AssessmentResult } from "../../../shared/api/schemas";
|
||||
import { assessmentResultSummary } from "./result-summary";
|
||||
|
||||
const base = {
|
||||
attempt_id: "0199b4f2-7c1e-7d3a-9f00-aabbccddeeff",
|
||||
specialization: "backend",
|
||||
target_grade: "middle",
|
||||
root_attempt_id: null,
|
||||
chain_deadline: null,
|
||||
task_language: "go",
|
||||
kind: "root",
|
||||
mode: "demo_basic",
|
||||
not_determined_reason: null,
|
||||
confirmed_grade: null,
|
||||
previous_confirmed_grade: null,
|
||||
strength: null,
|
||||
calibration_status: "uncalibrated",
|
||||
limitations: [],
|
||||
uncertainty: null,
|
||||
basic_score: null,
|
||||
practices: [],
|
||||
gaps: [],
|
||||
durations: { items_seconds: 60, practice_seconds: null },
|
||||
next_steps: [],
|
||||
} as const;
|
||||
|
||||
function result(patch: Record<string, unknown>): AssessmentResult {
|
||||
return { ...base, ...patch } as unknown as AssessmentResult;
|
||||
}
|
||||
|
||||
describe("assessmentResultSummary", () => {
|
||||
it("restates a confirmed grade without deriving one", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "confirmed", confirmed_grade: "middle" }),
|
||||
);
|
||||
expect(summary.text).toBe("Уровень подтвержден: Backend, Middle.");
|
||||
expect(summary.reason).toBeNull();
|
||||
expect(summary.isDemonstration).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the previous grade when nothing was confirmed", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "not_confirmed", previous_confirmed_grade: "junior" }),
|
||||
);
|
||||
expect(summary.text).toBe("Уровень пока не подтвержден: Backend, Middle.");
|
||||
expect(summary.reason).toBe("Прежний подтвержденный уровень Junior сохраняется.");
|
||||
});
|
||||
|
||||
it("explains why no decision was made", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "not_determined", not_determined_reason: "expired" }),
|
||||
);
|
||||
expect(summary.text).toBe("Результат не определен: Backend, Middle.");
|
||||
expect(summary.reason).toBe("Время попытки истекло до завершения заданий.");
|
||||
});
|
||||
|
||||
it("marks express training as a demonstration", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({
|
||||
kind: "demo_express",
|
||||
mode: "demo_express",
|
||||
specialization: null,
|
||||
target_grade: null,
|
||||
task_language: null,
|
||||
outcome: "demonstration",
|
||||
limitations: ["demonstration_only"],
|
||||
}),
|
||||
);
|
||||
expect(summary.isDemonstration).toBe(true);
|
||||
expect(summary.reason).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user