-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganize all tests in a single top folder (#3981)
* lift node version restraint to allow more recent version if already installed * add node test for latest version * change python version * use purple for debug logs * update workflow * add playwright dev dependency * update workflow * change test * oops * improve test * update test * fix tests * mv units tests to a subfolder * reorganize tests * fix install * update test_state * revert node changes and only keep new tests organization * move integration tests in tests/integration * fix integration workflow * fix dockerfile workflow * fix dockerfile workflow 2 * fix shared_state
- Loading branch information
Showing
121 changed files
with
306 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: integration-node-latest | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
TELEMETRY_ENABLED: false | ||
|
||
jobs: | ||
check_latest_node: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.12'] | ||
node-version: ['node'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup_build_env | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
run-poetry-install: true | ||
create-venv-at-path: .venv | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: | | ||
poetry run uv pip install pyvirtualdisplay pillow | ||
poetry run playwright install --with-deps | ||
- run: | | ||
# poetry run pytest tests/test_node_version.py | ||
poetry run pytest tests/integration | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"""Test for latest node version being able to run reflex.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Generator | ||
|
||
import httpx | ||
import pytest | ||
from playwright.sync_api import Page, expect | ||
|
||
from reflex.testing import AppHarness | ||
|
||
|
||
def TestNodeVersionApp(): | ||
"""A test app for node latest version.""" | ||
import reflex as rx | ||
from reflex.utils.prerequisites import get_node_version | ||
|
||
class TestNodeVersionConfig(rx.Config): | ||
pass | ||
|
||
class TestNodeVersionState(rx.State): | ||
@rx.var | ||
def node_version(self) -> str: | ||
return str(get_node_version()) | ||
|
||
app = rx.App() | ||
|
||
@app.add_page | ||
def index(): | ||
return rx.heading("Node Version check v", TestNodeVersionState.node_version) | ||
|
||
|
||
@pytest.fixture() | ||
def node_version_app(tmp_path) -> Generator[AppHarness, Any, None]: | ||
"""Fixture to start TestNodeVersionApp app at tmp_path via AppHarness. | ||
Args: | ||
tmp_path: pytest tmp_path fixture | ||
Yields: | ||
running AppHarness instance | ||
""" | ||
with AppHarness.create( | ||
root=tmp_path, | ||
app_source=TestNodeVersionApp, # type: ignore | ||
) as harness: | ||
yield harness | ||
|
||
|
||
def test_node_version(node_version_app: AppHarness, page: Page): | ||
"""Test for latest node version being able to run reflex. | ||
Args: | ||
node_version_app: running AppHarness instance | ||
page: playwright page instance | ||
""" | ||
|
||
def get_latest_node_version(): | ||
response = httpx.get("https://nodejs.org/dist/index.json") | ||
versions = response.json() | ||
|
||
# Assuming the first entry in the API response is the most recent version | ||
if versions: | ||
latest_version = versions[0]["version"] | ||
return latest_version | ||
return None | ||
|
||
assert node_version_app.frontend_url is not None | ||
page.goto(node_version_app.frontend_url) | ||
expect(page.get_by_role("heading")).to_have_text( | ||
f"Node Version check {get_latest_node_version()}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Root directory for tests.""" | ||
|
||
import os | ||
|
||
from reflex import constants |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.