forked from Rockachopa/Timmy-time-dashboard
feat: code quality audit + autoresearch integration + infra hardening (#150)
This commit is contained in:
committed by
GitHub
parent
fd0ede0d51
commit
ae3bb1cc21
@@ -5,8 +5,8 @@ RUN: SELENIUM_UI=1 pytest tests/functional/test_fast_e2e.py -v
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
try:
|
||||
from selenium import webdriver
|
||||
@@ -14,6 +14,7 @@ try:
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
HAS_SELENIUM = True
|
||||
except ImportError:
|
||||
HAS_SELENIUM = False
|
||||
@@ -77,9 +78,10 @@ class TestAllPagesLoad:
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
|
||||
|
||||
# Give a small extra buffer for animations (fadeUp in style.css)
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
# Verify page has expected content
|
||||
@@ -102,10 +104,9 @@ class TestAllFeaturesWork:
|
||||
|
||||
# 1. Event Log - verify events display
|
||||
driver.get(f"{dashboard_url}/swarm/events")
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
# Should have header and either events or empty state
|
||||
@@ -124,21 +125,15 @@ class TestAllFeaturesWork:
|
||||
|
||||
# 2. Memory - verify search works
|
||||
driver.get(f"{dashboard_url}/memory?query=test")
|
||||
WebDriverWait(driver, 3).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
|
||||
# Should have search input
|
||||
search = driver.find_elements(
|
||||
By.CSS_SELECTOR, "input[type='search'], input[name='query']"
|
||||
)
|
||||
search = driver.find_elements(By.CSS_SELECTOR, "input[type='search'], input[name='query']")
|
||||
assert search, "Memory page missing search input"
|
||||
|
||||
# 3. Ledger - verify balance display
|
||||
driver.get(f"{dashboard_url}/lightning/ledger")
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
time.sleep(0.5)
|
||||
|
||||
body = driver.find_element(By.TAG_NAME, "body").text
|
||||
@@ -155,10 +150,9 @@ class TestCascadeRouter:
|
||||
|
||||
# Check router status page
|
||||
driver.get(f"{dashboard_url}/router/status")
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
body = driver.find_element(By.TAG_NAME, "body").text
|
||||
@@ -172,9 +166,7 @@ class TestCascadeRouter:
|
||||
|
||||
# Check nav has router link
|
||||
driver.get(dashboard_url)
|
||||
WebDriverWait(driver, 3).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
|
||||
nav_links = driver.find_elements(By.XPATH, "//a[contains(@href, '/router')]")
|
||||
assert nav_links, "Navigation missing router link"
|
||||
@@ -187,30 +179,23 @@ class TestUpgradeQueue:
|
||||
"""Verify upgrade queue page loads with expected elements."""
|
||||
|
||||
driver.get(f"{dashboard_url}/self-modify/queue")
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
body = driver.find_element(By.TAG_NAME, "body").text
|
||||
|
||||
# Should have queue header
|
||||
assert "upgrade" in body.lower() or "queue" in body.lower(), (
|
||||
"Missing queue header"
|
||||
)
|
||||
assert "upgrade" in body.lower() or "queue" in body.lower(), "Missing queue header"
|
||||
|
||||
# Should have pending section or empty state
|
||||
has_pending = "pending" in body.lower() or "no pending" in body.lower()
|
||||
assert has_pending, "Missing pending upgrades section"
|
||||
|
||||
# Check for approve/reject buttons if upgrades exist
|
||||
approve_btns = driver.find_elements(
|
||||
By.XPATH, "//button[contains(text(), 'Approve')]"
|
||||
)
|
||||
reject_btns = driver.find_elements(
|
||||
By.XPATH, "//button[contains(text(), 'Reject')]"
|
||||
)
|
||||
approve_btns = driver.find_elements(By.XPATH, "//button[contains(text(), 'Approve')]")
|
||||
reject_btns = driver.find_elements(By.XPATH, "//button[contains(text(), 'Reject')]")
|
||||
|
||||
# Either no upgrades (no buttons) or buttons exist
|
||||
# This is a soft check - page structure is valid either way
|
||||
@@ -223,18 +208,15 @@ class TestActivityFeed:
|
||||
"""Verify swarm live page has activity feed elements."""
|
||||
|
||||
driver.get(f"{dashboard_url}/swarm/live")
|
||||
WebDriverWait(driver, 5).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
body = driver.find_element(By.TAG_NAME, "body").text
|
||||
|
||||
# Should have live indicator or activity section
|
||||
has_live = any(
|
||||
x in body.lower() for x in ["live", "activity", "swarm", "agents", "tasks"]
|
||||
)
|
||||
has_live = any(x in body.lower() for x in ["live", "activity", "swarm", "agents", "tasks"])
|
||||
assert has_live, "Swarm live page missing content"
|
||||
|
||||
# Check for WebSocket connection indicator (if implemented)
|
||||
@@ -261,9 +243,7 @@ class TestFastSmoke:
|
||||
|
||||
for route in routes:
|
||||
try:
|
||||
r = httpx.get(
|
||||
f"{dashboard_url}{route}", timeout=3, follow_redirects=True
|
||||
)
|
||||
r = httpx.get(f"{dashboard_url}{route}", timeout=3, follow_redirects=True)
|
||||
if r.status_code != 200:
|
||||
failures.append(f"{route}: {r.status_code}")
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user