fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.
This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).
Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
153
backend/tests/test_school_frontend.py
Normal file
153
backend/tests/test_school_frontend.py
Normal file
@@ -0,0 +1,153 @@
|
||||
"""
|
||||
Unit Tests for School Frontend Module
|
||||
|
||||
Tests for the refactored school frontend components:
|
||||
- school_styles.py (CSS styles)
|
||||
- school_templates.py (Page templates)
|
||||
"""
|
||||
import pytest
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
|
||||
from frontend.school_styles import get_school_base_styles
|
||||
from frontend.school_templates import (
|
||||
render_school_sidebar,
|
||||
render_school_base_page,
|
||||
SCHOOL_NAV_ITEMS,
|
||||
SCHOOL_ICONS
|
||||
)
|
||||
|
||||
|
||||
class TestSchoolStyles:
|
||||
"""Test CSS styles"""
|
||||
|
||||
def test_get_school_base_styles_returns_string(self):
|
||||
"""Test that get_school_base_styles returns a string"""
|
||||
result = get_school_base_styles()
|
||||
assert isinstance(result, str)
|
||||
assert len(result) > 0
|
||||
|
||||
def test_css_contains_variables(self):
|
||||
"""Test that CSS contains CSS variables"""
|
||||
css = get_school_base_styles()
|
||||
assert "--bp-primary:" in css
|
||||
assert "--bp-bg:" in css
|
||||
assert "--bp-surface:" in css
|
||||
|
||||
def test_css_contains_layout_classes(self):
|
||||
"""Test that CSS contains layout classes"""
|
||||
css = get_school_base_styles()
|
||||
assert ".app-container" in css
|
||||
assert ".sidebar" in css
|
||||
assert ".main-content" in css
|
||||
|
||||
def test_css_contains_component_classes(self):
|
||||
"""Test that CSS contains component classes"""
|
||||
css = get_school_base_styles()
|
||||
assert ".btn" in css
|
||||
assert ".card" in css
|
||||
assert ".table" in css
|
||||
|
||||
|
||||
class TestSchoolTemplates:
|
||||
"""Test template rendering functions"""
|
||||
|
||||
def test_school_nav_items_defined(self):
|
||||
"""Test that navigation items are defined"""
|
||||
assert len(SCHOOL_NAV_ITEMS) > 0
|
||||
assert any(item['id'] == 'dashboard' for item in SCHOOL_NAV_ITEMS)
|
||||
|
||||
def test_school_icons_defined(self):
|
||||
"""Test that icons are defined"""
|
||||
assert len(SCHOOL_ICONS) > 0
|
||||
assert 'home' in SCHOOL_ICONS
|
||||
assert 'users' in SCHOOL_ICONS
|
||||
|
||||
def test_render_school_sidebar_returns_string(self):
|
||||
"""Test that render_school_sidebar returns a string"""
|
||||
result = render_school_sidebar()
|
||||
assert isinstance(result, str)
|
||||
|
||||
def test_render_school_sidebar_contains_navigation(self):
|
||||
"""Test that sidebar contains navigation items"""
|
||||
result = render_school_sidebar()
|
||||
assert "sidebar" in result
|
||||
assert "/school" in result
|
||||
assert "Dashboard" in result
|
||||
|
||||
def test_render_school_sidebar_active_page(self):
|
||||
"""Test active page highlighting"""
|
||||
result = render_school_sidebar("attendance")
|
||||
assert "active" in result
|
||||
assert "Anwesenheit" in result
|
||||
|
||||
def test_render_school_sidebar_contains_all_nav_items(self):
|
||||
"""Test that all navigation items are present"""
|
||||
result = render_school_sidebar()
|
||||
for item in SCHOOL_NAV_ITEMS:
|
||||
assert item['label'] in result, f"Missing nav item: {item['label']}"
|
||||
|
||||
def test_render_school_base_page_returns_html(self):
|
||||
"""Test that render_school_base_page returns HTML"""
|
||||
result = render_school_base_page("Test Title", "<p>Test Content</p>")
|
||||
assert isinstance(result, str)
|
||||
assert "<!DOCTYPE html>" in result
|
||||
assert "</html>" in result
|
||||
|
||||
def test_render_school_base_page_contains_title(self):
|
||||
"""Test that title is included in HTML"""
|
||||
result = render_school_base_page("My Test Page", "<p>Content</p>")
|
||||
assert "My Test Page" in result
|
||||
assert "<title>BreakPilot – My Test Page</title>" in result
|
||||
|
||||
def test_render_school_base_page_contains_content(self):
|
||||
"""Test that content is included in HTML"""
|
||||
test_content = "<p>This is test content</p>"
|
||||
result = render_school_base_page("Title", test_content)
|
||||
assert test_content in result
|
||||
|
||||
def test_render_school_base_page_includes_styles(self):
|
||||
"""Test that styles are included"""
|
||||
result = render_school_base_page("Title", "Content")
|
||||
assert "<style>" in result
|
||||
assert "--bp-primary" in result
|
||||
|
||||
def test_render_school_base_page_includes_sidebar(self):
|
||||
"""Test that sidebar is included"""
|
||||
result = render_school_base_page("Title", "Content", "dashboard")
|
||||
assert "sidebar" in result
|
||||
assert "Schulverwaltung" in result
|
||||
|
||||
def test_render_school_base_page_extra_styles(self):
|
||||
"""Test that extra styles are included"""
|
||||
extra = ".custom-class { color: red; }"
|
||||
result = render_school_base_page("Title", "Content", extra_styles=extra)
|
||||
assert ".custom-class" in result
|
||||
|
||||
def test_render_school_base_page_extra_scripts(self):
|
||||
"""Test that extra scripts are included"""
|
||||
extra = "console.log('test');"
|
||||
result = render_school_base_page("Title", "Content", extra_scripts=extra)
|
||||
assert "console.log" in result
|
||||
|
||||
|
||||
class TestSchoolFrontendIntegration:
|
||||
"""Integration tests"""
|
||||
|
||||
def test_styles_and_templates_compatible(self):
|
||||
"""Test that styles work with templates"""
|
||||
# Get styles and render a page
|
||||
styles = get_school_base_styles()
|
||||
page = render_school_base_page("Test", "<div class='card'>Content</div>")
|
||||
|
||||
# Styles should include card class
|
||||
assert ".card" in styles
|
||||
# Page should include the styles
|
||||
assert ".card" in page
|
||||
|
||||
def test_all_nav_items_have_valid_hrefs(self):
|
||||
"""Test that all nav items have valid hrefs"""
|
||||
for item in SCHOOL_NAV_ITEMS:
|
||||
assert 'href' in item
|
||||
assert item['href'].startswith('/school')
|
||||
Reference in New Issue
Block a user