|
| 1 | +import pytest |
| 2 | +import dash |
| 3 | +from dash.dependencies import Input, Output |
| 4 | +import dash_core_components as dcc |
| 5 | +import dash_html_components as html |
| 6 | + |
| 7 | + |
| 8 | +@pytest.mark.DCC782 |
| 9 | +def test_lipa001_path(dash_dcc): |
| 10 | + app = dash.Dash(__name__) |
| 11 | + app.layout = html.Div( |
| 12 | + [ |
| 13 | + dcc.Link("Relative Path", id="link1", href="google.com"), |
| 14 | + dcc.Location(id="url", refresh=False), |
| 15 | + html.Div(id="content") |
| 16 | + ] |
| 17 | + ) |
| 18 | + @app.callback(Output("content", "children"), [Input("url", "pathname")]) |
| 19 | + def display_children(children): |
| 20 | + return children |
| 21 | + |
| 22 | + dash_dcc.start_server(app) |
| 23 | + |
| 24 | + dash_dcc.wait_for_element('#link1').click() |
| 25 | + |
| 26 | + dash_dcc.wait_for_text_to_equal("#content", "/google.com") |
| 27 | + |
| 28 | + |
| 29 | +@pytest.mark.DCC782 |
| 30 | +def test_lipa002_path(dash_dcc): |
| 31 | + app = dash.Dash(__name__) |
| 32 | + app.layout = html.Div( |
| 33 | + [ |
| 34 | + dcc.Link(children='Absolute Path', id="link1", href="https://google.com", refresh=True), |
| 35 | + dcc.Location(id="url", refresh=False) |
| 36 | + ] |
| 37 | + ) |
| 38 | + dash_dcc.start_server(app) |
| 39 | + |
| 40 | + dash_dcc.wait_for_element('#link1').click() |
| 41 | + |
| 42 | + location = dash_dcc.driver.execute_script( |
| 43 | + ''' |
| 44 | + return window.location.href |
| 45 | + ''' |
| 46 | + ) |
| 47 | + |
| 48 | + assert location == 'https://www.google.com/' |
0 commit comments