Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dash_globe/tests/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_gallery_footer_uses_html_instead_of_markdown():
footer = usage.build_gallery_footer()

assert footer.id == "gallery-footer"
assert footer.__class__.__name__ == "P"
assert footer.__class__.__name__ == "Alert"
assert not any(component.__class__.__name__ == "Markdown" for component in _walk_components(usage.app.layout))


Expand Down Expand Up @@ -459,7 +459,10 @@ def test_render_component_gallery(dash_duo):
assert dash_duo.find_element("#choropleth-countries-globe canvas")

choropleth_event = "#choropleth-countries-event"
placeholder_text = "Click Run to mount this globe, then hover a country to inspect the latest hover payload."
choropleth_idle_texts = {
usage.CHOROPLETH_COUNTRIES_EVENT_PLACEHOLDER,
usage.CHOROPLETH_COUNTRIES_HOVER_IDLE_TEXT,
}
canvas = dash_duo.find_element("#choropleth-countries-globe canvas")
dash_duo.driver.execute_script("arguments[0].scrollIntoView({block: 'center'});", canvas)
canvas_rect = canvas.rect
Expand All @@ -481,11 +484,11 @@ def test_render_component_gallery(dash_duo):
ActionChains(dash_duo.driver).move_to_element_with_offset(canvas, x_offset, y_offset).perform()
time.sleep(0.35)
hovered_payload = dash_duo.find_element(choropleth_event).text
if hovered_payload != placeholder_text and '"layer": "polygon"' in hovered_payload:
if '"layer": "polygon"' in hovered_payload:
break

assert hovered_payload is not None
assert hovered_payload != placeholder_text
assert hovered_payload not in choropleth_idle_texts
assert '"layer": "polygon"' in hovered_payload

time.sleep(0.9)
Expand Down
10 changes: 8 additions & 2 deletions dash_globe/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,12 @@ def build_situation_room_selection_signature(snapshots):
"https://raw.githubusercontent.com/vasturiano/react-globe.gl/master/example/datasets/"
"ne_110m_admin_0_countries.geojson"
)
CHOROPLETH_COUNTRIES_EVENT_PLACEHOLDER = (
"Click Run to mount this globe, then hover a country to inspect the latest payload."
)
CHOROPLETH_COUNTRIES_HOVER_IDLE_TEXT = (
"Hover a country to highlight it and inspect the latest hover payload."
)
CHOROPLETH_BACKGROUND_IMAGE_URL = "https://unpkg.com/three-globe@2.45.2/example/img/night-sky.png"
CHOROPLETH_PALETTE = ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#f03b20", "#bd0026"]
AIRLINE_ROUTE_COUNTRY = "Portugal"
Expand Down Expand Up @@ -3979,7 +3985,7 @@ def build_examples_grid():
example_code_and_events(
CHOROPLETH_COUNTRIES_EXAMPLE_CODE,
event_id="choropleth-countries-event",
event_placeholder="Click Run to mount this globe, then hover a country to inspect the latest payload.",
event_placeholder=CHOROPLETH_COUNTRIES_EVENT_PLACEHOLDER,
),
),
globe_card(
Expand Down Expand Up @@ -4264,7 +4270,7 @@ def highlight_airline_routes(hover_data):
Input("choropleth-countries-globe", "hoverData"),
)
def highlight_choropleth_country(hover_data):
payload_text = "Hover a country to highlight it and inspect the latest hover payload."
payload_text = CHOROPLETH_COUNTRIES_HOVER_IDLE_TEXT
if hover_data is not None:
payload_text = json.dumps(hover_data, indent=2)

Expand Down