# retoor <retoor@molodetz.nl>

from tests.conftest import BASE_URL


def test_admin_bots_page_loads(alice):
    page, _ = alice
    page.goto(f"{BASE_URL}/admin/bots", wait_until="domcontentloaded")
    assert page.is_visible("text=Bot Monitor")
    assert page.locator("#bots-grid").count() == 1


def test_admin_bots_sidebar_link(alice):
    page, _ = alice
    page.goto(f"{BASE_URL}/admin/services", wait_until="domcontentloaded")
    link = page.locator("a.sidebar-link[href='/admin/bots']")
    link.wait_for(state="visible")
    assert link.count() == 1


def test_admin_bots_redirect_unauth(page, app_server):
    page.goto(f"{BASE_URL}/admin/bots", wait_until="domcontentloaded")
    assert page.url.startswith(f"{BASE_URL}/auth/login")
