feat(bandejas): país de la lista según lo que es, Siguiente pendiente en Alertas y nombre del cliente en las listas
This commit is contained in:
1 parent
5a18e69570
commit
fd3dd06a00
23 files changed
+247
-18
No files matched your search
@@ -220,3 +220,79 @@ def test_la_bandeja_ofrece_dictaminar_solo_en_las_pendientes(
|
||||
assert f"/alertas/{historica_id}#gestion" not in html and "data-dictaminar" not in html
|
||||
# El botón lleva a la tarjeta de gestión del detalle.
|
||||
assert 'id="gestion"' in cliente.get(f"/alertas/{abierta_id}").text
|
||||
|
||||
|
||||
def test_siguiente_pendiente_primero_las_vencidas_luego_por_vencimiento(
|
||||
fabrica, tmp_path: Path, cliente: TestClient, monkeypatch
|
||||
) -> None:
|
||||
from datetime import timedelta
|
||||
|
||||
hoy = date(2026, 11, 16)
|
||||
monkeypatch.setattr("app.fechas.hoy", lambda: hoy)
|
||||
_cargar_base(fabrica, tmp_path)
|
||||
with fabrica() as sesion:
|
||||
modelo = sesion.scalars(sa.select(Alerta).order_by(Alerta.id)).first()
|
||||
ids = {}
|
||||
for clave, vence, estado in (
|
||||
("sin_fecha", None, "nueva"),
|
||||
("en_10", hoy + timedelta(days=10), "en_revision"),
|
||||
("vencida", hoy - timedelta(days=3), "nueva"),
|
||||
("en_2", hoy + timedelta(days=2), "nueva"),
|
||||
("escalada", hoy - timedelta(days=9), "escalada"), # ya tiene caso: no se dictamina
|
||||
):
|
||||
a = Alerta(
|
||||
tenant_id=modelo.tenant_id, created_by="pytest", regla_id=modelo.regla_id,
|
||||
cliente_id=modelo.cliente_id, nivel="preventiva", estado=estado, evidencia={},
|
||||
vence_el=vence,
|
||||
) # fmt: skip
|
||||
sesion.add(a)
|
||||
sesion.flush()
|
||||
ids[clave] = a.id
|
||||
sesion.commit()
|
||||
entrar_empresa(cliente, Rol.OFICIAL)
|
||||
orden = []
|
||||
desde = None
|
||||
for _ in range(4):
|
||||
r = cliente.get("/alertas/siguiente" + (f"?desde={desde}" if desde else ""))
|
||||
assert r.status_code == 303
|
||||
desde = int(r.headers["location"].rsplit("/", 1)[1])
|
||||
orden.append(desde)
|
||||
with fabrica() as sesion: # se dictamina: la cierra y pide la siguiente
|
||||
sesion.get(Alerta, desde).estado = "cerrada"
|
||||
sesion.commit()
|
||||
assert orden == [ids["vencida"], ids["en_2"], ids["en_10"], ids["sin_fecha"]]
|
||||
# Dictaminada, el detalle ofrece «Siguiente pendiente»; sin pendientes, vuelve a la bandeja.
|
||||
assert "data-siguiente-pendiente" in cliente.get(f"/alertas/{desde}").text
|
||||
final = cliente.get(f"/alertas/siguiente?desde={desde}")
|
||||
assert final.headers["location"] == "/alertas?aviso=Sin+alertas+pendientes"
|
||||
assert 'data-toast="Sin alertas pendientes"' in cliente.get(final.headers["location"]).text
|
||||
# La escalada no muestra «Dictaminar» en la bandeja (se resuelve en su caso).
|
||||
html = cliente.get("/alertas?estado=escalada").text
|
||||
assert f"/alertas/{ids['escalada']}#gestion" not in html
|
||||
|
||||
|
||||
def test_las_listas_muestran_el_nombre_y_no_el_identificador(
|
||||
fabrica, tmp_path: Path, cliente: TestClient
|
||||
) -> None:
|
||||
_cargar_base(fabrica, tmp_path)
|
||||
with fabrica() as sesion:
|
||||
tenant = sesion.scalar(sa.select(Tenant).where(Tenant.clave == "demo"))
|
||||
alerta = sesion.scalars(sa.select(Alerta).order_by(Alerta.id)).first()
|
||||
alerta.estado = "nueva" # abierta: aparece en la tabla de Inicio
|
||||
sesion.commit()
|
||||
nombre = nombres_para_mostrar(sesion, tenant, [alerta.cliente_id])[alerta.cliente_id]
|
||||
id_externo = sesion.get(Cliente, alerta.cliente_id).id_externo
|
||||
pendientes = servicio_inicio.pendientes(sesion, tenant)
|
||||
assert [a.cliente for a in pendientes.alertas if a.id == alerta.id] == [nombre]
|
||||
entrar_empresa(cliente, Rol.OFICIAL)
|
||||
for ruta in (
|
||||
"/inicio",
|
||||
"/cartera",
|
||||
"/creditos",
|
||||
"/operaciones",
|
||||
"/riesgo",
|
||||
f"/alertas/{alerta.id}",
|
||||
):
|
||||
html = cliente.get(ruta).text
|
||||
assert nombre in html, ruta
|
||||
assert f">{id_externo}</a>" not in html, ruta
|
||||
@@ -703,3 +703,30 @@ def test_bandeja_con_boton_revisar_cotejo_y_siguiente_pendiente(
|
||||
# Sin pendientes: de vuelta a la bandeja con el mensaje.
|
||||
assert siguiente.headers["location"].startswith("/screening?aviso=Sin+coincidencias+pendientes")
|
||||
assert "Sin coincidencias pendientes" in cliente.get(siguiente.headers["location"]).text
|
||||
|
||||
|
||||
def test_el_pais_de_la_lista_dice_si_es_nacionalidad_o_domicilio(
|
||||
cliente: TestClient, fabrica: sessionmaker[Session]
|
||||
) -> None:
|
||||
assert importador.etiqueta_pais("onu", "fisica") == "Nacionalidad"
|
||||
assert importador.etiqueta_pais("onu", "moral") == "País (domicilio)"
|
||||
assert importador.etiqueta_pais("sat_69b", "moral") == "País (domicilio)"
|
||||
assert importador.etiqueta_pais("pep", "fisica") == "País (cargo)"
|
||||
cliente_id = alta(cliente, "Muhammad", "Zaydan")
|
||||
with fabrica() as sesion:
|
||||
onu = sesion.scalar(sa.select(Lista.id).where(Lista.nombre == "onu"))
|
||||
tenant_id = sesion.get(Cliente, cliente_id).tenant_id
|
||||
entidad = Coincidencia(
|
||||
tenant_id=tenant_id, created_by="pytest", persona_id=cliente_id, lista_id=onu,
|
||||
texto_lista="EMPRESA FICTICIA INTERNACIONAL", score=90, decision="pendiente",
|
||||
fuente="screening", detalle={"tipo_persona": "moral", "pais": "Cuba"},
|
||||
) # fmt: skip
|
||||
sesion.add(entidad)
|
||||
sesion.commit()
|
||||
entidad_id = entidad.id
|
||||
bandeja = cliente.get("/screening?lista=onu").text
|
||||
assert "Nacionalidad o país" in bandeja
|
||||
assert 'Cuba<small class="cotejo__rotulo" data-pais-rotulo>País (domicilio)</small>' in bandeja
|
||||
detalle = cliente.get(f"/screening/{entidad_id}").text
|
||||
assert "<dt data-pais-rotulo>País (domicilio)</dt>" in detalle
|
||||
assert "<dt>Nacionalidad</dt><dd>México</dd>" in detalle
|
||||
Reference in new issue
Block a user