From 460d4fe75b7d23300975e0bbb52ce05e79e9521e Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Fri, 13 Dec 2024 14:02:31 -0800 Subject: [PATCH 1/6] unbreak link _hover --- reflex/components/radix/themes/typography/link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/components/radix/themes/typography/link.py b/reflex/components/radix/themes/typography/link.py index 25a0902cc5..c931024084 100644 --- a/reflex/components/radix/themes/typography/link.py +++ b/reflex/components/radix/themes/typography/link.py @@ -76,7 +76,7 @@ def create(cls, *children, **props) -> Component: Returns: Component: The link component """ - props.setdefault(":hover", {"color": color("accent", 8)}) + props.setdefault("_hover", {"color": color("accent", 8)}) href = props.get("href") is_external = props.pop("is_external", None) From 0e3d1fb4f6c83c04ddab3c7cadf254e8e9956db5 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Sat, 14 Dec 2024 00:53:33 +0100 Subject: [PATCH 2/6] add a test to catch the error --- .../tests_playwright/test_link_hover.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/integration/tests_playwright/test_link_hover.py diff --git a/tests/integration/tests_playwright/test_link_hover.py b/tests/integration/tests_playwright/test_link_hover.py new file mode 100644 index 0000000000..9ef38e50b1 --- /dev/null +++ b/tests/integration/tests_playwright/test_link_hover.py @@ -0,0 +1,45 @@ +from typing import Generator + +import pytest +from playwright.sync_api import Page, expect + +from reflex.testing import AppHarness + + +def LinkApp(): + import reflex as rx + + app = rx.App() + + def index(): + return rx.vstack( + rx.link( + "Click me", + href="#", + color="blue", + _hover=rx.Style({"color": "red"}), + ) + ) + + app.add_page(index, "/") + + +@pytest.fixture +def link_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + with AppHarness.create( + root=tmp_path_factory.mktemp("appearance_app"), + app_source=LinkApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +def test_link(link_app: AppHarness, page: Page): + assert link_app.frontend_url is not None + page.goto(link_app.frontend_url) + + link = page.get_by_role("link") + expect(link).to_have_text("Click me") + expect(link).to_have_css("color", "rgb(0, 0, 255)") + link.hover() + expect(link).to_have_css("color", "rgb(255, 0, 0)") From 2a08342213d431fc2efb34d4930a5fae6dbc3d63 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Sat, 14 Dec 2024 01:20:10 +0100 Subject: [PATCH 3/6] change tmp path for harness --- tests/integration/tests_playwright/test_link_hover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests_playwright/test_link_hover.py b/tests/integration/tests_playwright/test_link_hover.py index 9ef38e50b1..adf38342bd 100644 --- a/tests/integration/tests_playwright/test_link_hover.py +++ b/tests/integration/tests_playwright/test_link_hover.py @@ -27,7 +27,7 @@ def index(): @pytest.fixture def link_app(tmp_path_factory) -> Generator[AppHarness, None, None]: with AppHarness.create( - root=tmp_path_factory.mktemp("appearance_app"), + root=tmp_path_factory.mktemp("link_app"), app_source=LinkApp, # type: ignore ) as harness: assert harness.app_instance is not None, "app is not running" From af8c4b9456134601d9e06fc219a072df9e68cbb4 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Sat, 14 Dec 2024 01:55:00 +0100 Subject: [PATCH 4/6] add () to fixture --- tests/integration/tests_playwright/test_link_hover.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/tests_playwright/test_link_hover.py b/tests/integration/tests_playwright/test_link_hover.py index adf38342bd..efbf64013d 100644 --- a/tests/integration/tests_playwright/test_link_hover.py +++ b/tests/integration/tests_playwright/test_link_hover.py @@ -24,7 +24,7 @@ def index(): app.add_page(index, "/") -@pytest.fixture +@pytest.fixture() def link_app(tmp_path_factory) -> Generator[AppHarness, None, None]: with AppHarness.create( root=tmp_path_factory.mktemp("link_app"), @@ -34,7 +34,7 @@ def link_app(tmp_path_factory) -> Generator[AppHarness, None, None]: yield harness -def test_link(link_app: AppHarness, page: Page): +def test_link_hover(link_app: AppHarness, page: Page): assert link_app.frontend_url is not None page.goto(link_app.frontend_url) From 9da4061737624efa44f5a3039baa34c8864b896c Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 6 Jan 2025 14:34:57 -0800 Subject: [PATCH 5/6] add spacer to avoid initial hover --- tests/integration/tests_playwright/test_link_hover.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/tests_playwright/test_link_hover.py b/tests/integration/tests_playwright/test_link_hover.py index efbf64013d..9510bd3587 100644 --- a/tests/integration/tests_playwright/test_link_hover.py +++ b/tests/integration/tests_playwright/test_link_hover.py @@ -13,12 +13,13 @@ def LinkApp(): def index(): return rx.vstack( + rx.box(height="10em"), # spacer, so the link isn't hovered initially rx.link( "Click me", href="#", color="blue", _hover=rx.Style({"color": "red"}), - ) + ), ) app.add_page(index, "/") From 564780de47c67c18c2776f485530be5d9f405eaa Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 6 Jan 2025 14:52:06 -0800 Subject: [PATCH 6/6] only install chromium browser for faster ci --- .github/workflows/integration_app_harness.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_app_harness.yml b/.github/workflows/integration_app_harness.yml index e6ea793774..21b021ee5c 100644 --- a/.github/workflows/integration_app_harness.yml +++ b/.github/workflows/integration_app_harness.yml @@ -53,7 +53,7 @@ jobs: SCREENSHOT_DIR: /tmp/screenshots/${{ matrix.state_manager }}/${{ matrix.python-version }}/${{ matrix.split_index }} REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }} run: | - poetry run playwright install --with-deps + poetry run playwright install chromium poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}} - uses: actions/upload-artifact@v4 name: Upload failed test screenshots