|
1 |
| -import time |
| 1 | +from time import sleep |
2 | 2 |
|
3 | 3 | from crystal_toolkit.apps.examples.structure import app
|
| 4 | +from crystal_toolkit.apps.examples.tests.typing import DashDuo |
4 | 5 |
|
5 | 6 |
|
6 |
| -def test_structure(dash_duo): |
| 7 | +def test_structure(dash_duo: DashDuo) -> None: |
7 | 8 |
|
8 | 9 | dash_duo.start_server(app)
|
9 | 10 | dash_duo.clear_storage()
|
10 | 11 |
|
11 |
| - time.sleep(5) |
12 | 12 | dash_duo.percy_snapshot("example_structure_on_load")
|
| 13 | + sleep(1) |
13 | 14 |
|
14 | 15 | # click the settings button (second button in the button-bar) to show the settings panel
|
15 | 16 | # and test the settings options.
|
16 |
| - dash_duo.find_elements(".mpc-button-bar .button")[1].click() |
| 17 | + dash_duo.find_element(".mpc-button-bar .button[data-for*=settings]").click() |
| 18 | + |
| 19 | + # make sure changing unit cell works |
| 20 | + for idx in range(3): |
| 21 | + dash_duo.select_dcc_dropdown("#CTmy_structure_unit-cell-choice", index=idx) |
| 22 | + dash_duo.percy_snapshot(f"example_structure_unit-cell_index_{idx}") |
17 | 23 |
|
18 | 24 | # test changing radius
|
19 |
| - el = dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=0) |
20 |
| - time.sleep(1) |
| 25 | + dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=0) |
21 | 26 | dash_duo.percy_snapshot("example_structure_radius_index_0")
|
| 27 | + sleep(1) |
22 | 28 |
|
23 | 29 | # test changing radius again
|
24 |
| - el = dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=2) |
25 |
| - time.sleep(1) |
| 30 | + dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=2) |
26 | 31 | dash_duo.percy_snapshot("example_structure_primitive_radius_index_2")
|
| 32 | + sleep(1) |
27 | 33 |
|
28 |
| - assert ( |
29 |
| - bool(dash_duo.get_logs()) is False |
30 |
| - ), f"Browser console contains an error: {dash_duo.get_logs()}" |
| 34 | + logs = dash_duo.get_logs() |
| 35 | + assert logs == [], f"Browser console contains an error: {logs}" |
0 commit comments