This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #640 - tooltip.always_visible for slider and rangeslider
- Loading branch information
1 parent
61f5f50
commit eb3be14
Showing
8 changed files
with
97 additions
and
38 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
Empty file.
Empty file.
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
Empty file.
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,62 @@ | ||
import dash | ||
from dash.dependencies import Input, Output | ||
import dash_html_components as html | ||
import dash_core_components as dcc | ||
|
||
from ..utils import click_at_coord_fractions | ||
|
||
|
||
def test_slsl001_always_visible_slider(dash_duo): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div([ | ||
dcc.Slider( | ||
id="slider", | ||
min=0, | ||
max=20, | ||
step=1, | ||
value=5, | ||
tooltip={"always_visible": True} | ||
), | ||
html.Div(id="out") | ||
]) | ||
|
||
@app.callback(Output("out", "children"), [Input("slider", "value")]) | ||
def update_output(value): | ||
return "You have selected {}".format(value) | ||
|
||
dash_duo.start_server(app) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 5") | ||
|
||
slider = dash_duo.find_element("#slider") | ||
click_at_coord_fractions(dash_duo, slider, 0.5, 0.5) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 10") | ||
click_at_coord_fractions(dash_duo, slider, 0.75, 0.5) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 15") | ||
|
||
|
||
def test_slsl002_always_visible_rangeslider(dash_duo): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div([ | ||
dcc.RangeSlider( | ||
id="rangeslider", | ||
min=0, | ||
max=20, | ||
step=1, | ||
value=[5, 15], | ||
tooltip={"always_visible": True} | ||
), | ||
html.Div(id="out") | ||
]) | ||
|
||
@app.callback(Output("out", "children"), [Input("rangeslider", "value")]) | ||
def update_output(rng): | ||
return "You have selected {}-{}".format(*rng) | ||
|
||
dash_duo.start_server(app) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 5-15") | ||
|
||
slider = dash_duo.find_element("#rangeslider") | ||
click_at_coord_fractions(dash_duo, slider, 0.1, 0.5) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 2-15") | ||
click_at_coord_fractions(dash_duo, slider, 0.5, 0.5) | ||
dash_duo.wait_for_text_to_equal("#out", "You have selected 2-10") |
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,28 @@ | ||
from selenium.webdriver.common.action_chains import ActionChains | ||
|
||
|
||
def click_date(dash_duo, component_selector, row, col): | ||
date_picker_selector = ( | ||
".CalendarMonthGrid_month__horizontal" | ||
":not(.CalendarMonthGrid_month__hidden)" | ||
) | ||
dash_duo.find_element( | ||
" ".join([ | ||
component_selector, | ||
date_picker_selector, | ||
# nth-child is 1-based, but let's use 0-based | ||
"tr:nth-child({})".format(row + 1), | ||
"td:nth-child({})".format(col + 1) | ||
]) | ||
).click() | ||
|
||
|
||
def click_at_coord_fractions(dash_duo, el, fx, fy): | ||
width = el.size['width'] | ||
height = el.size['height'] | ||
( | ||
ActionChains(dash_duo.driver) | ||
.move_to_element_with_offset(el, width * fx, height * fy) | ||
.click() | ||
.perform() | ||
) |