@@ -63,6 +63,28 @@ def european_csv_file() -> Iterator[Path]:
6363 path .unlink (missing_ok = True )
6464
6565
66+ @pytest .fixture
67+ def percentage_filter_csv_file () -> Iterator [Path ]:
68+ """CSV with filter transmission in 0-100% range (not 0-1)."""
69+ content = """wavelength,Filter_BP630
70+ 400,0.001
71+ 500,0.002
72+ 600,5.5
73+ 610,34.0
74+ 620,85.0
75+ 630,99.2
76+ 640,92.0
77+ 650,50.0
78+ 660,3.0
79+ 700,0.001
80+ """
81+ with tempfile .NamedTemporaryFile (mode = "w" , suffix = ".csv" , delete = False ) as f :
82+ f .write (content )
83+ path = Path (f .name )
84+ yield path
85+ path .unlink (missing_ok = True )
86+
87+
6688@pytest .fixture
6789def spectrum_form_page (live_server : LiveServer , auth_page : Page ) -> Iterator [Page ]:
6890 """Navigate to the spectrum form page."""
@@ -548,6 +570,29 @@ def test_submit_filter_spectrum_with_source(
548570 assert spectrum .reference is None # No reference was provided
549571
550572
573+ def test_submit_filter_percentage_data_normalized_to_fraction (
574+ spectrum_form_page : Page , percentage_filter_csv_file : Path
575+ ) -> None :
576+ """Filter data in 0-100% range is converted to 0-1 fraction on submission."""
577+ page = spectrum_form_page
578+ _upload_csv (page , percentage_filter_csv_file )
579+ _select_columns (page , wavelength_col = 0 , data_cols = [1 ])
580+
581+ _fill_spectrum_card (page , category = "f" , subtype = "bp" , owner = "E2E Pct Filter" )
582+ _fill_source (page , "E2E Pct Filter Source" )
583+
584+ page .locator ("#id_confirmation" ).check ()
585+ page .locator ("#submit-btn" ).click ()
586+
587+ expect (page ).to_have_url (re .compile (r".*/spectra/submitted/" ))
588+
589+ spectrum = Spectrum .objects .all_objects ().filter (source = "E2E Pct Filter Source" ).first ()
590+ assert spectrum is not None
591+ max_val = max (v for _ , v in spectrum .data )
592+ assert max_val <= 1.0 , f"Filter data should be 0-1 fraction, got max={ max_val } "
593+ assert max_val > 0.9 , f"Expected max near 0.99, got { max_val } "
594+
595+
551596def test_submit_light_spectrum (spectrum_form_page : Page , sample_csv_file : Path ) -> None :
552597 """Submit a light source spectrum (exercises light category handling)."""
553598 page = spectrum_form_page
0 commit comments