"""
Smoke tests for base.html — AC 2, 3, 5, 6 (Story 2.1).

Tests that:
- GET / returns 200 with full HTML (not plain text)
- All 8 nav sections are linked in the response
- active_page='dashboard' marks the dashboard link with aria-current="page"
- 404 renders an HTML template (not plain "Not Found" text)
- All 4 flash categories render correctly
"""


class TestBaseTemplate:
    def test_index_returns_200_with_html(self, client):
        resp = client.get('/')
        assert resp.status_code == 200
        assert b'<html' in resp.data

    def test_nav_contains_all_section_links(self, client):
        resp = client.get('/')
        data = resp.data
        assert b'/transactions/' in data
        assert b'/budgets/' in data
        assert b'/bills/' in data
        assert b'/paydown/' in data
        assert b'/import/' in data
        assert b'/analytics/' in data
        assert b'/settings/' in data

    def test_dashboard_active_page_aria_current(self, client):
        resp = client.get('/')
        assert b'aria-current="page"' in resp.data

    def test_404_returns_html_template(self, client):
        resp = client.get('/this-path-does-not-exist-anywhere')
        assert resp.status_code == 404
        assert b'<html' in resp.data
        # Should NOT be plain text "Not Found"
        assert resp.data.strip() != b'Not Found'

    def test_flash_success_renders(self, client):
        with client.session_transaction() as sess:
            sess['_flashes'] = [('success', 'It worked!')]
        resp = client.get('/')
        assert b'It worked!' in resp.data
        assert b'flash-success' in resp.data

    def test_flash_error_renders(self, client):
        with client.session_transaction() as sess:
            sess['_flashes'] = [('error', 'Something failed')]
        resp = client.get('/')
        assert b'Something failed' in resp.data
        assert b'flash-error' in resp.data

    def test_flash_warning_renders(self, client):
        with client.session_transaction() as sess:
            sess['_flashes'] = [('warning', 'Watch out')]
        resp = client.get('/')
        assert b'Watch out' in resp.data
        assert b'flash-warning' in resp.data

    def test_flash_info_renders(self, client):
        with client.session_transaction() as sess:
            sess['_flashes'] = [('info', 'FYI message')]
        resp = client.get('/')
        assert b'FYI message' in resp.data
