Integration testing: Firefox compatibility (#3162)

* Integration testing: Firefox compatibility

* test_client_side_storage: ruff format
This commit is contained in:
Masen Furer 2024-04-26 13:44:08 -07:00 committed by GitHub
parent 92cdc15896
commit 74eaab5e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import time
from typing import Generator
import pytest
from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
@ -374,9 +375,12 @@ async def test_client_side_state(
"value": "c3%20value",
}
time.sleep(2) # wait for c3 to expire
assert "state.client_side_state.client_side_sub_state.c3" not in cookie_info_map(
driver
)
if not isinstance(driver, Firefox):
# Note: Firefox does not remove expired cookies Bug 576347
assert (
"state.client_side_state.client_side_sub_state.c3"
not in cookie_info_map(driver)
)
local_storage_items = local_storage.items()
local_storage_items.pop("chakra-ui-color-mode", None)

View File

@ -34,7 +34,7 @@ def FullyControlledInput():
value=State.text,
id="plain_value_input",
disabled=True,
_disabled={"background_color": "#EEE"},
_disabled={"width": "42px"},
),
rx.input(default_value="default", id="default_input"),
rx.el.input(
@ -124,13 +124,10 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness):
assert fully_controlled_input.poll_for_value(debounce_input) == "initial"
assert fully_controlled_input.poll_for_value(value_input) == "initial"
assert fully_controlled_input.poll_for_value(plain_value_input) == "initial"
assert (
plain_value_input.value_of_css_property("background-color")
== "rgba(238, 238, 238, 1)"
)
assert plain_value_input.value_of_css_property("width") == "42px"
# move cursor to home, then to the right and type characters
debounce_input.send_keys(Keys.HOME, Keys.ARROW_RIGHT)
debounce_input.send_keys(*([Keys.ARROW_LEFT] * len("initial")), Keys.ARROW_RIGHT)
debounce_input.send_keys("foo")
assert AppHarness._poll_for(
lambda: fully_controlled_input.poll_for_value(value_input) == "ifoonitial"

View File

@ -10,7 +10,7 @@ from reflex.testing import AppHarness
PARAGRAPH_TEXT = "Tailwind Is Cool"
PARAGRAPH_CLASS_NAME = "text-red-500"
TEXT_RED_500_COLOR = "rgba(239, 68, 68, 1)"
TEXT_RED_500_COLOR = ["rgba(239, 68, 68, 1)", "rgb(239, 68, 68)"]
def TailwindApp(
@ -104,7 +104,7 @@ def test_tailwind_app(tailwind_app: AppHarness, tailwind_disabled: bool):
assert p.value_of_css_property("font-family") == "monospace"
if tailwind_disabled:
# expect default color, not "text-red-500" from tailwind utility class
assert p.value_of_css_property("color") != TEXT_RED_500_COLOR
assert p.value_of_css_property("color") not in TEXT_RED_500_COLOR
else:
# expect "text-red-500" from tailwind utility class
assert p.value_of_css_property("color") == TEXT_RED_500_COLOR
assert p.value_of_css_property("color") in TEXT_RED_500_COLOR

View File

@ -538,7 +538,7 @@ class AppHarness:
if driver_clz is None:
requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome")
driver_clz = getattr(webdriver, requested_driver)
options = webdriver.ChromeOptions()
options = getattr(webdriver, f"{requested_driver}Options")()
if driver_clz is webdriver.Chrome and want_headless:
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")