mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
fix(spool-form): improve handling of core_weight_catalog_id and catalog ID selection logic
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 || '',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user