from __future__ import annotations

import pytest
from django.test import override_settings
from django.urls import reverse


@pytest.mark.django_db
@override_settings(
    ALUMNI_SOCIAL_EMBEDS={
        "linkedin_company_url": "https://www.linkedin.com/company/ruforum/",
        "twitter_handle": "RUFORUMNetwork",
        "enabled": True,
    }
)
def test_social_feed_renders_when_enabled(client):
    resp = client.get(reverse("alumni_profiles:directory"))
    assert resp.status_code == 200
    body = resp.content.decode()
    assert "linkedin.com/company/ruforum" in body
    assert "twitter.com/RUFORUMNetwork" in body or "@RUFORUMNetwork" in body


@pytest.mark.django_db
@override_settings(
    ALUMNI_SOCIAL_EMBEDS={
        "linkedin_company_url": "https://www.linkedin.com/company/ruforum/",
        "twitter_handle": "RUFORUMNetwork",
        "enabled": False,
    }
)
def test_social_feed_skipped_when_disabled(client):
    resp = client.get(reverse("alumni_profiles:directory"))
    assert resp.status_code == 200
    body = resp.content.decode()
    assert "platform.twitter.com/widgets.js" not in body
    assert "twitter-timeline" not in body
