mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 16:04:21 +00:00
test: add frontend smoke and backend e2e CI
This commit is contained in:
@@ -92,11 +92,11 @@ def e2e_client(e2e_port, langbot_process):
|
||||
|
||||
base_url = f'http://127.0.0.1:{e2e_port}'
|
||||
|
||||
with httpx.Client(base_url=base_url, timeout=10.0) as client:
|
||||
with httpx.Client(base_url=base_url, timeout=10.0, trust_env=False) as client:
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def e2e_db_path(e2e_tmpdir):
|
||||
"""Path to SQLite database file."""
|
||||
return e2e_tmpdir / 'data' / 'langbot.db'
|
||||
return e2e_tmpdir / 'data' / 'langbot.db'
|
||||
|
||||
@@ -38,7 +38,7 @@ class TestStartupFlow:
|
||||
# System info should contain version info
|
||||
assert 'version' in data['data'] or 'edition' in data['data']
|
||||
|
||||
def test_database_initialized(self, e2e_db_path):
|
||||
def test_database_initialized(self, langbot_process, e2e_db_path):
|
||||
"""Verify SQLite database was created and initialized."""
|
||||
assert e2e_db_path.exists()
|
||||
|
||||
@@ -75,7 +75,7 @@ class TestStartupFlow:
|
||||
"""Test auth endpoint."""
|
||||
# First startup may allow initial setup
|
||||
response = e2e_client.post('/api/v1/user/auth', json={
|
||||
'username': 'admin',
|
||||
'user': 'admin',
|
||||
'password': 'admin',
|
||||
})
|
||||
|
||||
@@ -94,7 +94,7 @@ class TestStartupStages:
|
||||
# If API responds on e2e_port, config was loaded
|
||||
assert e2e_client.get('/api/v1/system/info').status_code == 200
|
||||
|
||||
def test_migrations_applied(self, e2e_db_path):
|
||||
def test_migrations_applied(self, langbot_process, e2e_db_path):
|
||||
"""Verify database migrations were applied."""
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(str(e2e_db_path))
|
||||
|
||||
@@ -44,6 +44,17 @@ class LangBotProcess:
|
||||
# Prepare environment
|
||||
env = os.environ.copy()
|
||||
env['PYTHONPATH'] = str(self.project_root / 'src')
|
||||
for proxy_key in (
|
||||
'HTTP_PROXY',
|
||||
'HTTPS_PROXY',
|
||||
'ALL_PROXY',
|
||||
'http_proxy',
|
||||
'https_proxy',
|
||||
'all_proxy',
|
||||
):
|
||||
env.pop(proxy_key, None)
|
||||
env['NO_PROXY'] = '127.0.0.1,localhost'
|
||||
env['no_proxy'] = '127.0.0.1,localhost'
|
||||
|
||||
# Set API port via environment variable
|
||||
env['API__PORT'] = str(self.port)
|
||||
@@ -113,6 +124,8 @@ precision = 2
|
||||
r = httpx.get(
|
||||
f'http://127.0.0.1:{self.port}/api/v1/system/info',
|
||||
timeout=2.0,
|
||||
follow_redirects=False,
|
||||
trust_env=False,
|
||||
)
|
||||
if r.status_code == 200:
|
||||
logger.info(f'LangBot started successfully on port {self.port}')
|
||||
@@ -185,6 +198,8 @@ precision = 2
|
||||
r = httpx.get(
|
||||
f'http://127.0.0.1:{self.port}/api/v1/system/info',
|
||||
timeout=5.0,
|
||||
follow_redirects=False,
|
||||
trust_env=False,
|
||||
)
|
||||
return r.status_code == 200
|
||||
except Exception:
|
||||
@@ -201,4 +216,4 @@ def find_project_root() -> Path:
|
||||
return parent
|
||||
|
||||
# Fallback to LangBot-test-build directory
|
||||
return Path('/home/glwuy/langbot-app/LangBot-test-build')
|
||||
return Path('/home/glwuy/langbot-app/LangBot-test-build')
|
||||
|
||||
Reference in New Issue
Block a user