Skip to content

Commit 3a10ab9

Browse files
author
Oliver Flasch
committed
first test
1 parent c99dfe1 commit 3a10ab9

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ Pull requests are welcome.
2525
Please see https://github.com/plotly/dash-component-boilerplate for information on the architecture of Dash components.
2626

2727

28+
## Testing
29+
30+
dash-coreui-components comes with integration tests in the `tests/` folder.
31+
Install the test requirements with `pip install -r tests/requirements.txt`.
32+
33+
To run the tests, use `pytest --driver Chrome tests/` or simply `test_usage_py.sh`.
34+
Other drivers (IE, Firefox) can also be used.
35+
36+
2837
## Creating and Publishing Production Builds
2938

3039
Run `make_python_dist.sh` to create a Python package tarball.

test_usage_py.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
clear
4+
pytest --driver Chrome tests/
5+

tests/test_usage.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1+
import pytest
12
from pytest_dash.utils import (
23
import_app,
34
wait_for_text_to_equal,
45
wait_for_element_by_css_selector
56
)
7+
from selenium.webdriver.support.ui import Select
68

79

8-
# Basic test for the component rendering.
9-
def test_render_component(dash_threaded, selenium):
10+
@pytest.fixture
11+
def usage_app(dash_threaded):
1012
# Start a dash app contained in `usage.py`
1113
# dash_threaded is a fixture by pytest-dash
1214
# It will load a py file containing a Dash instance named `app`
1315
# and start it in a thread.
1416
app = import_app('usage')
1517
dash_threaded(app)
18+
return app
1619

17-
# Get the generated component input with selenium
18-
# The html input will be a children of the #input dash component
19-
my_component = wait_for_element_by_css_selector(selenium, '#input > input')
20+
def test_dashboard_test_textarea(usage_app, selenium):
21+
dashboard_test_textarea = wait_for_element_by_css_selector(selenium, '#dashboard-test-textarea')
22+
assert 'Hello, world!' == dashboard_test_textarea.get_attribute('value')
23+
dashboard_test_textarea.send_keys('TEST')
24+
wait_for_text_to_equal(selenium, '#dashboard-test-output',
25+
'You have entered "Hello, world!TEST". You selected None in the aside dropdown and the aside slider sits at 3.')
2026

21-
assert 'my-value' == my_component.get_attribute('value')
22-
23-
# Clear the input
24-
my_component.clear()
25-
26-
# Send keys to the custom input.
27-
my_component.send_keys('Hello dash')
28-
29-
# Wait for the text to equal, if after the timeout (default 10 seconds)
30-
# the text is not equal it will fail the test.
31-
wait_for_text_to_equal(selenium, '#output', 'You have entered Hello dash')

0 commit comments

Comments
 (0)