Skip to content

Commit bfa73a7

Browse files
committed
add crystal_toolkit/apps/examples/tests/test_diffraction.py
1 parent 271c9a9 commit bfa73a7

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

crystal_toolkit/apps/examples/tests/test_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_hello_scientist(dash_duo: DashDuo):
1818
dash_duo.percy_snapshot("hello_scientist")
1919

2020
logs = dash_duo.get_logs()
21-
assert logs == [], f"Browser console contains an error: {logs}"
21+
assert logs == [], f"Browser console should not contain errors: {logs}"
2222

2323

2424
def test_hello_structure(dash_duo: DashDuo) -> None:
@@ -29,7 +29,7 @@ def test_hello_structure(dash_duo: DashDuo) -> None:
2929
dash_duo.percy_snapshot("hello_structure")
3030

3131
logs = dash_duo.get_logs()
32-
assert logs == [], f"Browser console contains an error: {logs}"
32+
assert logs == [], f"Browser console should not contain errors: {logs}"
3333

3434

3535
def test_hello_structure_interactive(dash_duo: DashDuo) -> None:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from time import sleep
2+
3+
from selenium.webdriver.common.keys import Keys
4+
5+
from crystal_toolkit.apps.examples.diffraction import app
6+
from crystal_toolkit.apps.examples.tests.typing import DashDuo
7+
8+
9+
def test_diffraction(dash_duo: DashDuo) -> None:
10+
11+
dash_duo.start_server(app)
12+
dash_duo.clear_storage()
13+
14+
# make sure the XRD component was mounted and is a node with class 'dash-graph'
15+
node = dash_duo.find_element("#CTXRayDiffractionComponent_xrd-plot")
16+
assert "dash-graph" in node.get_attribute("class")
17+
18+
sleep(1)
19+
# select 'Shape Factor' and 'Peak Profile' inputs and increment their values
20+
# to ensure they throw no errors
21+
input_nodes = dash_duo.find_elements("input[type=number]")
22+
input_nodes[0].send_keys(Keys.ARROW_UP)
23+
sleep(1)
24+
input_nodes[1].send_keys(Keys.ARROW_UP)
25+
sleep(1)
26+
# focus the other input since component only updates on blur
27+
input_nodes[0].send_keys(Keys.ARROW_UP)
28+
29+
logs = dash_duo.get_logs()
30+
assert logs == [], f"Browser console should not contain errors: {logs}"

crystal_toolkit/apps/examples/tests/test_structure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ def test_structure(dash_duo: DashDuo) -> None:
3232
sleep(1)
3333

3434
logs = dash_duo.get_logs()
35-
assert logs == [], f"Browser console contains an error: {logs}"
35+
assert logs == [], f"Browser console should not contain errors: {logs}"

crystal_toolkit/apps/examples/tests/typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class DashDuo(Protocol):
1313
See https://dash.plotly.com/testing#browser-apis
1414
"""
1515

16+
# driver = ... # selenium.webdriver.remote.WebDriver
17+
1618
def start_server(self, start_server) -> None:
1719
...
1820

crystal_toolkit/apps/tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def test_main_app_startup(dash_duo: DashDuo):
1717

1818
assert (
1919
dash_duo.get_logs() == []
20-
), f"Browser console contains an error: {dash_duo.get_logs()}"
20+
), f"Browser console should not contain errors: {dash_duo.get_logs()}"

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ ignore = E203,E731,W503
77
per-file-ignores =
88
# F401: imported but unused
99
__init__.py: F401
10+
11+
[tool:pytest]
12+
addopts = -p no:warnings

0 commit comments

Comments
 (0)