-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeployURL is not updated in AppHarness tests. #2772
Comments
Just for reference: |
I.e. these two tests fail. """Integration tests for deploy_url."""
from __future__ import annotations
from typing import Generator
from selenium.webdriver.common.by import By
import pytest
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from reflex.testing import AppHarness
def DeployUrlSample():
"""Sample app for testing config deploy_url is correct (in tests)."""
import reflex as rx
class State(rx.State):
def goto_self(self):
return rx.redirect(rx.config.get_config().deploy_url)
def index():
return rx.fragment(
rx.button("GOTO SELF", on_click=State.goto_self, id="goto_self")
)
app = rx.App(state=rx.State)
app.add_page(index)
@pytest.fixture(scope="module")
def deploy_url_sample(tmp_path_factory) -> Generator[AppHarness, None, None]:
with AppHarness.create(
root=tmp_path_factory.mktemp("deploy_url_sample"),
app_source=DeployUrlSample, # type: ignore
) as harness:
yield harness
@pytest.fixture()
def driver(deploy_url_sample: AppHarness) -> Generator[WebDriver, None, None]:
assert deploy_url_sample.app_instance is not None, "app is not running"
driver = deploy_url_sample.frontend()
try:
yield driver
finally:
driver.quit()
def test_deploy_url(deploy_url_sample: AppHarness, driver: WebDriver):
import reflex as rx
assert rx.config.get_config().deploy_url != "http://localhost:3000"
assert rx.config.get_config().deploy_url == deploy_url_sample.frontend_url
driver.get(rx.config.get_config().deploy_url)
assert driver.current_url == rx.config.get_config().deploy_url
def test_deploy_url_in_app(deploy_url_sample: AppHarness, driver: WebDriver):
driver.implicitly_wait(10)
driver.find_element(By.ID, "goto_self").click()
WebDriverWait(driver, 10).until(
lambda driver: driver.current_url == deploy_url_sample.frontend_url
) |
Nobody wants to do a red2green 🩹 with given tests? What's up 😺 ? It's like a task from advent of code. |
Describe the bug
rx.get_config().deploy_url
always returnshttp://localhost:3000
.To Reproduce
Create an
AppHarness
test.Expected behavior
rx.get_config().deploy_url
returns the correct URL for the test environment.Specifics (please complete the following information):
The text was updated successfully, but these errors were encountered: