from pathlib import Path

ROOT = Path('/home/fizzlepoof/repos/truenas-stacks/home')


def read(relative_path: str) -> str:
    return (ROOT / relative_path).read_text()


def test_hot_fuzz_theme_markers_exist_across_doris_sites() -> None:
    expectations = {
        'doris-kitchen/app/templates/base.html': [
            'doris-hot-fuzz',
            'Doris Constabulary',
            'N.W.A. Case File',
            'hot-fuzz-art',
            'constable-silhouette',
            'swan-stamp',
            'cinematic-glow',
            'app-casefile app-casefile-kitchen',
            'Pantry Evidence',
            'recipe-evidence-tag',
        ],
        'doris-schoolhouse/app/templates/base.html': [
            'doris-hot-fuzz',
            'Doris Constabulary',
            'N.W.A. Case File',
            'hot-fuzz-art',
            'constable-silhouette',
            'swan-stamp',
            'cinematic-glow',
            'app-casefile app-casefile-schoolhouse',
            'Records Intake',
            'coursework-evidence-tag',
        ],
        'doris-barbell/app/templates/base.html': [
            'doris-hot-fuzz',
            'Doris Constabulary',
            'N.W.A. Case File',
            'hot-fuzz-art',
            'constable-silhouette',
            'swan-stamp',
            'cinematic-glow',
            'app-casefile app-casefile-barbell',
            'Training Dossier',
            'barbell-evidence-tag',
        ],
        'doris-dashboard/bin/generate_dashboard.py': [
            'Doris Constabulary',
            'N.W.A. Case File',
            'for-the-greater-good',
            'hot-fuzz-art',
            'constable-silhouette',
            'swan-stamp',
            'cinematic-glow',
            'Operator Evidence Board',
            'operator-evidence-tag',
            'hero-board',
            'lead-warrant',
            'hero-slip-grid',
        ],
    }

    for relative_path, markers in expectations.items():
        content = read(relative_path)
        for marker in markers:
            assert marker in content, f'{marker} missing from {relative_path}'


def test_hot_fuzz_theme_tokens_exist_in_site_stylesheets() -> None:
    expectations = {
        'doris-kitchen/app/static/app.css': ['--hf-red', '--hf-amber', '.incident-tape', '.casefile-header', '.hot-fuzz-art', '.constable-silhouette', '.swan-stamp', '.cinematic-glow', '.app-casefile', '.film-grain', '@keyframes emergencyPulse', '.evidence-board', '.case-legend', '.dossier-grid'],
        'doris-schoolhouse/app/static/app.css': ['--hf-red', '--hf-amber', '.incident-tape', '.casefile-header', '.hot-fuzz-art', '.constable-silhouette', '.swan-stamp', '.cinematic-glow', '.app-casefile', '.film-grain', '@keyframes emergencyPulse', '.evidence-board', '.case-legend', '.dossier-grid'],
        'doris-barbell/app/static/app.css': ['--hf-red', '--hf-amber', '.incident-tape', '.casefile-header', '.hot-fuzz-art', '.constable-silhouette', '.swan-stamp', '.cinematic-glow', '.app-casefile', '.film-grain', '@keyframes emergencyPulse', '.evidence-board', '.case-legend', '.dossier-grid'],
        'doris-dashboard/public/style.css': ['--hf-red', '--hf-amber', '.incident-tape', '.casefile-header', '.hot-fuzz-art', '.constable-silhouette', '.swan-stamp', '.cinematic-glow', '.app-casefile', '.film-grain', '@keyframes emergencyPulse', '.evidence-board', '.case-legend', '.dossier-grid', '.hero-board', '.hero-dossier-card', '.hero-slip-grid'],
    }

    for relative_path, markers in expectations.items():
        content = read(relative_path)
        for marker in markers:
            assert marker in content, f'{marker} missing from {relative_path}'


def test_interior_casefile_markers_exist_on_key_pages() -> None:
    expectations = {
        'doris-kitchen/app/templates/dashboard.html': ['evidence-board', 'case-legend', 'Kitchen queue board', 'dossier-grid'],
        'doris-kitchen/app/templates/search.html': ['evidence-board', 'case-legend', 'Lead intake', 'Search warrant'],
        'doris-schoolhouse/app/templates/dashboard.html': ['evidence-board', 'case-legend', 'Course board', 'dossier-grid'],
        'doris-schoolhouse/app/templates/assignment_upload.html': ['evidence-board', 'chain-of-custody', 'Submission packet', 'intake-docket'],
        'doris-barbell/app/templates/dashboard.html': ['evidence-board', 'case-legend', 'Training floor board', 'dossier-grid'],
        'doris-dashboard/bin/generate_dashboard.py': ['evidence-board', 'case-legend', 'Operator board', 'dossier-grid'],
    }

    for relative_path, markers in expectations.items():
        content = read(relative_path)
        for marker in markers:
            assert marker in content, f'{marker} missing from {relative_path}'
