diff --git a/tests/integration/test_icon.py b/tests/integration/test_icon.py index 47f887e498a..43313532a62 100644 --- a/tests/integration/test_icon.py +++ b/tests/integration/test_icon.py @@ -6,7 +6,7 @@ from selenium.webdriver.common.by import By from reflex.components.lucide.icon import LUCIDE_ICON_LIST -from reflex.testing import AppHarness +from reflex.testing import AppHarness, WebDriver def Icons(): @@ -16,7 +16,9 @@ def Icons(): app = rx.App() class State(rx.State): - pass + """State for the Icons app.""" + + dynamic_icon: str = "airplay" @app.add_page def index(): @@ -28,6 +30,10 @@ def index(): value=State.router.session.client_token, is_read_only=True, ), + rx.el.div( + rx.icon(State.dynamic_icon), + id="dynamic_icon", + ), *[ rx.el.div( rx.icon(icon_name), @@ -39,16 +45,19 @@ def index(): @pytest.fixture(scope="module") -def icons(tmp_path_factory) -> Generator[AppHarness, None, None]: +def icons( + tmp_path_factory, app_harness_env: type[AppHarness] +) -> Generator[AppHarness, None, None]: """Start Icons app at tmp_path via AppHarness. Args: tmp_path_factory: pytest tmp_path_factory fixture + app_harness_env: The AppHarness environment to use Yields: running AppHarness instance """ - with AppHarness.create( + with app_harness_env.create( root=tmp_path_factory.mktemp("icons"), app_source=Icons, ) as harness: @@ -80,14 +89,16 @@ def driver(icons: AppHarness): driver.quit() -def test_icons(driver, icons: AppHarness): +def test_icons(driver: WebDriver, icons: AppHarness): """Test that the var operations produce the right results. Args: driver: selenium WebDriver open to the app icons: AppHarness for the dynamic components """ - for icon_name in LUCIDE_ICON_LIST: + for icon_name in [*LUCIDE_ICON_LIST, "dynamic_icon"]: AppHarness.expect( - lambda icon_name=icon_name: driver.find_element(By.ID, icon_name) + lambda icon_name=icon_name: driver.find_element( + By.ID, icon_name + ).find_element(By.TAG_NAME, "svg") )