diff --git a/client/src/pages/spools/list.tsx b/client/src/pages/spools/list.tsx index 770ec17..714a6f8 100644 --- a/client/src/pages/spools/list.tsx +++ b/client/src/pages/spools/list.tsx @@ -52,6 +52,9 @@ function collapseSpool(element: ISpool): ISpoolCollapsed { } else { filament_name = element.filament.name ?? element.filament.id.toString(); } + if (!element.price){ + element.price = element.filament.price; + } return { ...element, combined_name: filament_name, diff --git a/tests_integration/tests/spool/test_add.py b/tests_integration/tests/spool/test_add.py index f5ae7fd..817a74d 100644 --- a/tests_integration/tests/spool/test_add.py +++ b/tests_integration/tests/spool/test_add.py @@ -185,3 +185,15 @@ def test_add_spool_both_used_and_remaining_weight(random_filament: dict[str, Any }, ) assert result.status_code == 400 # Cannot set both used and remaining weight + +def test_add_spool_price(random_filament: dict[str, Any]): + """Test adding a spool to the database.""" + # Execute + result = httpx.post( + f"{URL}/api/v1/spool", + json={ + "filament_id": random_filament["id"], + "price": 25, + }, + ) + assert result.status_code == 400 # Cannot set price \ No newline at end of file diff --git a/tests_integration/tests/spool/test_get.py b/tests_integration/tests/spool/test_get.py index acb8345..fa4e0f4 100644 --- a/tests_integration/tests/spool/test_get.py +++ b/tests_integration/tests/spool/test_get.py @@ -16,6 +16,7 @@ def test_get_spool(random_filament: dict[str, Any]): location = "The Pantry" lot_nr = "123456789" comment = "abcdefghåäö" + price = 25 archived = True result = httpx.post( f"{URL}/api/v1/spool", @@ -27,6 +28,7 @@ def test_get_spool(random_filament: dict[str, Any]): "location": location, "lot_nr": lot_nr, "comment": comment, + "price": price, "archived": archived, }, ) diff --git a/tests_integration/tests/spool/test_update.py b/tests_integration/tests/spool/test_update.py index c1d3be3..6ce69d8 100644 --- a/tests_integration/tests/spool/test_update.py +++ b/tests_integration/tests/spool/test_update.py @@ -99,6 +99,27 @@ def test_update_spool_both_used_and_remaining_weight(random_filament: dict[str, # Clean up httpx.delete(f"{URL}/api/v1/spool/{spool['id']}").raise_for_status() +def test_update_spool_price(random_filament: dict[str, Any]): + """Test updating a spool in the database.""" + # Setup + result = httpx.post( + f"{URL}/api/v1/spool", + json={"filament_id": random_filament["id"]}, + ) + result.raise_for_status() + spool = result.json() + + # Execute + result = httpx.patch( + f"{URL}/api/v1/spool/{spool['id']}", + json={ + "price": 750, + }, + ) + assert result.status_code == 400 # Cannot update both used and remaining weight + + # Clean up + httpx.delete(f"{URL}/api/v1/spool/{spool['id']}").raise_for_status() def test_update_spool_not_found(random_filament: dict[str, Any]): """Test updating a spool that does not exist."""