|
1 | | -from pytest_dash.utils import ( |
2 | | - import_app, |
3 | | - wait_for_text_to_equal, |
4 | | - wait_for_element_by_css_selector |
5 | | -) |
| 1 | +import os |
| 2 | +import importlib |
| 3 | +from .IntegrationTests import IntegrationTests |
| 4 | +from selenium.webdriver.common.by import By |
| 5 | +from selenium.webdriver.support.ui import WebDriverWait |
| 6 | +from selenium.webdriver.support import expected_conditions as EC |
6 | 7 |
|
7 | 8 |
|
8 | | -# Basic test for the component rendering. |
9 | | -def test_render_component(dash_threaded, selenium): |
10 | | - # Start a dash app contained in `usage.py` |
11 | | - # dash_threaded is a fixture by pytest-dash |
12 | | - # It will load a py file containing a Dash instance named `app` |
13 | | - # and start it in a thread. |
14 | | - app = import_app('usage') |
15 | | - dash_threaded(app) |
| 9 | +class Tests(IntegrationTests): |
| 10 | + def create_usage_test(self, filename): |
| 11 | + app = importlib.import_module(filename).app |
16 | 12 |
|
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') |
| 13 | + self.startServer(app) |
20 | 14 |
|
21 | | - assert 'my-value' == my_component.get_attribute('value') |
| 15 | + WebDriverWait(self.driver, 20).until( |
| 16 | + EC.presence_of_element_located((By.ID, "cytoscape")) |
| 17 | + ) |
22 | 18 |
|
23 | | - # Clear the input |
24 | | - my_component.clear() |
| 19 | + self.driver.save_screenshot(os.path.join( |
| 20 | + os.path.dirname(__file__), |
| 21 | + 'screenshots', |
| 22 | + filename + '.png' |
| 23 | + )) |
25 | 24 |
|
26 | | - # Send keys to the custom input. |
27 | | - my_component.send_keys('Hello dash') |
| 25 | + def test_usage_advanced(self): |
| 26 | + self.create_usage_test('usage-advanced') |
28 | 27 |
|
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') |
| 28 | + def test_usage_animated_bfs(self): |
| 29 | + self.create_usage_test('demos.usage-animated-bfs') |
| 30 | + |
| 31 | + def test_usage_breadthfirst_layout(self): |
| 32 | + self.create_usage_test('demos.usage-breadthfirst-layout') |
| 33 | + |
| 34 | + def test_usage_compound_nodes(self): |
| 35 | + self.create_usage_test('demos.usage-compound-nodes') |
| 36 | + |
| 37 | + def test_usage_events(self): |
| 38 | + self.create_usage_test('usage-events') |
| 39 | + |
| 40 | + def test_usage_elements(self): |
| 41 | + self.create_usage_test('usage-elements') |
| 42 | + |
| 43 | + def test_usage_pie_style(self): |
| 44 | + self.create_usage_test('demos.usage-pie-style') |
| 45 | + |
| 46 | + def test_usage_simple(self): |
| 47 | + self.create_usage_test('usage') |
| 48 | + |
| 49 | + def test_usage_stylesheet(self): |
| 50 | + self.create_usage_test('usage-stylesheet') |
| 51 | + |
| 52 | + def test_usage_initialisation(self): |
| 53 | + self.create_usage_test('demos.usage-initialisation') |
| 54 | + |
| 55 | + def test_usage_linkout_example(self): |
| 56 | + self.create_usage_test('demos.usage-linkout-example') |
0 commit comments