fix: align opportunity UI with canonical current action
This commit is contained in:
58
tests/test_opportunity_current_action_consistency.py
Normal file
58
tests/test_opportunity_current_action_consistency.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from pathlib import Path
|
||||
from inspect import getsource
|
||||
|
||||
from app.admin_ui.pages.opportunities import (
|
||||
_opportunity_board_column_for_opportunity,
|
||||
_opportunity_card_next_action,
|
||||
)
|
||||
|
||||
|
||||
def opportunity(**overrides):
|
||||
item = {
|
||||
"id": "opp-1",
|
||||
"stage": "INVOICE_REQUESTED",
|
||||
"status": "open",
|
||||
"lifecycle_state": "active",
|
||||
"pending_task_count": 2,
|
||||
"pending_primary_action_code": "SEND_INVOICE",
|
||||
"pending_primary_action": "Enviar fatura ao cliente",
|
||||
"clientflow_next_action": {
|
||||
"action_code": "RECONCILE_DOCUMENTS",
|
||||
"label": "Associar orçamento enviado",
|
||||
"description": "Documento enviado ainda não associado.",
|
||||
},
|
||||
"metadata": {},
|
||||
}
|
||||
item.update(overrides)
|
||||
return item
|
||||
|
||||
|
||||
def test_board_primary_action_uses_structured_decision_not_stale_pending_task():
|
||||
assert _opportunity_card_next_action(opportunity()) == "Associar orçamento enviado"
|
||||
|
||||
|
||||
def test_board_column_uses_structured_decision_not_stale_financial_task():
|
||||
assert _opportunity_board_column_for_opportunity(opportunity()) != "payment"
|
||||
|
||||
|
||||
def test_detail_does_not_replace_structured_decision_with_arbitrary_pending_task():
|
||||
source = Path("app/admin_ui/pages/opportunities.py").read_text(encoding="utf-8")
|
||||
detail = source[source.index("async def opportunity_detail_page"):]
|
||||
assert "elif not lifecycle_override and next_task:" not in detail
|
||||
|
||||
|
||||
def test_explicit_scheduled_call_remains_a_valid_primary_override():
|
||||
opp = opportunity(
|
||||
lifecycle_state="active",
|
||||
pending_follow_up_action_code="CALL_CUSTOMER",
|
||||
pending_follow_up_action="Ligar ao cliente",
|
||||
pending_follow_up_due_at="2099-08-21T09:00:00+00:00",
|
||||
)
|
||||
assert _opportunity_card_next_action(opp).startswith("Ligar ao cliente em")
|
||||
|
||||
|
||||
def test_opportunity_list_read_path_does_not_attempt_schema_writes():
|
||||
from app.opportunity_service import list_opportunities
|
||||
|
||||
source = getsource(list_opportunities)
|
||||
assert "ensure_opportunity_schema()" not in source
|
||||
Reference in New Issue
Block a user