from pathlib import Path


def test_opportunity_board_uses_central_next_action():
    text = Path('app/admin_ui/pages/opportunities.py').read_text()
    assert 'def _attach_central_next_actions' in text
    assert 'get_opportunity_next_action(oid)' in text
    assert '_attach_central_next_actions(opportunities)' in text
    assert 'central.get("label")' in text
    assert 'CLOSE_OPPORTUNITY' in text
    assert 'Choose the visual column from the same first-safe-action precedence.' in text
    assert 'pending_primary_action_code' in text


def test_board_columns_follow_central_finance_and_operations():
    text = Path('app/admin_ui/pages/opportunities.py').read_text()
    assert 'effective_code in {"SEND_INVOICE", "SEND_PROFORMA", "CONFIRM_PAYMENT", "FOLLOW_UP_PAYMENT"}' in text
    assert '"PREPARE_ORDER", "CREATE_SHIPMENT", "WAIT_PRODUCTION", "WAIT_ODOO"' in text
    assert 'reconstructed_review_required(metadata)' in text


def test_operational_cockpit_uses_whout_and_hides_production_step():
    text = Path('app/admin_dashboard.py').read_text()
    assert 'def physical_whout_done()' in text
    assert 'ensure_card("odoo_physical_status", label="Estado físico Odoo", status="shipped"' in text
    assert 'ensure_card("packlink_shipment", label="Envio", status="done"' in text
    assert 'if key == "odoo_production":' in text
    assert 'WH/MO/production is technical Odoo detail only' in text


def test_wait_production_label_renamed_to_whout():
    text = Path('config/company_profiles/blif/labels.yaml').read_text()
    assert 'WAIT_PRODUCTION:' in text
    assert 'label: Aguardar WH/OUT' in text
    assert 'WH/MO é detalhe técnico' in text
