Skip to content

Conversation

l0uden
Copy link
Contributor

@l0uden l0uden commented Sep 29, 2025

Description

Tests for set_control action drill_through and interactions

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

l0uden added 30 commits April 1, 2025 14:32
Copy link
Contributor

github-actions bot commented Sep 29, 2025

View the example dashboards of the current commit live on PyCafe ☕ 🚀

Updated on: 2025-10-01 16:47:35 UTC
Commit: 1b609d8

Compare the examples using the commit's wheel file vs the latest released version:

vizro-core/examples/scratch_dev

View with commit's wheel vs View with latest release

vizro-core/examples/dev/

View with commit's wheel vs View with latest release

vizro-core/examples/visual-vocabulary/

View with commit's wheel vs View with latest release

vizro-core/examples/tutorial/

View with commit's wheel vs View with latest release

Copy link
Contributor

@huong-li-nguyen huong-li-nguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Really appreciated the comments to see what happens :)

Copy link
Contributor

@petar-qb petar-qb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really amazing work @l0uden!! 🚀 🚀

Left a few comments below, but you're really close to getting this merged!

Comment on lines +15 to +44
layout=vm.Grid(grid=[[0], [2], [1]]),
components=[
vm.Graph(
id=cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID,
figure=px.scatter(
iris,
x="sepal_length",
y="petal_width",
color="species",
custom_data=["species"],
),
actions=[
set_control(control="filter_interactions", value="species"),
vm.Action(
function=scatter_click_data_custom_action(),
inputs=[f"{cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID}.clickData"],
outputs=f"{cnst.CARD_SET_CONTROL_INTERACTIONS_ID}",
),
],
),
vm.Card(id=cnst.CARD_SET_CONTROL_INTERACTIONS_ID, text="### No data clicked."),
vm.Graph(
id=cnst.BOX_SET_CONTROL_INTERACTIONS_ID,
figure=px.box(
iris,
x="sepal_length",
y="petal_width",
color="species",
),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same?

Suggested change
layout=vm.Grid(grid=[[0], [2], [1]]),
components=[
vm.Graph(
id=cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID,
figure=px.scatter(
iris,
x="sepal_length",
y="petal_width",
color="species",
custom_data=["species"],
),
actions=[
set_control(control="filter_interactions", value="species"),
vm.Action(
function=scatter_click_data_custom_action(),
inputs=[f"{cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID}.clickData"],
outputs=f"{cnst.CARD_SET_CONTROL_INTERACTIONS_ID}",
),
],
),
vm.Card(id=cnst.CARD_SET_CONTROL_INTERACTIONS_ID, text="### No data clicked."),
vm.Graph(
id=cnst.BOX_SET_CONTROL_INTERACTIONS_ID,
figure=px.box(
iris,
x="sepal_length",
y="petal_width",
color="species",
),
),
components=[
vm.Graph(
id=cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID,
figure=px.scatter(
iris,
x="sepal_length",
y="petal_width",
color="species",
custom_data=["species"],
),
actions=[
set_control(control="filter_interactions", value="species"),
vm.Action(
function=scatter_click_data_custom_action(),
inputs=[f"{cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID}.clickData"],
outputs=f"{cnst.CARD_SET_CONTROL_INTERACTIONS_ID}",
),
],
),
vm.Graph(
id=cnst.BOX_SET_CONTROL_INTERACTIONS_ID,
figure=px.box(
iris,
x="sepal_length",
y="petal_width",
color="species",
),
),
vm.Card(id=cnst.CARD_SET_CONTROL_INTERACTIONS_ID, text="### No data clicked."),

Comment on lines +53 to +56
vm.Parameter(
targets=[f"{cnst.BOX_SET_CONTROL_INTERACTIONS_ID}.title"],
selector=vm.RadioItems(id=cnst.RADIOITEM_SET_CONTROL_INTER_PARAM, options=["red", "blue"], value="blue"),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this if it's not changed using the set_control?

Comment on lines +28 to +35
vm.Action(
function=scatter_click_data_custom_action(),
inputs=[f"{cnst.SCATTER_SET_CONTROL_INTERACTIONS_ID}.clickData"],
outputs=f"{cnst.CARD_SET_CONTROL_INTERACTIONS_ID}",
),
],
),
vm.Card(id=cnst.CARD_SET_CONTROL_INTERACTIONS_ID, text="### No data clicked."),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Comment on lines +94 to +98
vm.Filter(
column="year",
targets=[cnst.SET_CONTROL_TABLE_AG_GRID_INTERACTIONS_ID],
selector=vm.Dropdown(value=2007),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still have this filter if it’s not affected by set_control? If it’s redundant, we should remove it.

The set_control tests will be expanding soon, so it’s important to keep things as simple as possible. Could you simplify these pages and tests accordingly, and make sure all similar pages follow the same structure (same for tests)? That way, it’ll be easier to adjust them later if needed.

Comment on lines +83 to +85
controls=[
vm.Filter(column="species", selector=vm.Dropdown(value="virginica")),
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can remove this, so this page is aligned structurally with drill_through_parameter_page_1 and drill_through_filter_page_1.

Comment on lines +77 to +119
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_set_control_filter_interactions_graph(dash_br):
"""Test filter interactions between two graphs."""
accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION)
page_select(
dash_br,
page_name=cnst.SET_CONTROL_GRAPH_INTERACTIONS_PAGE,
)

# select 'versicolor' in dropdown filter and check result for box graph
clear_dropdown(dash_br, cnst.DROPDOWN_SET_CONTROL_INTER_FILTER)
select_dropdown_value(dash_br, dropdown_id=cnst.DROPDOWN_SET_CONTROL_INTER_FILTER, value="versicolor")
# Check y axis max value is '1.8'
dash_br.wait_for_text_to_equal(
graph_axis_value_path(graph_id=cnst.BOX_SET_CONTROL_INTERACTIONS_ID, axis_value_number="5", axis_value="1.8"),
"1.8",
)

# click on the 'setosa' data in scatter graph and check result for box graph
dash_br.click_at_coord_fractions("#scatter_set_control_inter path:nth-of-type(20)", 0, 1)
# Check y axis max value is '0.6'
dash_br.wait_for_text_to_equal(
graph_axis_value_path(graph_id=cnst.BOX_SET_CONTROL_INTERACTIONS_ID, axis_value_number="3", axis_value="0.6"),
"0.6",
)

# open dropdown and check values
dash_br.multiple_click(dropdown_arrow_path(dropdown_id=cnst.DROPDOWN_SET_CONTROL_INTER_FILTER), 1)
check_selected_dropdown(
dash_br,
dropdown_id=cnst.DROPDOWN_SET_CONTROL_INTER_FILTER,
all_value=False,
expected_selected_options=["setosa"],
expected_unselected_options=["SelectAll", "versicolor", "virginica"],
)
# close dropdown
dash_br.multiple_click(dropdown_arrow_path(dropdown_id=cnst.DROPDOWN_SET_CONTROL_INTER_FILTER), 1)

# select 'red' title for the box graph
dash_br.multiple_click(
categorical_components_value_path(elem_id=cnst.RADIOITEM_SET_CONTROL_INTER_PARAM, value=1), 1
)
dash_br.wait_for_text_to_equal(".gtitle", "red")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I already mentioned above, let's streamline the pages and tests. So, in this case I would skip several steps and only:

  1. open the relevant page
  2. click on the versicolor point on the source graph
  3. check the targeted control options/value (could be skipped as well)
  4. check the targeted graph layout.

Comment on lines +122 to +147
def test_set_control_filter_interactions_ag_grid(dash_br):
"""Test filter interaction between ag_grid and line graph."""
accordion_select(dash_br, accordion_name=cnst.ACTIONS_ACCORDION)
page_select(
dash_br,
page_name=cnst.SET_CONTROL_TABLE_AG_GRID_INTERACTIONS_PAGE,
)

# check if column 'country' is available
dash_br.wait_for_element(
f"div[id='{cnst.SET_CONTROL_TABLE_AG_GRID_INTERACTIONS_ID}'] div:nth-of-type(1) div[col-id='country']"
)

# click on Albania country
dash_br.multiple_click(
f"div[id='{cnst.SET_CONTROL_TABLE_AG_GRID_INTERACTIONS_ID}'] div[class='ag-center-cols-container'] "
f"div:nth-of-type(2) div[col-id='country']",
1,
)
# Check y axis max value is '40k'
dash_br.wait_for_text_to_equal(
graph_axis_value_path(
graph_id=cnst.SET_CONTROL_LINE_AG_GRID_INTERACTIONS_ID, axis_value_number="6", axis_value="50k"
),
"50k",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a great example of a simple test! 🚀 As I mentioned in the comment above, it's maybe worth to check that the targeted filter value is the right one.

Comment on lines +157 to +158
# click on the 'setosa' data in scatter graph
dash_br.click_at_coord_fractions(f"#{cnst.SCATTER_FILTER_DRILL_THROUGH_SOURCE_ID} path:nth-of-type(20)", 0, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if you click on the "versicolor" graph's point here and in the test_parameter_drill_through especially. For some controls the "setosa" is already set by default (like for the radio_items tested in test_parameter_drill_through).

edit: Same for all tests added in this PR.

Comment on lines +162 to +171
check_selected_categorical_component(
dash_br,
component_id=cnst.CHECKLIST_FILTER_DRILL_THROUGH_ID,
select_all_status=False,
options_value_status=[
{"value": 1, "selected": True, "value_name": "setosa"},
{"value": 2, "selected": False, "value_name": "versicolor"},
{"value": 3, "selected": False, "value_name": "virginica"},
],
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also make a check of the x-axis or something else to prove that the filter/parameter on the targeted page is properly applied? (Same for all drill-through tests)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work! The filte/parameter interaction and drill-through are coverer excellently!

If it's not that hard, would you mind adding two more use cases:

  • chaining two set_control actions on the same page
  • graph drill-down (set_control) where the source and the target graph is the same

If you find some of these two cases too complicate, then I'm totally fine to skip it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants