-
-
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.
Merge pull request #3000 from plotly/master-2.18.1
Master 2.18.1
- Loading branch information
Showing
13 changed files
with
1,504 additions
and
1,188 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
57 changes: 20 additions & 37 deletions
57
components/dash-core-components/tests/integration/location/test_location_logout.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 |
---|---|---|
@@ -1,47 +1,30 @@ | ||
from dash.exceptions import PreventUpdate | ||
from dash import Dash, Input, Output, dcc, html | ||
import flask | ||
import pytest | ||
import time | ||
|
||
|
||
def test_llgo001_location_logout(dash_dcc): | ||
@pytest.mark.parametrize("add_initial_logout_button", [False, True]) | ||
def test_llgo001_location_logout(dash_dcc, add_initial_logout_button): | ||
# FIXME: Logout button is deprecated, remove this test for dash 3.0 | ||
app = Dash(__name__) | ||
|
||
@app.server.route("/_logout", methods=["POST"]) | ||
def on_logout(): | ||
rep = flask.redirect("/logged-out") | ||
rep.set_cookie("logout-cookie", "", 0) | ||
return rep | ||
|
||
app.layout = html.Div( | ||
[html.H2("Logout test"), dcc.Location(id="location"), html.Div(id="content")] | ||
) | ||
|
||
@app.callback(Output("content", "children"), [Input("location", "pathname")]) | ||
def on_location(location_path): | ||
if location_path is None: | ||
raise PreventUpdate | ||
|
||
if "logged-out" in location_path: | ||
return "Logged out" | ||
with pytest.warns( | ||
DeprecationWarning, | ||
match="The Logout Button is no longer used with Dash Enterprise and can be replaced with a html.Button or html.A.", | ||
): | ||
app.layout = [ | ||
html.H2("Logout test"), | ||
html.Div(id="content"), | ||
] | ||
if add_initial_logout_button: | ||
app.layout.append(dcc.LogoutButton()) | ||
else: | ||
|
||
@flask.after_this_request | ||
def _insert_cookie(rep): | ||
rep.set_cookie("logout-cookie", "logged-in") | ||
return rep | ||
|
||
return dcc.LogoutButton(id="logout-btn", logout_url="/_logout") | ||
|
||
dash_dcc.start_server(app) | ||
time.sleep(1) | ||
dash_dcc.percy_snapshot("Core Logout button") | ||
|
||
assert dash_dcc.driver.get_cookie("logout-cookie")["value"] == "logged-in" | ||
|
||
dash_dcc.wait_for_element("#logout-btn").click() | ||
dash_dcc.wait_for_text_to_equal("#content", "Logged out") | ||
@app.callback(Output("content", "children"), Input("content", "id")) | ||
def on_location(location_path): | ||
return dcc.LogoutButton(id="logout-btn", logout_url="/_logout") | ||
|
||
assert not dash_dcc.driver.get_cookie("logout-cookie") | ||
dash_dcc.start_server(app) | ||
time.sleep(1) | ||
|
||
assert dash_dcc.get_logs() == [] | ||
assert dash_dcc.get_logs() == [] |
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
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
Oops, something went wrong.