Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions tests/integration/test_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -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),
Expand All @@ -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:
Expand Down Expand Up @@ -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")
)
Loading