Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
154 lines
5.4 KiB
Python
154 lines
5.4 KiB
Python
"""
|
||
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')
|