Files
BEYOND/scripts/pruebas.sh
T
Jorem JuárezandClaude Opus 5 e0764ef792 Resucita el widget de la foto y corrige el revestimiento de Clientes
El menú de la foto no aparecía nunca: el contenedor llevaba overflow:hidden
para redondear la imagen y el menú cuelga de su borde inferior con top:100%,
así que se renderizaba recortado. Las tres opciones estaban en el DOM y eran
inalcanzables. El redondeo lo hace ahora cada hijo por su cuenta.

Detrás había dos defectos más que nadie podía ver desde la interfaz porque el
primero tapaba el camino. useExternalListener se importaba de
@web/core/utils/hooks, donde no existe: el diálogo de la cámara reventaba al
renderizar con un error opaco de OWL, siempre, también en producción. Y
alternarMenu hacía «abierto = fijado || abierto», que nunca cierra: en tablet,
donde no hay mouse que sacar, el menú se quedaba pegado.

Los tres los cazó el navegador. Dockerfile.test agrega Chromium a la MISMA
imagen fijada por digest que producción, y pruebas.sh corre la suite ahí
dentro: sin navegador, Odoo SALTA las pruebas de JavaScript y reporta verde,
que es como un widget muerto convivió con la suite en verde. Un test propio
ejecuta las unitarias de beyond_base sin arrastrar las ~3700 del core. Doce
unitarias cubren el menú, la degradación sin cámara, la trasera por defecto,
el cambio de cámara y la liberación del stream al cerrar y con Escape; una de
ellas afirma que nadie recorta el menú, porque contar elementos no detectaba
el defecto: el nodo estaba ahí.

Del revestimiento: las notas dejan de mostrar las etiquetas HTML en crudo, la
ficha ocupa el ancho completo —la segunda columna quedó vacía al irse RFC,
sitio, categorías e idioma—, ciudad y estado se leen uno bajo otro, y
Anonimizar baja del <header> al pie, junto a Guardar y Descartar y como acción
secundaria: en la franja de estados parecía la acción principal.

Las iniciales colapsaban a una franja porque el envoltorio de Odoo no tiene
altura propia, y el tamaño en em se resolvía contra la tipografía heredada.
Las tarjetas fantasma eran las que Odoo mete para cuadrar la retícula, a las
que el revestimiento pintaba fondo y borde.

En datos demo: los avatares de colores no eran iniciales sino monogramas
guardados COMO foto; se repintan en la paleta del panel. Los usuarios demo
heredaban la foto del usuario plantilla y por eso la barra nunca mostraba el
avatar naranja. Y el cliente con foto usa ahora una ilustración propia en vez
de la imagen de una empleada.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-26 10:35:54 -06:00

152 lines
6.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Beyond test suite, on a throwaway database.
#
# WHY A CLEAN DATABASE. beyond_dev accumulates state that has nothing to do
# with the code: uninstalled modules, leftover demo companies, taxes edited by
# hand. Six tests failed there for reasons none of us caused, and a baseline
# that is not zero stops being a signal — nobody reads "6 failed" twice.
# The suite now runs against a database created from scratch on every run, so
# a failure means the code, always.
#
# beyond_dev is for looking at screens; this is for knowing whether it works.
#
# EL NAVEGADOR. The suite runs inside a throwaway container built from
# Dockerfile.test, which is the runtime image plus a pinned Chromium. Odoo
# drives it through browser_js to run the hoot unit tests and the tours;
# WITHOUT a browser it skips them and reports green. The dev compose and the
# production image are untouched — this is a third artifact, the same one the
# CI will use.
#
# The database is dropped at the end, including when a test fails. Keep it for
# a post mortem with: ./scripts/pruebas.sh --conservar
#
# Uso:
# ./scripts/pruebas.sh # los seis módulos
# ./scripts/pruebas.sh beyond_base # solo uno (y sus dependencias)
# ./scripts/pruebas.sh --conservar # no borra la base al terminar
set -euo pipefail
DB="${BEYOND_TEST_DB:-beyond_test}"
MODULOS="beyond_base,beyond_branch,beyond_customer,beyond_product_capture,beyond_attendance_qr,beyond_pos_theme"
CONSERVAR=0
SUITE_COMPLETA=1
for arg in "$@"; do
case "$arg" in
--conservar) CONSERVAR=1 ;;
--*) echo "Opción desconocida: $arg" >&2; exit 2 ;;
*) MODULOS="$arg"; SUITE_COMPLETA=0 ;;
esac
done
# Ports of their own. The suite now runs in its own container, so the clash
# with the dev server is gone, but the values stay explicit: the browser tests
# build their URLs from them.
PUERTO="${BEYOND_TEST_PORT:-8169}"
PUERTO_GEVENT="${BEYOND_TEST_GEVENT_PORT:-8172}"
limpiar() {
if [ "$CONSERVAR" -eq 1 ]; then
echo "[*] La base $DB se conserva (--conservar)."
return
fi
echo "[*] Borrando la base de pruebas $DB..."
# --force: Odoo leaves its connection pool open for a moment after
# --stop-after-init and plain dropdb refuses while anyone is attached.
docker compose exec -T db dropdb -U odoo --if-exists --force "$DB" || true
}
trap limpiar EXIT
echo "[*] Creando la base de pruebas $DB desde cero..."
docker compose exec -T db dropdb -U odoo --if-exists --force "$DB"
docker compose exec -T db createdb -U odoo -O odoo "$DB"
# Only OUR tests. --test-enable alone runs every installed module's suite,
# which here means ~3700 core tests, many of them browser tours that cannot
# pass without chromium in the container. Their noise is exactly what this
# script exists to remove.
ETIQUETAS="$(echo "$MODULOS" | tr ',' '\n' | sed 's|^|/|' | paste -sd, -)"
IMAGEN="${BEYOND_TEST_IMAGE:-beyond-test:local}"
RED="${BEYOND_TEST_NETWORK:-beyond_default}"
echo "[*] Construyendo la imagen de pruebas ($IMAGEN)..."
docker build -q -f Dockerfile.test -t "$IMAGEN" . > /dev/null
echo "[*] Instalando $MODULOS con datos demo y corriendo su suite..."
# -i and not -u: the point is a fresh install.
#
# --with-demo is REQUIRED, not decoration: in Odoo 19 demo data is off by
# default for new databases ("--without-demo ... (default)"), and beyond_dev
# only has it because it was created through the database manager with the box
# ticked. Without this flag there are no demo branches and the tests that look
# one up fail on an empty search. The demo data is also part of what has to
# keep working (CLAUDE.md, "demostrarlo en 2 minutos").
# --shm-size=1g: Chromium comparte memoria entre procesos por /dev/shm, y el
# valor por defecto de Docker (64 MB) lo hace caerse a media suite con
# «Target crashed». Es la causa clásica de una suite de navegador intermitente.
# --network: para alcanzar el Postgres del compose por su nombre de servicio,
# que es el que ya trae odoo.conf.
docker run --rm \
--network "$RED" \
--shm-size=1g \
-e PGPASSWORD="$(grep -E '^DB_PASSWORD=' .env | cut -d= -f2-)" \
-v "$PWD/addons:/mnt/extra-addons:ro" \
-v "$PWD/odoo.conf:/etc/odoo/odoo.conf:ro" \
"$IMAGEN" \
odoo -d "$DB" -i "$MODULOS" --with-demo \
--test-enable --test-tags="$ETIQUETAS" --stop-after-init \
--http-port="$PUERTO" --gevent-port="$PUERTO_GEVENT" \
2>&1 | tee /tmp/beyond_pruebas.log | grep -E \
"(FAIL|ERROR): Test|Traceback|tests\.stats|failed, .* error|Modules loaded" || true
# ── Fallos esperados ──────────────────────────────────────────────────────
# Known-failing tests, with the ticket that owns each one. They are NOT
# silenced: they are counted and listed on every run, so the baseline stays
# honest and a NEW failure stands out immediately. A test that stops failing
# is also reported, so this list does not rot.
#
# ADR-014 (docs/adr/ADR-014-impuesto-propio.md): a clean install has no 16%
# tax at all, because l10n_mx only auto-installs when a company's country is
# Mexico and ours is set to the United States. The guarantee of ADR-010 —the
# displayed price is the total to pay— has nothing to stand on. These five
# tests are right and the product is wrong; they stay red until ADR-014 is
# decided.
ESPERADOS="TestBeyondIvaIncluido.test_el_iva_de_venta_esta_incluido_en_el_precio
TestBeyondIvaIncluido.test_la_aritmetica_es_de_extraccion_no_de_suma
TestBeyondIvaIncluido.test_repara_una_base_donde_el_iva_se_suma
TestBeyondIvaConCajaAbierta.test_al_cerrar_la_caja_entra_solo
TestBeyondIvaConCajaAbierta.test_con_una_venta_viva_se_difiere_en_vez_de_reventar"
REALES="$(grep -oE '(FAIL|ERROR): [A-Za-z0-9_]+\.[A-Za-z0-9_]+' /tmp/beyond_pruebas.log \
| sed -E 's/^(FAIL|ERROR): //' | sort -u)"
ESPERADOS_ORD="$(echo "$ESPERADOS" | sort -u)"
INESPERADOS="$(comm -23 <(echo "$REALES") <(echo "$ESPERADOS_ORD") | sed '/^$/d')"
ARREGLADOS="$(comm -13 <(echo "$REALES") <(echo "$ESPERADOS_ORD") | sed '/^$/d')"
echo
# Solo tiene sentido con la suite completa: corriendo un módulo suelto, los
# esperados de otro no aparecen y se leerían como «ya pasan».
if [ -n "$ARREGLADOS" ] && [ "$SUITE_COMPLETA" -eq 1 ]; then
echo "[!] Estos tests estaban en la lista de esperados y ya PASAN."
echo " Quítalos de ESPERADOS en este script:"
echo "$ARREGLADOS" | sed 's/^/ /'
echo
fi
ESPERADOS_VIVOS="$(comm -12 <(echo "$REALES") <(echo "$ESPERADOS_ORD") | sed '/^$/d')"
if [ -n "$ESPERADOS_VIVOS" ]; then
echo "[i] Fallos esperados (ADR-014, siguen rojos a propósito): $(echo "$ESPERADOS_VIVOS" | wc -l | tr -d ' ')"
echo "$ESPERADOS_VIVOS" | sed 's/^/ /'
echo
fi
if [ -n "$INESPERADOS" ]; then
echo "[X] Fallos NUEVOS, no esperados:"
echo "$INESPERADOS" | sed 's/^/ /'
echo " Registro completo: /tmp/beyond_pruebas.log"
exit 1
fi
echo "[OK] Sin fallos nuevos sobre base limpia."