diff --git a/vizro-core/tests/unit/vizro/conftest.py b/vizro-core/tests/unit/vizro/conftest.py index be2c41e6f..1048465f0 100644 --- a/vizro-core/tests/unit/vizro/conftest.py +++ b/vizro-core/tests/unit/vizro/conftest.py @@ -5,6 +5,7 @@ import vizro.models as vm import vizro.plotly.express as px +from vizro.tables import dash_data_table @pytest.fixture @@ -24,6 +25,10 @@ def standard_px_chart(gapminder): size_max=60, ) +@pytest.fixture +def standard_dash_table(gapminder): + return dash_data_table(data_frame=gapminder) + @pytest.fixture def standard_go_chart(gapminder): diff --git a/vizro-core/tests/unit/vizro/models/_components/test_table.py b/vizro-core/tests/unit/vizro/models/_components/test_table.py index ac0944ec8..e1c8d8ff1 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_table.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_table.py @@ -14,11 +14,6 @@ from vizro.tables import dash_data_table -@pytest.fixture -def standard_dash_table(): - return dash_data_table(data_frame=px.data.gapminder()) - - @pytest.fixture def dash_table_with_arguments(): return dash_data_table(data_frame=px.data.gapminder(), style_header={"border": "1px solid green"}) @@ -31,7 +26,13 @@ def dash_table_with_str_dataframe(): @pytest.fixture def expected_table(): - return html.Div(dash_table.DataTable(pd.DataFrame().to_dict("records"), []), id="text_table") + return html.Div( + [ + None, + html.Div(dash_table.DataTable(), id="text_table"), + ], + className="table-container", + ) class TestDunderMethodsTable: @@ -109,7 +110,7 @@ def test_process_figure_data_frame_df(self, standard_dash_table, gapminder): class TestBuildTable: - def test_graph_build(self, standard_dash_table, expected_table): + def test_table_build(self, standard_dash_table, expected_table): table = vm.Table( id="text_table", figure=standard_dash_table, diff --git a/vizro-core/tests/unit/vizro/models/test_page.py b/vizro-core/tests/unit/vizro/models/test_page.py index 416ba458c..18d18ed5d 100644 --- a/vizro-core/tests/unit/vizro/models/test_page.py +++ b/vizro-core/tests/unit/vizro/models/test_page.py @@ -90,10 +90,10 @@ def test_set_layout_invalid(self): with pytest.raises(ValidationError, match="Number of page and grid components need to be the same."): vm.Page(title="Page 4", components=[vm.Button()], layout=vm.Layout(grid=[[0, 1]])) - def test_valid_component_types(self, standard_px_chart): + def test_valid_component_types(self, standard_px_chart,standard_dash_table): vm.Page( title="Page Title", - components=[vm.Graph(figure=standard_px_chart), vm.Card(text="""# Header 1"""), vm.Button()], + components=[vm.Graph(figure=standard_px_chart), vm.Card(text="""# Header 1"""), vm.Button(),vm.Table(figure=standard_dash_table)], ) @pytest.mark.parametrize(