"""Bundle / feature toggle validation."""
from __future__ import annotations

import pytest

from app.tests.conftest import TENANT_A, tenant_headers


@pytest.mark.asyncio
async def test_hidden_bundle_not_active_by_default(client):
    caps = await client.get("/capabilities")
    assert caps.json()["features"]["pos_engine"] is False

    venue = await client.post(
        "/api/v1/venues",
        json={"code": "v1", "name": "Venue", "status": "active"},
        headers=tenant_headers(TENANT_A),
    )
    venue_id = venue.json()["id"]

    listed = await client.get(
        "/api/v1/tenant-bundles",
        headers=tenant_headers(TENANT_A),
    )
    assert listed.status_code == 200
    assert listed.json() == []

    # Feature remains disabled until explicitly toggled
    toggle = await client.post(
        "/api/v1/feature-toggles/upsert",
        json={
            "feature_key": "hospitality.pos_pro",
            "enabled": False,
            "venue_id": venue_id,
            "bundle_key": "pos_pro",
        },
        headers=tenant_headers(TENANT_A),
    )
    assert toggle.status_code == 200
    assert toggle.json()["enabled"] is False
