diff --git a/PROGRESS.md b/PROGRESS.md index 21539f9..a57be5c 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -46,6 +46,9 @@ - **Admin Tests: Color Picker + Pack Color Sync**: Added palette-based test color selection - Test editor now uses the same palette picker as packs - When selecting/changing a pack in test editor, test color auto-updates to the pack color +- **Admin Bulk Card Editor: Fix pack mapping typing**: Fixed TypeScript build error in pack list loading + - Removed unsafe `Record` cast for `CardPackPreviewDto` + - Added unit test and JSDOM polyfills for Radix Select in tests (`mnemo_cards_admin`) - **Service Reliability**: Enhanced service management and monitoring - Port conflict detection and resolution diff --git a/TODO.md b/TODO.md index a5ed344..9aac4a1 100644 --- a/TODO.md +++ b/TODO.md @@ -52,6 +52,7 @@ - Frontend components: Target 70% coverage - Common libraries: Target 90% coverage - ✅ Added unit test for version display on auth page + - ✅ Admin: fixed `BulkCardEditor` pack loading TypeScript error (TS2352) + unit test; added JSDOM polyfills for Radix Select - ✅ Web: CardViewer navigation controls are constrained under the card on wide screens (widget test added) - ✅ Web: Pack details "Перемешать" button has no active (pressed) state (widget test updated) - ✅ **User Telegram Field Tests**: Added comprehensive unit tests for telegram field diff --git a/mnemo_cards_admin/src/components/BulkCardEditor.tsx b/mnemo_cards_admin/src/components/BulkCardEditor.tsx index d89eeed..1e0409c 100644 --- a/mnemo_cards_admin/src/components/BulkCardEditor.tsx +++ b/mnemo_cards_admin/src/components/BulkCardEditor.tsx @@ -75,12 +75,8 @@ export function BulkCardEditor({ images, defaultPackId, onComplete, onCancel }: try { if (response && response.items && Array.isArray(response.items)) { const packs = response.items.map((pack) => { - const obj: Record = - pack && typeof pack === 'object' - ? (pack as Record) - : {} - const id = String(obj.id ?? '') - const title = String(obj.title ?? obj.id ?? '') + const id = String(pack.id) + const title = pack.title?.trim() ? String(pack.title) : id return { id, title } }) setPacksData(packs) diff --git a/mnemo_cards_admin/src/test/setup.ts b/mnemo_cards_admin/src/test/setup.ts index c44951a..2b4a9d6 100644 --- a/mnemo_cards_admin/src/test/setup.ts +++ b/mnemo_cards_admin/src/test/setup.ts @@ -1 +1,21 @@ import '@testing-library/jest-dom' + +// Radix UI uses Pointer Events APIs that are not fully implemented in JSDOM. +// Polyfill the minimal surface to prevent runtime errors in tests. +if (!Element.prototype.hasPointerCapture) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + Element.prototype.hasPointerCapture = () => false +} +if (!Element.prototype.setPointerCapture) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + Element.prototype.setPointerCapture = () => {} +} +if (!Element.prototype.releasePointerCapture) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + Element.prototype.releasePointerCapture = () => {} +} + +if (!HTMLElement.prototype.scrollIntoView) { + // eslint-disable-next-line @typescript-eslint/no-empty-function + HTMLElement.prototype.scrollIntoView = () => {} +}