From 416ea3391b9fa272365f8e3e7eebd2c5a27d57dc Mon Sep 17 00:00:00 2001 From: vladtechno Date: Fri, 5 Jun 2026 18:49:31 +0300 Subject: [PATCH] =?UTF-8?q?feat(pwa):=20rename=20=D0=A1=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=BD=E2=86=92=D0=A1=D0=B0=D0=BB=D0=BE=D0=BD=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4,=20add=20=D0=A1=D0=B0=D0=BB=D0=BE=D0=BD=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=20+=20=D0=91=D0=B0=D0=B3=D0=B0=D0=B6=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=20slots?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract photo slots to tested lib/inspectionSlots; rename interior label, add interior-rear + trunk slots (all inspection types). 3 new tests. Co-Authored-By: claude-flow --- .../frontend/src/lib/inspectionSlots.test.ts | 18 +++++++++ .../frontend/src/lib/inspectionSlots.ts | 37 +++++++++++++++++++ .../frontend/src/pages/InspectionEditor.tsx | 26 +------------ 3 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 mechanic-pwa/frontend/src/lib/inspectionSlots.test.ts create mode 100644 mechanic-pwa/frontend/src/lib/inspectionSlots.ts diff --git a/mechanic-pwa/frontend/src/lib/inspectionSlots.test.ts b/mechanic-pwa/frontend/src/lib/inspectionSlots.test.ts new file mode 100644 index 0000000..b519fe4 --- /dev/null +++ b/mechanic-pwa/frontend/src/lib/inspectionSlots.test.ts @@ -0,0 +1,18 @@ +import { slotsForType } from "@/lib/inspectionSlots"; + +test("Салон перед (ключ interior сохранён) + Салон зад + Багажник", () => { + const slots = slotsForType("handover"); + expect(slots.find((s) => s.side === "interior")?.label).toBe("Салон перед"); + expect(slots.find((s) => s.side === "interior-rear")?.label).toBe("Салон зад"); + expect(slots.find((s) => s.side === "trunk")?.label).toBe("Багажник"); +}); + +test("порядок: Салон перед → Салон зад → Багажник идут подряд", () => { + const sides = slotsForType("return").map((s) => s.side); + const i = sides.indexOf("interior"); + expect(sides.slice(i, i + 3)).toEqual(["interior", "interior-rear", "trunk"]); +}); + +test("набор одинаков для всех типов (унифицировано)", () => { + expect(slotsForType("periodic")).toEqual(slotsForType("handover")); +}); diff --git a/mechanic-pwa/frontend/src/lib/inspectionSlots.ts b/mechanic-pwa/frontend/src/lib/inspectionSlots.ts new file mode 100644 index 0000000..2b96edb --- /dev/null +++ b/mechanic-pwa/frontend/src/lib/inspectionSlots.ts @@ -0,0 +1,37 @@ +/** + * Слоты фото осмотра авто. Вынесены из InspectionEditor, чтобы быть покрытыми + * тестами. Все типы осмотров (приёмка/выдача/плановый/ad-hoc) показывают один + * набор — фидбек: общее состояние машины фиксируем всегда. + * + * ВАЖНО: `side` — стабильный ключ слота (часть S3-ключа фото и значение + * PhotoSide на бэке). Подпись (`label`) менять можно, ключ — нет, иначе уже + * снятые фото осиротеют. Поэтому «Салон перед» имеет ключ `interior` (бывш. «Салон»). + */ +export interface InspectionSlot { + side: string; + label: string; +} + +export const SLOTS_GENERAL: InspectionSlot[] = [ + { side: "front", label: "Перед" }, + { side: "rear", label: "Зад" }, + { side: "left", label: "Левый бок" }, + { side: "right", label: "Правый бок" }, + { side: "vin", label: "VIN" }, + { side: "odometer", label: "Одометр" }, + { side: "interior", label: "Салон перед" }, + { side: "interior-rear", label: "Салон зад" }, + { side: "trunk", label: "Багажник" }, + { side: "free", label: "Свободное" }, +]; + +export const SLOT_JACK: InspectionSlot = { side: "jack", label: "Домкрат" }; + +// Шильдик замены масла — отдельный слот при выдаче/приёмке. Фото нужно как для +// сверки текущего пробега со следующим ТО, так и для контроля что водитель не +// клеит свой стикер. +export const SLOT_OIL_STICKER: InspectionSlot = { side: "oil-sticker", label: "Шильдик замены масла" }; + +export function slotsForType(_type: string): InspectionSlot[] { + return [...SLOTS_GENERAL, SLOT_JACK, SLOT_OIL_STICKER]; +} diff --git a/mechanic-pwa/frontend/src/pages/InspectionEditor.tsx b/mechanic-pwa/frontend/src/pages/InspectionEditor.tsx index 82e8448..23d0ccb 100644 --- a/mechanic-pwa/frontend/src/pages/InspectionEditor.tsx +++ b/mechanic-pwa/frontend/src/pages/InspectionEditor.tsx @@ -25,30 +25,8 @@ import { loadZoneLabels } from "@/data/zoneLabels"; import { damageTypeRuToEnum } from "@/data/damageVocabulary"; import { ttImageUrl } from "@/api/vehicles"; -const SLOTS_GENERAL: { side: string; label: string }[] = [ - { side: "front", label: "Перед" }, - { side: "rear", label: "Зад" }, - { side: "left", label: "Левый бок" }, - { side: "right", label: "Правый бок" }, - { side: "vin", label: "VIN" }, - { side: "odometer", label: "Одометр" }, - { side: "interior", label: "Салон" }, - { side: "free", label: "Свободное" }, -]; - -const SLOT_JACK = { side: "jack", label: "Домкрат" }; -// Шильдик замены масла — отдельный слот при выдаче/приёмке. -// Фото нужно как для сверки текущего пробега со следующим ТО, так и для -// контроля что водитель не клеит свой стикер. -const SLOT_OIL_STICKER = { side: "oil-sticker", label: "Шильдик замены масла" }; - -/** Все типы осмотров (выдача/приёмка/плановый/...) показывают одинаковый - * набор слотов общих ракурсов + домкрат. Раньше «return» исключал общие - * фото в пользу скорости приёмки, но фидбек: при приёмке всё равно надо - * фиксировать общее состояние машины, как и при выдаче/осмотре. */ -function slotsForType(_type: string): typeof SLOTS_GENERAL { - return [...SLOTS_GENERAL, SLOT_JACK, SLOT_OIL_STICKER]; -} +// Слоты фото осмотра — в @/lib/inspectionSlots (покрыто тестами). +import { slotsForType } from "@/lib/inspectionSlots"; const SEVERITY_LABELS: Record = { cosmetic: "косметика",