diff --git a/frontend/src/__tests__/components/SpoolFormModal.test.tsx b/frontend/src/__tests__/components/SpoolFormModal.test.tsx index f357fc121..821f1ac2e 100644 --- a/frontend/src/__tests__/components/SpoolFormModal.test.tsx +++ b/frontend/src/__tests__/components/SpoolFormModal.test.tsx @@ -258,10 +258,8 @@ describe('SpoolFormModal weightTouched', () => { fireEvent.focus(weightPicker!); // Click on "Bambu Lab 250g" option - await waitFor(() => { - const bambuOption = screen.queryByText('Bambu Lab 250g'); - if (bambuOption) fireEvent.click(bambuOption); - }); + const bambuOption = await screen.findByText('Bambu Lab 250g'); + fireEvent.click(bambuOption); // Click the add spool button const addButtons = screen.getAllByRole('button', { name: /add spool/i }); @@ -317,7 +315,7 @@ describe('SpoolFormModal weightTouched', () => { const bambuFound = weightInputs.some(input => input.value === 'Bambu Lab 250g' || input.getAttribute('value') === 'Bambu Lab 250g' ); - expect(bambuFound || screen.queryByText('Bambu Lab 250g')).toBeTruthy(); + expect(bambuFound).toBeTruthy(); }); }); }); diff --git a/frontend/src/components/SpoolFormModal.tsx b/frontend/src/components/SpoolFormModal.tsx index 9ebd56905..11988349c 100644 --- a/frontend/src/components/SpoolFormModal.tsx +++ b/frontend/src/components/SpoolFormModal.tsx @@ -171,7 +171,7 @@ export function SpoolFormModal({ isOpen, onClose, spool, printersWithCalibration rgba: spool.rgba || '808080FF', label_weight: spool.label_weight || 1000, core_weight: spool.core_weight || 250, - core_weight_catalog_id: spool.core_weight_catalog_id || null, + core_weight_catalog_id: spool.core_weight_catalog_id ?? null, weight_used: spool.weight_used || 0, slicer_filament: spool.slicer_filament || '', note: spool.note || '', diff --git a/frontend/src/components/spool-form/AdditionalSection.tsx b/frontend/src/components/spool-form/AdditionalSection.tsx index 82e8d0f5f..44acdd7c0 100644 --- a/frontend/src/components/spool-form/AdditionalSection.tsx +++ b/frontend/src/components/spool-form/AdditionalSection.tsx @@ -54,9 +54,8 @@ function SpoolWeightPicker({ if (matches.length === 1) { onCatalogIdChange(matches[0].id); } else if (matches.length === 0) { - // No matches, clear selection only if we don't have a catalogId - // (to avoid clearing valid IDs when catalog hasn't loaded yet) - if (!catalogId) { + // No matches, clear selection to prevent stale catalog ID + if (catalogId !== null) { onCatalogIdChange(null); } }