Skip to content

Commit 08d9fbf

Browse files
masenfLendemor
andauthored
unbreak link _hover (#4537)
* unbreak link _hover * add a test to catch the error * change tmp path for harness * add () to fixture * add spacer to avoid initial hover * only install chromium browser for faster ci --------- Co-authored-by: Lendemor <thomas.brandeho@gmail.com>
1 parent 72d7616 commit 08d9fbf

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

.github/workflows/integration_app_harness.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
SCREENSHOT_DIR: /tmp/screenshots/${{ matrix.state_manager }}/${{ matrix.python-version }}/${{ matrix.split_index }}
5454
REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }}
5555
run: |
56-
poetry run playwright install --with-deps
56+
poetry run playwright install chromium
5757
poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}}
5858
- uses: actions/upload-artifact@v4
5959
name: Upload failed test screenshots

reflex/components/radix/themes/typography/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create(cls, *children, **props) -> Component:
7676
Returns:
7777
Component: The link component
7878
"""
79-
props.setdefault(":hover", {"color": color("accent", 8)})
79+
props.setdefault("_hover", {"color": color("accent", 8)})
8080
href = props.get("href")
8181

8282
is_external = props.pop("is_external", None)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Generator
2+
3+
import pytest
4+
from playwright.sync_api import Page, expect
5+
6+
from reflex.testing import AppHarness
7+
8+
9+
def LinkApp():
10+
import reflex as rx
11+
12+
app = rx.App()
13+
14+
def index():
15+
return rx.vstack(
16+
rx.box(height="10em"), # spacer, so the link isn't hovered initially
17+
rx.link(
18+
"Click me",
19+
href="#",
20+
color="blue",
21+
_hover=rx.Style({"color": "red"}),
22+
),
23+
)
24+
25+
app.add_page(index, "/")
26+
27+
28+
@pytest.fixture()
29+
def link_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
30+
with AppHarness.create(
31+
root=tmp_path_factory.mktemp("link_app"),
32+
app_source=LinkApp, # type: ignore
33+
) as harness:
34+
assert harness.app_instance is not None, "app is not running"
35+
yield harness
36+
37+
38+
def test_link_hover(link_app: AppHarness, page: Page):
39+
assert link_app.frontend_url is not None
40+
page.goto(link_app.frontend_url)
41+
42+
link = page.get_by_role("link")
43+
expect(link).to_have_text("Click me")
44+
expect(link).to_have_css("color", "rgb(0, 0, 255)")
45+
link.hover()
46+
expect(link).to_have_css("color", "rgb(255, 0, 0)")

0 commit comments

Comments
 (0)