-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Checklist and RadioItems labels with titles
- Loading branch information
Showing
4 changed files
with
79 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...onents/tests/integration/dropdown/test_dropdown_radioitems_checklist_option_title_prop.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# -*- coding: UTF-8 -*- | ||
|
||
import pytest | ||
from dash.testing import wait | ||
from dash import Dash, Input, Output, dcc, html | ||
|
||
|
||
@pytest.mark.DCC793 | ||
@pytest.mark.parametrize("component_type,component_kwargs,selector_class_name", [ | ||
(dcc.Dropdown, {"multi": True, "value": "NYC"}, "Select-value"), | ||
(dcc.Dropdown, {"multi": False, "value": "NYC"}, "Select-value"), | ||
(dcc.Checklist, {"value": ["NYC"], "labelClassName": "Select-value-label"}, "Select-value-label"), | ||
(dcc.RadioItems, {"value": "NYC", "labelClassName": "Select-value-label"}, "Select-value-label"), | ||
]) | ||
def test_ddot001_dropdown_radioitems_checklist_option_title(dash_dcc, component_type, component_kwargs, selector_class_name): | ||
app = Dash(__name__) | ||
|
||
id_prefix = component_type.__name__.lower() | ||
|
||
app.layout = html.Div( | ||
[ | ||
dcc.Input( | ||
id=f"{id_prefix}_title_input", | ||
type="text", | ||
placeholder="Enter a title for New York City", | ||
), | ||
component_type( | ||
id=id_prefix, | ||
options=[ | ||
{"label": "New York City", "value": "NYC"}, | ||
{"label": "Montréal", "value": "MTL"}, | ||
{"label": "San Francisco", "value": "SF"}, | ||
], | ||
**component_kwargs | ||
), | ||
] | ||
) | ||
|
||
@app.callback( | ||
Output(id_prefix, "options"), [Input(f"{id_prefix}_title_input", "value")] | ||
) | ||
def add_title_to_option(title): | ||
return [ | ||
{"label": "New York City", "title": title, "value": "NYC"}, | ||
{"label": "Montréal", "value": "MTL"}, | ||
{"label": "San Francisco", "value": "SF"}, | ||
] | ||
|
||
dash_dcc.start_server(app) | ||
|
||
component_option_element = dash_dcc.wait_for_element(f"#{id_prefix} .{selector_class_name}") | ||
|
||
component_title_input = dash_dcc.wait_for_element(f"#{id_prefix}_title_input") | ||
|
||
# Empty string title ('') (default for no title) | ||
|
||
wait.until(lambda: component_option_element.get_attribute("title") == "", 3) | ||
|
||
component_title_input.send_keys("The Big Apple") | ||
|
||
wait.until( | ||
lambda: component_option_element.get_attribute("title") == "The Big Apple", 3 | ||
) | ||
|
||
dash_dcc.clear_input(component_title_input) | ||
|
||
component_title_input.send_keys("Gotham City?") | ||
|
||
wait.until( | ||
lambda: component_option_element.get_attribute("title") == "Gotham City?", 3 | ||
) | ||
|
||
dash_dcc.clear_input(component_title_input) | ||
|
||
wait.until(lambda: component_option_element.get_attribute("title") == "", 3) | ||
|
||
assert dash_dcc.get_logs() == [] |
70 changes: 0 additions & 70 deletions
70
components/dash-core-components/tests/integration/dropdown/test_option_title_prop.py
This file was deleted.
Oops, something went wrong.