@@ -428,3 +428,73 @@ def test_polars_df_no_pyarrow():
428428 "Computing pairwise associations is not available for Polars dataframes "
429429 "when PyArrow is not installed" in html_snippet
430430 )
431+
432+
433+ @skip_polars_installed_without_pyarrow
434+ def test_open_tab_parameter (df_module ):
435+ """Test the open_tab parameter functionality"""
436+ df = df_module .make_dataframe (
437+ {
438+ "A" : [1 , 2 , 3 , 4 , 5 ],
439+ "B" : ["a" , "b" , "c" , "d" , "e" ],
440+ }
441+ )
442+
443+ # Test open behavior (should be 'table')
444+ report1 = TableReport (df )
445+ assert report1 .open_tab == "table"
446+
447+ # Test explicitly set to 'stats'
448+ report2 = TableReport (df , open_tab = "stats" )
449+ assert report2 .open_tab == "stats"
450+
451+ # Test set to 'distributions'
452+ report3 = TableReport (df , open_tab = "distributions" )
453+ assert report3 .open_tab == "distributions"
454+
455+ # Test set to 'associations'
456+ report4 = TableReport (df , open_tab = "associations" )
457+ assert report4 .open_tab == "associations"
458+
459+ # Test HTML generation includes correct attributes
460+ html_snippet = report2 .html_snippet ()
461+ assert 'data-target-panel-id="summary-statistics-panel"' in html_snippet
462+ assert "data-is-selected" in html_snippet
463+
464+
465+ @skip_polars_installed_without_pyarrow
466+ def test_open_tab_wrong_names (df_module ):
467+ df = df_module .make_dataframe (
468+ {
469+ "A" : [1 , 2 , 3 , 4 , 5 ],
470+ "B" : ["a" , "b" , "c" , "d" , "e" ],
471+ }
472+ )
473+
474+ # Test invalid tab name (should raise error)
475+ with pytest .raises (ValueError , match = "'open_tab' must be one of" ):
476+ TableReport (df , open_tab = "invalid" )
477+
478+ with pytest .raises (ValueError , match = "'open_tab' must be one of" ):
479+ TableReport (df , open_tab = "invalid" ).html ()
480+
481+
482+ @skip_polars_installed_without_pyarrow
483+ def test_open_tab_minimal_mode (df_module ):
484+ """Test that default_tab falls back to 'table' in minimal mode when needed"""
485+ df = df_module .make_dataframe (
486+ {
487+ "A" : [1 , 2 , 3 , 4 , 5 ],
488+ "B" : ["a" , "b" , "c" , "d" , "e" ],
489+ }
490+ )
491+
492+ # Test minimal mode with open_tab set to 'distributions'
493+ report1 = TableReport (df , open_tab = "distributions" )
494+ report1 ._set_minimal_mode ()
495+ assert report1 .open_tab == "table"
496+
497+ # Test minimal mode with open_tab set to 'associations'
498+ report2 = TableReport (df , open_tab = "associations" )
499+ report2 ._set_minimal_mode ()
500+ assert report2 .open_tab == "table"
0 commit comments