Initial commit
This commit is contained in:
48
tests/test_ui.py
Normal file
48
tests/test_ui.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
UI_BASE = os.getenv("UI_BASE", "http://192.168.1.2:9094")
|
||||
|
||||
def _wait_for_http(url: str, timeout_s: float = 90) -> None:
|
||||
deadline = time.time() + timeout_s
|
||||
last_err = None
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
resp = requests.get(url, timeout=5)
|
||||
if resp.status_code == 200:
|
||||
return
|
||||
last_err = f"status {resp.status_code}"
|
||||
except Exception as exc:
|
||||
last_err = str(exc)
|
||||
time.sleep(2)
|
||||
raise RuntimeError(f"service not ready: {url} ({last_err})")
|
||||
|
||||
|
||||
def test_ui_index_contains_expected_elements():
|
||||
_wait_for_http(UI_BASE + "/health")
|
||||
resp = requests.get(UI_BASE + "/", timeout=30)
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert "Model Manager" in html
|
||||
assert "id=\"download-form\"" in html
|
||||
assert "id=\"models-list\"" in html
|
||||
assert "id=\"logs-output\"" in html
|
||||
assert "id=\"theme-toggle\"" in html
|
||||
|
||||
|
||||
def test_ui_assets_available():
|
||||
resp = requests.get(UI_BASE + "/ui/styles.css", timeout=30)
|
||||
assert resp.status_code == 200
|
||||
css = resp.text
|
||||
assert "data-theme" in css
|
||||
|
||||
resp = requests.get(UI_BASE + "/ui/app.js", timeout=30)
|
||||
assert resp.status_code == 200
|
||||
js = resp.text
|
||||
assert "themeToggle" in js
|
||||
assert "localStorage" in js
|
||||
assert "logs-output" in js
|
||||
Reference in New Issue
Block a user