ываыв
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# Аудит заказов, оплаты и админки заказов
|
||||
|
||||
**Дата:** 2026-05-28
|
||||
**Scope:** `orders/payments/admin-orders`
|
||||
|
||||
## Summary
|
||||
|
||||
- P0: не найдено в первой итерации.
|
||||
- P1: исправлены SSE/queryKey для админской деталки, authorType админского чата, summary внимания и guard оплаты до подтверждения доставки.
|
||||
- P2: добавлены focused tests для найденных дефектов.
|
||||
- P3: рефакторинги оставлены в backlog.
|
||||
|
||||
## Findings
|
||||
|
||||
### P1-001: SSE инвалидирует несуществующий queryKey админской деталки
|
||||
|
||||
**Статус:** fixed
|
||||
**Код:** `client/src/app/providers/SseProvider.tsx`
|
||||
**Тест:** `client/src/app/providers/__tests__/SseProvider.test.tsx`
|
||||
**Симптом:** события `message:new`, `order:statusChanged`, `order:updated` инвалидируют `['admin', 'orders', orderId]`, но деталка использует `['admin', 'orders', 'detail', selectedId]`.
|
||||
**Решение:** добавить инвалидацию `['admin', 'orders', 'detail', orderId]`, списка и summary для order events.
|
||||
|
||||
### P1-002: Админский чат передает инвертированный authorType в ChatMessageBubble
|
||||
|
||||
**Статус:** fixed
|
||||
**Код:** `client/src/features/order-detail/ui/OrderDetailContent.tsx`
|
||||
**Тест:** `client/src/features/order-detail/ui/__tests__/OrderDetailContent.test.tsx`
|
||||
**Симптом:** для `m.authorType === 'admin'` компонент получает `authorType="user"`.
|
||||
**Решение:** передавать фактический `authorType`: admin-message как `admin`, user-message как `user`.
|
||||
|
||||
### P1-003: Admin summary считает все PENDING_PAYMENT как attention
|
||||
|
||||
**Статус:** fixed
|
||||
**Код:** `server/src/routes/api/admin-orders.js`
|
||||
**Тест:** `server/src/routes/api/__tests__/admin-orders.test.js`
|
||||
**Симптом:** `attentionCount` считает все `PENDING_PAYMENT`, включая заказы, где цена уже подтверждена.
|
||||
**Решение:** считать только `PENDING_PAYMENT + delivery + deliveryFeeLocked=false`.
|
||||
|
||||
### P1-004: Admin может перевести delivery-заказ в PAID до подтверждения цены
|
||||
|
||||
**Статус:** fixed
|
||||
**Код:** `server/src/routes/api/admin-orders.js`
|
||||
**Тест:** `server/src/routes/api/__tests__/admin-orders.test.js`
|
||||
**Симптом:** статусный guard разрешает `PENDING_PAYMENT -> PAID` без проверки `deliveryFeeLocked`.
|
||||
**Решение:** для `next === 'PAID'` отклонять delivery-заказы с `deliveryFeeLocked === false` кодом 409.
|
||||
|
||||
## Refactor Backlog
|
||||
|
||||
- Проверить, нужен ли `client/src/shared/constants/order.ts::canTransitionOrderStatus`; если нужен, сделать deliveryType обязательным аргументом.
|
||||
- После стабилизации route-тестов рассмотреть вынос части логики `admin-orders.js` в маленькие pure helpers.
|
||||
|
||||
## Verification
|
||||
|
||||
- `server npm test` — pass
|
||||
- `server npm run lint` — pass, warnings only
|
||||
- `server npm run format:check` — pass
|
||||
- `client npm run lint` — pass, warnings only
|
||||
- `client npm run format:check` — pass
|
||||
- `client focused vitest` — pass
|
||||
- `client npm run build` — pass, Vite chunk-size warning only
|
||||
Reference in New Issue
Block a user