"""Test dashboard navigation link in all pages""" import pytest import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from app import app as flask_app @pytest.fixture def client(): flask_app.config['TESTING'] = True with flask_app.test_client() as c: yield c # Pages that should show the dashboard nav link PAGES = [ "/", "/articles", "/reports", "/jobs", "/learn", "/whitelist", "/approvals", "/dashboard", "/circle", ] def test_dashboard_nav_in_all_pages(client): """Dashboard link appears in all page navigations""" for page in PAGES: r = client.get(page) html = r.data.decode('utf-8') msg = f"Missing dashboard link on {page}" assert '📊' in html and '数据看板' in html and 'href="/dashboard"' in html, msg def test_dashboard_nav_active_on_dashboard(client): """Dashboard nav item is active/highlighted on /dashboard page""" r = client.get('/dashboard') html = r.data.decode('utf-8') # Active class should be on the dashboard link assert '/dashboard' in html # The dashboard link should have the 'active' class assert 'dashboard' in html def test_existing_nav_items_still_present(client): """Existing nav items are not broken""" r = client.get('/') html = r.data.decode('utf-8') existing_items = ['消息浏览', '文章列表', '日报列表', '任务监控', '学习审核'] for item in existing_items: assert item in html, f"Missing existing nav item: {item}" if __name__ == '__main__': pytest.main([__file__, '-v'])