From 9bee767d01e09ae16bc896abba9e61bf758f1473 Mon Sep 17 00:00:00 2001 From: AnnMarueW Date: Tue, 23 Jun 2026 17:14:26 -0700 Subject: [PATCH 1/5] fix tests --- tests/test_custom_aggFunc_functions.py | 15 ++++-------- tests/test_selected_rows.py | 9 ++++---- tests/test_selection_buttons.py | 12 ++++++---- tests/test_sizing_buttons.py | 32 +++++++++----------------- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/tests/test_custom_aggFunc_functions.py b/tests/test_custom_aggFunc_functions.py index 769cccbe..48c5407f 100644 --- a/tests/test_custom_aggFunc_functions.py +++ b/tests/test_custom_aggFunc_functions.py @@ -6,17 +6,16 @@ import dash from dash import html, dcc from . import utils -from dash.testing.wait import until -import requests +import pandas as pd +df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" +) +data=df.to_dict("records") def test_ca001_custom_aggFunc_functions(dash_duo): app = dash.Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ # Row group by country and by year is enabled. { @@ -86,10 +85,6 @@ def test_ca001_custom_aggFunc_functions(dash_duo): def test_ca002_custom_aggFunc_functions(dash_duo): app = dash.Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ # Row group by country and by year is enabled. { diff --git a/tests/test_selected_rows.py b/tests/test_selected_rows.py index 53fdafdd..88020106 100644 --- a/tests/test_selected_rows.py +++ b/tests/test_selected_rows.py @@ -1,6 +1,5 @@ import dash_ag_grid as dag from dash import Dash, html, dcc, Output, Input, no_update -import requests from . import utils import pandas as pd import time @@ -9,9 +8,9 @@ def test_sr001_selected_rows(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() + df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" + ) columnDefs = [ {"field": "athlete"}, @@ -33,7 +32,7 @@ def test_sr001_selected_rows(dash_duo): dag.AgGrid( id="grid", columnDefs=columnDefs, - rowData=data, + rowData=df.to_dict("records"), columnSize="sizeToFit", defaultColDef={"resizable": True, "sortable": True, "filter": True}, dashGridOptions={"rowSelection": "single"}, diff --git a/tests/test_selection_buttons.py b/tests/test_selection_buttons.py index 3cdf12a6..20300854 100644 --- a/tests/test_selection_buttons.py +++ b/tests/test_selection_buttons.py @@ -1,16 +1,18 @@ import dash_ag_grid as dag from dash import Dash, html, dcc, Output, Input, no_update, ctx -import requests from . import utils +import pandas as pd + +df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" +) +data=df.to_dict("records") + def test_sb001_selection_buttons(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ {"field": "athlete"}, {"field": "age"}, diff --git a/tests/test_sizing_buttons.py b/tests/test_sizing_buttons.py index 36563a4b..dc2888c8 100644 --- a/tests/test_sizing_buttons.py +++ b/tests/test_sizing_buttons.py @@ -1,20 +1,22 @@ import pytest import dash_ag_grid as dag from dash import Dash, html, dcc, Output, Input, no_update, ctx, State -import requests from . import utils import json from dash.testing.wait import until import time +import pandas as pd + +df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" +).head(100) +data=df.to_dict("records") + def test_sb001_sizing_buttons(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ {"field": "athlete"}, {"field": "age"}, @@ -34,7 +36,7 @@ def test_sb001_sizing_buttons(dash_duo): dag.AgGrid( id="grid", columnDefs=columnDefs, - rowData=data[:100], + rowData=data, columnSize="sizeToFit", defaultColDef={ "resizable": True, @@ -123,10 +125,6 @@ def selected(state, oldState, opts): def test_sb002_sizing_buttons(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ {"field": "athlete"}, {"field": "age"}, @@ -146,7 +144,7 @@ def test_sb002_sizing_buttons(dash_duo): dag.AgGrid( id="grid", columnDefs=columnDefs, - rowData=data[:100], + rowData=data, columnSize="autoSize", defaultColDef={ "resizable": True, @@ -235,10 +233,6 @@ def selected(state): def test_sb003_sizing_buttons(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ {"field": "athlete"}, {"field": "age"}, @@ -258,7 +252,7 @@ def test_sb003_sizing_buttons(dash_duo): dag.AgGrid( id="grid", columnDefs=columnDefs, - rowData=data[:100], + rowData=data, columnSize="sizeToFit", defaultColDef={ "resizable": True, @@ -346,10 +340,6 @@ def selected(state, oldState, opts): def test_sb004_sizing_buttons(dash_duo): app = Dash(__name__) - data = requests.get( - r"https://www.ag-grid.com/example-assets/olympic-winners.json" - ).json() - columnDefs = [ {"field": "athlete"}, {"field": "age"}, @@ -369,7 +359,7 @@ def test_sb004_sizing_buttons(dash_duo): dag.AgGrid( id="grid", columnDefs=columnDefs, - rowData=data[:100], + rowData=data, columnSize="autoSize", defaultColDef={ "resizable": True, From 8a17d40b8e3eb69969cea87370b989072935a34c Mon Sep 17 00:00:00 2001 From: AnnMarueW Date: Tue, 23 Jun 2026 17:32:44 -0700 Subject: [PATCH 2/5] fix tests --- tests/test_custom_filter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_custom_filter.py b/tests/test_custom_filter.py index c4397797..a88b238c 100644 --- a/tests/test_custom_filter.py +++ b/tests/test_custom_filter.py @@ -68,7 +68,9 @@ def test_fi002_custom_filter(dash_duo): def test_fi003_custom_filter(dash_duo): app = Dash(__name__) - df = pd.read_json('https://www.ag-grid.com/example-assets/olympic-winners.json', convert_dates=False) + df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" + ) rowData = df.to_dict('records') @@ -129,7 +131,9 @@ def test_fi003_custom_filter(dash_duo): def test_fi004_custom_filter(dash_duo): app = Dash(__name__) - df = pd.read_json('https://www.ag-grid.com/example-assets/olympic-winners.json', convert_dates=False) + df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" + ) columnDefs = [ { From 42a746cb1d2559113b07bef28f998485c99b0f7e Mon Sep 17 00:00:00 2001 From: AnnMarueW Date: Wed, 24 Jun 2026 07:14:56 -0700 Subject: [PATCH 3/5] changed dropdown to button so works in dash 3 or 4 --- tests/test_column_state.py | 46 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/tests/test_column_state.py b/tests/test_column_state.py index 529f0541..f2fb027f 100644 --- a/tests/test_column_state.py +++ b/tests/test_column_state.py @@ -529,11 +529,10 @@ def test_toggle_column_visibility(dash_duo): app = Dash(__name__) app.layout = html.Div([ - dcc.Dropdown( + dcc.Button( + "hide/show col b", id="select-columns", - value=list(data.columns), - options=[{"label": col, "value": col} for col in data.columns], - multi=True, + n_clicks=0, ), dag.AgGrid( id="ag-grid", @@ -544,18 +543,17 @@ def test_toggle_column_visibility(dash_duo): @app.callback( Output("ag-grid", "columnDefs"), - Input("select-columns", "value"), + Input("select-columns", "n_clicks"), ) - def toggle_column_visibility(selected_columns): - if not selected_columns: - return no_update + def toggle_column_visibility(n): + if n % 2 == 0: + return [ + {"headerName": "a", "field": "a", "hide": False}, + {"headerName": "b", "field": "b", "hide": True} + ] return [ - { - "headerName": col_name, - "field": col_name, - "hide": col_name not in selected_columns, - } - for col_name in data.columns + {"headerName": "a", "field": "a", "hide": False}, + {"headerName": "b", "field": "b", "hide": False}, ] dash_duo.start_server(app) @@ -565,24 +563,20 @@ def toggle_column_visibility(selected_columns): grid.wait_for_cell_text(0, 0, "1") - # Hide column 'b' - dropdown = dash_duo.find_element("#select-columns") - option_b = dash_duo.find_element('span.Select-value-icon:nth-child(1)') - option_b.click() + button = dash_duo.find_element("#select-columns") + button.click() time.sleep(1) - # Only column 'a' should be visible + grid_headers = dash_duo.find_elements("div.ag-header-cell-label") header_texts = [h.text for h in grid_headers] - assert "a" not in header_texts - assert "b" in header_texts + assert "a" in header_texts + assert "b" in header_texts - # Show both columns again - dropdown.click() - option_b = dash_duo.find_element('.Select-menu') - option_b.click() + # Col b not visable + button.click() time.sleep(1) grid_headers = dash_duo.find_elements("div.ag-header-cell-label") header_texts = [h.text for h in grid_headers] assert "a" in header_texts - assert "b" in header_texts + assert "b" not in header_texts From d03e5a59ad1ac85ce44e3d477ddb1f23b1367931 Mon Sep 17 00:00:00 2001 From: AnnMarueW Date: Wed, 24 Jun 2026 14:13:05 -0700 Subject: [PATCH 4/5] fixed tests for v35 --- tests/test_custom_filter.py | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/tests/test_custom_filter.py b/tests/test_custom_filter.py index e92df021..f86483c9 100644 --- a/tests/test_custom_filter.py +++ b/tests/test_custom_filter.py @@ -5,16 +5,20 @@ from . import utils -df = px.data.election() -default_display_cols = ["district_id"] -other_cols = ["district", "winner"] - -df = pd.concat([df, pd.DataFrame({"district": ["test"]})]) - +df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" +) +rowData = df.to_dict('records') def test_fi002_custom_filter(dash_duo): app = Dash(__name__) + df = px.data.election() + default_display_cols = ["district_id"] + other_cols = ["district", "winner"] + + df = pd.concat([df, pd.DataFrame({"district": ["test"]})]) + app.layout = html.Div( [ dag.AgGrid( @@ -68,12 +72,6 @@ def test_fi002_custom_filter(dash_duo): def test_fi003_custom_filter(dash_duo): app = Dash(__name__) - df = pd.read_csv( - "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" - ) - - rowData = df.to_dict('records') - columnDefs = [ {'field': 'age', 'filter': 'agNumberColumnFilter'}, {'field': 'country', 'minWidth': 150}, @@ -130,10 +128,6 @@ def test_fi003_custom_filter(dash_duo): def test_fi003_custom_filter_v34(dash_duo): app = Dash(__name__) - df = pd.read_json('https://www.ag-grid.com/example-assets/olympic-winners.json', convert_dates=False) - - rowData = df.to_dict('records') - columnDefs = [ {'field': 'age', 'filter': 'agNumberColumnFilter'}, {'field': 'country', 'minWidth': 150}, @@ -192,9 +186,6 @@ def test_fi003_custom_filter_v34(dash_duo): def test_fi004_custom_filter(dash_duo): app = Dash(__name__) - df = pd.read_csv( - "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" - ) columnDefs = [ { @@ -224,7 +215,7 @@ def test_fi004_custom_filter(dash_duo): [ dag.AgGrid( id="grid", - rowData=df.to_dict("records"), + rowData=rowData, columnDefs=columnDefs, columnSize="sizeToFit", defaultColDef={"filter": True, "floatingFilter": True} @@ -305,9 +296,6 @@ def test_fi005_custom_filter(dash_duo): def test_fi006_custom_filter(dash_duo): app = Dash(__name__) - df = pd.read_csv( - "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" - ) columnDefs = [ {"field": "athlete", @@ -350,7 +338,7 @@ def test_fi006_custom_filter(dash_duo): id="date-filter-example", enableEnterpriseModules=True, columnDefs=columnDefs, - rowData=df.to_dict("records"), + rowData=rowData, defaultColDef={"flex": 1, "minWidth": 150, "floatingFilter": True}, dashGridOptions={"animateRows": False} ), From 8f61bd415dda368df46b6805c627b4d0e48a55a4 Mon Sep 17 00:00:00 2001 From: AnnMarueW Date: Wed, 24 Jun 2026 14:41:01 -0700 Subject: [PATCH 5/5] fixed tests --- tests/test_column_state.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/test_column_state.py b/tests/test_column_state.py index a9891dfc..dd4a70bb 100644 --- a/tests/test_column_state.py +++ b/tests/test_column_state.py @@ -547,14 +547,9 @@ def test_toggle_column_visibility(dash_duo): Input("select-columns", "n_clicks"), ) def toggle_column_visibility(n): - if n % 2 == 0: - return [ - {"headerName": "a", "field": "a", "hide": False}, - {"headerName": "b", "field": "b", "hide": True} - ] - return [ + return [ {"headerName": "a", "field": "a", "hide": False}, - {"headerName": "b", "field": "b", "hide": False}, + {"headerName": "b", "field": "b", "hide": n % 2 == 0}, ] dash_duo.start_server(app)