Просмотр исходного кода

fix(profiles): add PLA-CF + Bambu CF/GF/specialty variants to filament_type select (#1686)

  The Profiles page edit modal (shared by BL Cloud / Orca Cloud / Local
  Profiles) renders filament_type from backend/app/data/filament_fields.json
  via GET /cloud/fields/filament. The curated 11-option list pre-dated Bambu's
  CF/GF lineup expansion, so PLA-CF and most carbon/glass-fiber variants were
  unselectable — saved presets carried the wrong material code at dispatch.

  Expanded to 25 BambuStudio-aligned options grouped by family: PLA (+ CF/GF/
  AERO), PETG (+ CF), ABS (+ GF), ASA (+ CF/GF), PC, PCTG, PA family (+ CF/
  PAHT-CF/PA6-CF/PA6-GF), PET-CF, TPU, PPS family (+ CF/GF for X1E), PVA, HIPS.

  K-profiles editor unaffected (picks filament_id, not filament_type).
maziggy 2 месяцев назад
Родитель
Сommit
bfbf5d59af

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
CHANGELOG.md


+ 18 - 4
backend/app/data/filament_fields.json

@@ -17,14 +17,28 @@
       "description": "Material type",
       "options": [
         {"value": "PLA", "label": "PLA"},
-        {"value": "ABS", "label": "ABS"},
+        {"value": "PLA-CF", "label": "PLA-CF"},
+        {"value": "PLA-GF", "label": "PLA-GF"},
+        {"value": "PLA-AERO", "label": "PLA Aero"},
         {"value": "PETG", "label": "PETG"},
-        {"value": "TPU", "label": "TPU"},
+        {"value": "PETG-CF", "label": "PETG-CF"},
+        {"value": "ABS", "label": "ABS"},
+        {"value": "ABS-GF", "label": "ABS-GF"},
+        {"value": "ASA", "label": "ASA"},
+        {"value": "ASA-CF", "label": "ASA-CF"},
+        {"value": "ASA-GF", "label": "ASA-GF"},
+        {"value": "PC", "label": "PC"},
+        {"value": "PCTG", "label": "PCTG"},
         {"value": "PA", "label": "PA (Nylon)"},
         {"value": "PA-CF", "label": "PA-CF"},
+        {"value": "PAHT-CF", "label": "PAHT-CF"},
+        {"value": "PA6-CF", "label": "PA6-CF"},
+        {"value": "PA6-GF", "label": "PA6-GF"},
         {"value": "PET-CF", "label": "PET-CF"},
-        {"value": "PC", "label": "PC"},
-        {"value": "ASA", "label": "ASA"},
+        {"value": "TPU", "label": "TPU"},
+        {"value": "PPS", "label": "PPS"},
+        {"value": "PPS-CF", "label": "PPS-CF"},
+        {"value": "PPS-GF", "label": "PPS-GF"},
         {"value": "PVA", "label": "PVA"},
         {"value": "HIPS", "label": "HIPS"}
       ]

+ 53 - 0
backend/tests/unit/test_filament_fields_options.py

@@ -0,0 +1,53 @@
+"""Regression pin for the filament_type select options exposed by
+GET /cloud/fields/filament — used by the Profiles edit modal.
+
+Issue #1686: PLA-CF and other CF/GF variants were missing from the dropdown,
+so users could not tag custom presets with the correct material type.
+"""
+
+import json
+from pathlib import Path
+
+import pytest
+
+FIELDS_PATH = Path(__file__).resolve().parents[2] / "app" / "data" / "filament_fields.json"
+
+
+@pytest.fixture(scope="module")
+def filament_type_options() -> set[str]:
+    with FIELDS_PATH.open() as f:
+        data = json.load(f)
+    field = next(f for f in data["fields"] if f["key"] == "filament_type")
+    return {opt["value"] for opt in field["options"]}
+
+
+@pytest.mark.parametrize(
+    "material",
+    [
+        # Reported in #1686
+        "PLA-CF",
+        # Other Bambu CF / GF / specialty variants that share the same gap
+        "PLA-GF",
+        "PLA-AERO",
+        "PETG-CF",
+        "ABS-GF",
+        "ASA-CF",
+        "ASA-GF",
+        "PCTG",
+        "PAHT-CF",
+        "PA6-CF",
+        "PA6-GF",
+        "PPS",
+        "PPS-CF",
+        "PPS-GF",
+    ],
+)
+def test_filament_type_includes_carbon_and_glass_fiber_variants(filament_type_options: set[str], material: str) -> None:
+    assert material in filament_type_options
+
+
+def test_filament_type_keeps_baseline_materials(
+    filament_type_options: set[str],
+) -> None:
+    baseline = {"PLA", "PETG", "ABS", "ASA", "PC", "PA", "PA-CF", "PET-CF", "TPU", "PVA", "HIPS"}
+    assert baseline.issubset(filament_type_options)

Некоторые файлы не были показаны из-за большого количества измененных файлов