Skip to content

Commit

Permalink
Merge pull request #2006 from plotly/fix-ci
Browse files Browse the repository at this point in the history
Fix ci failures
  • Loading branch information
alexcjohnson authored Apr 13, 2022
2 parents f6abdfb + aea397b commit adb6db7
Show file tree
Hide file tree
Showing 33 changed files with 360 additions and 257 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ jobs:
. venv/bin/activate && rm -rf components/dash-core-components/dash_core_components
cd components/dash-core-components
TESTFILES=$(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml --junitprefix="components.dash-core-components" ${TESTFILES}
pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml --junitprefix="components.dash-core-components" ${TESTFILES} --reruns 3
- store_artifacts:
path: ~/dash/components/dash-core-components/test-reports
- store_test_results:
Expand Down
2 changes: 1 addition & 1 deletion components/dash-core-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"private::lint.prettier": "prettier --config .prettierrc src/**/*.js --list-different",
"prepublishOnly": "rm -rf lib && babel src --out-dir lib --copy-files && rm -rf lib/jl/ lib/*.jl",
"test": "run-s -c lint test:intg test:pyimport",
"test:intg": "pytest --nopercyfinalize --headless tests/integration",
"test:intg": "pytest --nopercyfinalize --headless tests/integration --reruns 3",
"test:pyimport": "python -m unittest tests/test_dash_import.py",
"prebuild:js": "cp node_modules/plotly.js-dist-min/plotly.min.js dash_core_components_base/plotly.min.js && cp node_modules/mathjax/es5/tex-svg.js dash_core_components_base/mathjax.js",
"build:js": "webpack --mode production",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import datetime, timedelta

import pytest
import werkzeug

from dash import Dash, Input, Output, html, dcc, no_update


Expand Down Expand Up @@ -71,6 +73,11 @@ def test_dtps010_local_and_session_persistence(dash_dcc):
assert dash_dcc.get_logs() == []


@pytest.mark.xfail(
condition=werkzeug.__version__ in ("2.1.0", "2.1.1"),
reason="Bug with 204 and Transfer-Encoding",
strict=False,
)
def test_dtps011_memory_persistence(dash_dcc):
app = Dash(__name__)
app.layout = html.Div(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def update_options(search_value):
dash_dcc.start_server(app)

# Get the inner input used for search value.
dropdown = dash_dcc.find_element("#my-dynamic-dropdown")
input_ = dropdown.find_element_by_css_selector("input")
input_ = dash_dcc.find_element("#my-dynamic-dropdown input")

# Focus on the input to open the options menu
input_.send_keys("x")
Expand All @@ -36,15 +35,15 @@ def update_options(search_value):
input_.clear()
input_.send_keys("o")

options = dropdown.find_elements_by_css_selector(".VirtualizedSelectOption")
options = dash_dcc.find_elements("#my-dynamic-dropdown .VirtualizedSelectOption")

# Should show all options.
assert len(options) == 3

# Searching for `on`
input_.send_keys("n")

options = dropdown.find_elements_by_css_selector(".VirtualizedSelectOption")
options = dash_dcc.find_elements("#my-dynamic-dropdown .VirtualizedSelectOption")

assert len(options) == 1
print(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import pytest
import time
import json

import werkzeug

from dash import Dash, Input, Output, State, dcc, html
from dash.exceptions import PreventUpdate
from selenium.webdriver.common.by import By
Expand Down Expand Up @@ -128,7 +131,7 @@ def show_relayout_data(data):

# use this opportunity to test restyleData, since there are multiple
# traces on this graph
legendToggle = dash_dcc.driver.find_element_by_css_selector(
legendToggle = dash_dcc.find_element(
"#example-graph .traces:first-child .legendtoggle"
)
legendToggle.click()
Expand All @@ -142,7 +145,7 @@ def show_relayout_data(data):
)

# and test relayoutData while we're at it
autoscale = dash_dcc.driver.find_element_by_css_selector("#example-graph .ewdrag")
autoscale = dash_dcc.find_element("#example-graph .ewdrag")
autoscale.click()
autoscale.click()
dash_dcc.wait_for_text_to_equal("#relayout-data", '{"xaxis.autorange": true}')
Expand Down Expand Up @@ -185,6 +188,10 @@ def render_content(click, prev_graph):
assert dash_dcc.get_logs() == []


@pytest.mark.skipif(
werkzeug.__version__ in ("2.1.0", "2.1.1"),
reason="Bug with no_update 204 responses get Transfer-Encoding header.",
)
@pytest.mark.parametrize("is_eager", [True, False])
def test_grva004_graph_prepend_trace(dash_dcc, is_eager):
app = Dash(__name__, eager_loading=is_eager)
Expand Down Expand Up @@ -357,6 +364,10 @@ def display_data(trigger, fig):
assert dash_dcc.get_logs() == []


@pytest.mark.skipif(
werkzeug.__version__ in ("2.1.0", "2.1.1"),
reason="Bug with no_update 204 responses get Transfer-Encoding header.",
)
@pytest.mark.parametrize("is_eager", [True, False])
def test_grva005_graph_extend_trace(dash_dcc, is_eager):
app = Dash(__name__, eager_loading=is_eager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def extras(t):
dcc.Link(
children="Absolute Path",
id="link1",
href=dash_dcc.server.url + "/extra/eseehc",
href="/extra/eseehc",
refresh=True,
),
dcc.Location(id="url", refresh=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def display_page(pathname):
dash_dcc.wait_for_text_to_equal("#page-content", "You are on page /test-link")

wait.until(
lambda: test_link.get_attribute("href") == "http://localhost:8050/test-link", 3
lambda: test_link.get_attribute("href")
== "http://localhost:{}/test-link".format(dash_dcc.server.port),
3,
)
wait.until(lambda: call_count.value == 2, 3)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def update_pathname(n_clicks, current_pathname):
# Check that link updates pathname
dash_dcc.find_element("#test-link").click()
until(
lambda: dash_dcc.driver.current_url.replace("http://localhost:8050", "")
lambda: dash_dcc.driver.current_url.replace(
"http://localhost:{}".format(dash_dcc.server.port), ""
)
== "/test/pathname",
3,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import pytest
import werkzeug

import dash.testing.wait as wait


@pytest.mark.xfail(
condition=werkzeug.__version__ in ("2.1.0", "2.1.1"),
reason="Bug with 204 and Transfer-Encoding",
strict=False,
)
def test_stdl001_data_lifecycle_with_different_condition(store_app, dash_dcc):
dash_dcc.start_server(store_app)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import werkzeug

from dash import Dash, Input, Output, dcc, html
from dash.exceptions import PreventUpdate
import json
Expand Down Expand Up @@ -119,6 +121,11 @@ def render_content(tab):
assert dash_dcc.get_logs() == []


@pytest.mark.xfail(
condition=werkzeug.__version__ in ("2.1.0", "2.1.1"),
reason="Bug with 204 and Transfer-Encoding",
strict=False,
)
@pytest.mark.parametrize("is_eager", [True, False])
def test_tabs_render_without_selected(dash_dcc, is_eager):
app = Dash(__name__, eager_loading=is_eager)
Expand Down
30 changes: 18 additions & 12 deletions components/dash-html-components/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ def test_click_simple(dash_duo):
]
)

@app.callback(Output("container", "children"), Input("button", "n_clicks"))
@app.callback(
Output("container", "children"),
Input("button", "n_clicks"),
# The new percy runner loads the page, so to get consistent behavior for
# call_count we need to skip the initial call
prevent_initial_call=True,
)
def update_output(n_clicks):
call_count.value += 1
return "clicked {} times".format(n_clicks)
Expand All @@ -25,14 +31,13 @@ def update_output(n_clicks):

dash_duo.find_element("#container")

dash_duo.wait_for_text_to_equal("#container", "clicked 0 times")
assert call_count.value == 1
assert call_count.value == 0
dash_duo.percy_snapshot("html button initialization")

dash_duo.find_element("#button").click()

dash_duo.wait_for_text_to_equal("#container", "clicked 1 times")
assert call_count.value == 2
assert call_count.value == 1
dash_duo.percy_snapshot("html button click")

assert not dash_duo.get_logs()
Expand All @@ -49,7 +54,7 @@ def test_click_prev(dash_duo):
app = Dash(__name__)
app.layout = html.Div(
[
html.Div(id="container"),
html.Div("Initial", id="container"),
html.Button("Click", id="button-1", n_clicks=0, n_clicks_timestamp=-1),
html.Button("Click", id="button-2", n_clicks=0, n_clicks_timestamp=-1),
]
Expand All @@ -63,6 +68,7 @@ def test_click_prev(dash_duo):
Input("button-2", "n_clicks"),
Input("button-2", "n_clicks_timestamp"),
],
prevent_initial_call=True,
)
def update_output(*args):
print(args)
Expand All @@ -73,25 +79,25 @@ def update_output(*args):

dash_duo.start_server(app)

dash_duo.wait_for_text_to_equal("#container", "0, 0")
assert timestamp_1.value == -1
assert timestamp_2.value == -1
assert call_count.value == 1
dash_duo.wait_for_text_to_equal("#container", "Initial")
assert timestamp_1.value == -5
assert timestamp_2.value == -5
assert call_count.value == 0
dash_duo.percy_snapshot("html button initialization 1")

dash_duo.find_element("#button-1").click()
dash_duo.wait_for_text_to_equal("#container", "1, 0")
assert timestamp_1.value > ((time.time() - (24 * 60 * 60)) * 1000)
assert timestamp_2.value == -1
assert call_count.value == 2
assert call_count.value == 1
dash_duo.percy_snapshot("html button-1 click")
prev_timestamp_1 = timestamp_1.value

dash_duo.find_element("#button-2").click()
dash_duo.wait_for_text_to_equal("#container", "1, 1")
assert timestamp_1.value == prev_timestamp_1
assert timestamp_2.value > ((time.time() - 24 * 60 * 60) * 1000)
assert call_count.value == 3
assert call_count.value == 2
dash_duo.percy_snapshot("html button-2 click")
prev_timestamp_2 = timestamp_2.value

Expand All @@ -100,7 +106,7 @@ def update_output(*args):
assert timestamp_1.value == prev_timestamp_1
assert timestamp_2.value > prev_timestamp_2
assert timestamp_2.value > timestamp_1.value
assert call_count.value == 4
assert call_count.value == 3
dash_duo.percy_snapshot("html button-2 click again")

assert not dash_duo.get_logs()
Loading

0 comments on commit adb6db7

Please sign in to comment.