Add browser Python editor with Pyodide, user auth, and workspace API
- FastAPI serves static UI, file CRUD under code/ and read-only lib/ - Pyodide worker runs Python and Jedi completions in the browser - SQLite accounts: login/register, session cookies, superuser user management - Optional EDITOR_API_KEY, AUTH_* env vars, .env.example - Pipenv, pytest, Selenium smoke test, README Made-with: Cursor
This commit is contained in:
48
tests/test_selenium_smoke.py
Normal file
48
tests/test_selenium_smoke.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Selenium smoke tests — need a running app (see README)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
import pytest
|
||||
|
||||
pytest.importorskip("selenium.webdriver")
|
||||
|
||||
|
||||
def _server_reachable(base_url: str, timeout: float = 2.0) -> bool:
|
||||
try:
|
||||
urllib.request.urlopen(f"{base_url.rstrip('/')}/", timeout=timeout)
|
||||
return True
|
||||
except (urllib.error.URLError, OSError):
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def driver():
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
opts = Options()
|
||||
opts.add_argument("--headless=new")
|
||||
opts.add_argument("--no-sandbox")
|
||||
opts.add_argument("--disable-dev-shm-usage")
|
||||
try:
|
||||
browser = webdriver.Chrome(options=opts)
|
||||
except Exception as exc: # pragma: no cover
|
||||
pytest.skip(f"Chrome / ChromeDriver not available: {exc}")
|
||||
yield browser
|
||||
browser.quit()
|
||||
|
||||
|
||||
@pytest.mark.selenium
|
||||
def test_home_page_title(driver):
|
||||
base = os.environ.get("SELENIUM_BASE_URL", "http://127.0.0.1:8080").rstrip("/")
|
||||
if not _server_reachable(base):
|
||||
pytest.skip(
|
||||
f"No server at {base}. In another terminal run: "
|
||||
"pipenv run dev (then re-run this test, or set SELENIUM_BASE_URL)."
|
||||
)
|
||||
driver.get(f"{base}/")
|
||||
assert "Python Editor" in driver.title
|
||||
Reference in New Issue
Block a user