66from selenium .webdriver .common .by import By
77
88from reflex .components .lucide .icon import LUCIDE_ICON_LIST
9- from reflex .testing import AppHarness
9+ from reflex .testing import AppHarness , WebDriver
1010
1111
1212def Icons ():
@@ -16,7 +16,9 @@ def Icons():
1616 app = rx .App ()
1717
1818 class State (rx .State ):
19- pass
19+ """State for the Icons app."""
20+
21+ dynamic_icon : str = "airplay"
2022
2123 @app .add_page
2224 def index ():
@@ -28,6 +30,10 @@ def index():
2830 value = State .router .session .client_token ,
2931 is_read_only = True ,
3032 ),
33+ rx .el .div (
34+ rx .icon (State .dynamic_icon ),
35+ id = "dynamic_icon" ,
36+ ),
3137 * [
3238 rx .el .div (
3339 rx .icon (icon_name ),
@@ -39,16 +45,19 @@ def index():
3945
4046
4147@pytest .fixture (scope = "module" )
42- def icons (tmp_path_factory ) -> Generator [AppHarness , None , None ]:
48+ def icons (
49+ tmp_path_factory , app_harness_env : type [AppHarness ]
50+ ) -> Generator [AppHarness , None , None ]:
4351 """Start Icons app at tmp_path via AppHarness.
4452
4553 Args:
4654 tmp_path_factory: pytest tmp_path_factory fixture
55+ app_harness_env: The AppHarness environment to use
4756
4857 Yields:
4958 running AppHarness instance
5059 """
51- with AppHarness .create (
60+ with app_harness_env .create (
5261 root = tmp_path_factory .mktemp ("icons" ),
5362 app_source = Icons ,
5463 ) as harness :
@@ -80,14 +89,16 @@ def driver(icons: AppHarness):
8089 driver .quit ()
8190
8291
83- def test_icons (driver , icons : AppHarness ):
92+ def test_icons (driver : WebDriver , icons : AppHarness ):
8493 """Test that the var operations produce the right results.
8594
8695 Args:
8796 driver: selenium WebDriver open to the app
8897 icons: AppHarness for the dynamic components
8998 """
90- for icon_name in LUCIDE_ICON_LIST :
99+ for icon_name in [ * LUCIDE_ICON_LIST , "dynamic_icon" ] :
91100 AppHarness .expect (
92- lambda icon_name = icon_name : driver .find_element (By .ID , icon_name )
101+ lambda icon_name = icon_name : driver .find_element (
102+ By .ID , icon_name
103+ ).find_element (By .TAG_NAME , "svg" )
93104 )
0 commit comments