@@ -721,11 +721,6 @@ def test_widget_with_unknown_row_count_empty_dataframe(
721721 assert widget .page == 0
722722
723723
724- # TODO(shuowei): Add tests for custom index and multiindex
725- # This may not be necessary for the SQL Cell use case but should be
726- # considered for completeness.
727-
728-
729724def test_widget_sort_should_sort_ascending_on_first_click (
730725 table_widget , paginated_pandas_df : pd .DataFrame
731726):
@@ -817,3 +812,55 @@ def test_widget_sort_should_reset_on_page_size_change(
817812 html = table_widget .table_html
818813
819814 _assert_html_matches_pandas_slice (html , expected_slice , paginated_pandas_df )
815+
816+
817+ @pytest .fixture (scope = "module" )
818+ def integer_column_df (session ):
819+ """Create a DataFrame with integer column labels."""
820+ pandas_df = pd .DataFrame ([[0 , 1 ], [2 , 3 ]], columns = pd .Index ([1 , 2 ]))
821+ return session .read_pandas (pandas_df )
822+
823+
824+ @pytest .fixture (scope = "module" )
825+ def multiindex_column_df (session ):
826+ """Create a DataFrame with MultiIndex column labels."""
827+ pandas_df = pd .DataFrame (
828+ {
829+ "foo" : ["one" , "one" , "one" , "two" , "two" , "two" ],
830+ "bar" : ["A" , "B" , "C" , "A" , "B" , "C" ],
831+ "baz" : [1 , 2 , 3 , 4 , 5 , 6 ],
832+ "zoo" : ["x" , "y" , "z" , "q" , "w" , "t" ],
833+ }
834+ )
835+ df = session .read_pandas (pandas_df )
836+ # The session is attached to `df` through the constructor.
837+ # We can pass it to the pivoted DataFrame.
838+ pdf = df .pivot (index = "foo" , columns = "bar" , values = ["baz" , "zoo" ])
839+ return pdf
840+
841+
842+ def test_table_widget_integer_columns_disables_sorting (integer_column_df ):
843+ """
844+ Given a DataFrame with integer column labels, the widget should
845+ disable sorting.
846+ """
847+ from bigframes .display import TableWidget
848+
849+ widget = TableWidget (integer_column_df )
850+ assert widget .orderable_columns == []
851+
852+
853+ def test_table_widget_multiindex_columns_disables_sorting (multiindex_column_df ):
854+ """
855+ Given a DataFrame with a MultiIndex for columns, the widget should
856+ disable sorting.
857+ """
858+ from bigframes .display import TableWidget
859+
860+ widget = TableWidget (multiindex_column_df )
861+ assert widget .orderable_columns == []
862+
863+
864+ # TODO(shuowei): Add tests for custom index and multiindex
865+ # This may not be necessary for the SQL Cell use case but should be
866+ # considered for completeness.
0 commit comments