diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..304ab5a --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,55 @@ +# Imagen de PRUEBAS de Beyond. +# +# The only thing it adds to the runtime image is a browser. Odoo runs its +# JavaScript suites — hoot unit tests AND tours — through browser_js, which +# drives a real Chrome in headless mode. Without one, `--test-enable` SKIPS +# them silently, and a widget can be dead in the interface while every test +# passes. That is not hypothetical: it happened, with the photo menu of +# beyond_image_camera. +# +# NOT the production image and NOT the dev compose: a third artifact, used by +# scripts/pruebas.sh and by the CI still pending in docs/despliegue.md. +# Producción no lleva navegador. +FROM odoo:19@sha256:84d09c623fc78050c2195161b98897995ba68c87aa4212d0ec0f4f3ce88c7610 + +USER root + +# Chromium de Playwright, fijado por versión de playwright. Tres candidatos +# quedaron descartados por motivos concretos: +# · Ubuntu `chromium` / `chromium-browser` en noble es un paquete de +# transición a snap (2:1snap1) que no se instala en un contenedor. +# · Chrome for Testing publica SOLO linux64 (x86-64), y las máquinas de +# desarrollo del proyecto son arm64: no arranca ni con emulación cómoda. +# · El repositorio apt de Google sirve siempre «la última», así que la +# versión no se puede fijar. +# Playwright publica builds de Chromium para arm64 y amd64 bajo la misma +# versión, así que ESTE MISMO Dockerfile produce el mismo navegador en la +# máquina de desarrollo y en la CI. Se sube a propósito, como el digest. +ARG PLAYWRIGHT_VERSION=1.56.0 +ENV PLAYWRIGHT_BROWSERS_PATH=/opt/navegador + +# python3-websocket: sin él Odoo SALTA las pruebas de navegador en vez de +# fallar — el verde silencioso que este archivo existe para eliminar. +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + python3-websocket python3-pip \ + ca-certificates fonts-liberation \ + libnss3 libnspr4 libdbus-1-3 libatk1.0-0t64 libatk-bridge2.0-0t64 \ + libcups2t64 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \ + libxfixes3 libxrandr2 libgbm1 libxshmfence1 libasound2t64 \ + libpango-1.0-0 libcairo2 libatspi2.0-0t64 \ + && pip3 install --no-cache-dir --break-system-packages \ + "playwright==${PLAYWRIGHT_VERSION}" \ + && python3 -m playwright install chromium \ + && pip3 uninstall -y --break-system-packages playwright \ + && apt-get purge -y python3-pip \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ + && chmod -R a+rX /opt/navegador + +# Odoo busca el ejecutable por nombre en PATH: google-chrome, chromium, +# chromium-browser o google-chrome-stable (odoo/tests/common.py). +RUN ln -sf "$(find /opt/navegador -name chrome -type f | head -1)" \ + /usr/local/bin/google-chrome + +USER odoo diff --git a/addons/beyond_base/static/src/fields/beyond_image_camera.js b/addons/beyond_base/static/src/fields/beyond_image_camera.js index c306ab1..c45847d 100644 --- a/addons/beyond_base/static/src/fields/beyond_image_camera.js +++ b/addons/beyond_base/static/src/fields/beyond_image_camera.js @@ -1,8 +1,11 @@ /** Part of Beyond. Collina Systems proprietary module. */ -import { Component, onWillUnmount, useRef, useState } from "@odoo/owl"; +import { Component, onWillUnmount, useExternalListener, useRef, useState } from "@odoo/owl"; import { Dialog } from "@web/core/dialog/dialog"; import { registry } from "@web/core/registry"; -import { useService, useExternalListener } from "@web/core/utils/hooks"; +// useExternalListener viene de OWL, NO de @web/core/utils/hooks: importarlo +// de ahí devuelve undefined y el diálogo de la cámara revienta al renderizar, +// sin decir por qué. Lo cazaron las unitarias en navegador. +import { useService } from "@web/core/utils/hooks"; import { browser } from "@web/core/browser/browser"; import { _t } from "@web/core/l10n/translation"; import { ImageField, imageField } from "@web/views/fields/image/image_field"; @@ -183,10 +186,17 @@ export class BeyondImageCamera extends ImageField { } } - /** Touch has no hover: a tap pins the menu open, another closes it. */ + /** + * Touch has no hover: a tap pins the menu open, another closes it. + * + * The second tap has to actually close it. `abierto = fijado || abierto` + * looked harmless and was not: once open, the right-hand side kept it + * open for ever and the menu could only be dismissed by moving a mouse + * the tablet does not have. + */ alternarMenu() { this.menu.fijado = !this.menu.fijado; - this.menu.abierto = this.menu.fijado || this.menu.abierto; + this.menu.abierto = this.menu.fijado; } cerrarMenu() { diff --git a/addons/beyond_base/static/tests/beyond_image_camera.test.js b/addons/beyond_base/static/tests/beyond_image_camera.test.js index 6049081..cc63896 100644 --- a/addons/beyond_base/static/tests/beyond_image_camera.test.js +++ b/addons/beyond_base/static/tests/beyond_image_camera.test.js @@ -1,6 +1,6 @@ /** Part of Beyond. Collina Systems proprietary module. */ import { expect, test, describe } from "@odoo/hoot"; -import { click, queryAll, queryFirst } from "@odoo/hoot-dom"; +import { click, press, queryAll, queryFirst } from "@odoo/hoot-dom"; import { animationFrame } from "@odoo/hoot-mock"; import { defineModels, @@ -10,6 +10,7 @@ import { patchWithCleanup, } from "@web/../tests/web_test_helpers"; import { browser } from "@web/core/browser/browser"; +import { defineMailModels } from "@mail/../tests/mail_test_helpers"; /** * Unit tests for beyond_image_camera. @@ -23,8 +24,11 @@ import { browser } from "@web/core/browser/browser"; describe.current.tags("desktop"); -class ResPartner extends models.Model { - _name = "res.partner"; +// Un modelo propio y NO res.partner: montar una vista sobre res.partner +// arrastra la maquinaria de mail (el chatter pide discuss.channel) y las +// pruebas mueren antes de llegar al widget. Al widget el modelo le da igual. +class BeyondFoto extends models.Model { + _name = "beyond.foto"; name = fields.Char(); image_1920 = fields.Binary(); @@ -32,22 +36,47 @@ class ResPartner extends models.Model { _records = [{ id: 1, name: "Alejandro Mcdonald", image_1920: "FOTO==" }]; } -defineModels([ResPartner]); +// Montar CUALQUIER formulario despierta la maquinaria de mail (el chatter +// pide discuss.channel) aunque la vista no lo lleve, porque mail parchea la +// vista de formulario en el bundle de pruebas. Sin esto, todas las pruebas +// mueren antes de llegar al widget. +defineMailModels(); +defineModels([BeyondFoto]); const VISTA = /* xml */ `
`; -/** Fakes a camera: one track whose stop() we can watch. */ +/** + * Fakes a camera: a REAL MediaStream whose track we can watch. + * + * It has to be a real one. Assigning a plain object to video.srcObject throws + * in Chromium ("the provided value is not of type MediaStream"), which showed + * up as an opaque "error in the owl lifecycle" and hid what was really being + * tested. A canvas gives us a genuine stream with a genuine track. + */ function camaraFalsa({ camaras = 1 } = {}) { - const pista = { stop: () => (pista.detenida = true), detenida: false, kind: "video" }; - const stream = { getTracks: () => [pista] }; + const lienzo = document.createElement("canvas"); + lienzo.width = 4; + lienzo.height = 4; + const stream = lienzo.captureStream(); + const pista = stream.getVideoTracks()[0]; + pista.detenida = false; + const detenerReal = pista.stop.bind(pista); + pista.stop = () => { + pista.detenida = true; + detenerReal(); + }; + pista.peticiones = []; patchWithCleanup(browser, { navigator: { ...browser.navigator, mediaDevices: { - getUserMedia: async () => stream, + getUserMedia: async (restricciones) => { + pista.peticiones.push(restricciones?.video?.facingMode); + return stream; + }, enumerateDevices: async () => Array.from({ length: camaras }, () => ({ kind: "videoinput" })), }, @@ -65,7 +94,7 @@ function sinCamara() { test("el menú de la foto se abre al pasar el mouse y se cierra al salir", async () => { camaraFalsa(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); expect(".beyond_foto_menu").toHaveCount(0); @@ -78,9 +107,43 @@ test("el menú de la foto se abre al pasar el mouse y se cierra al salir", async expect(".beyond_foto_menu").toHaveCount(0); }); +test("el contenedor de la foto no recorta el menú", async () => { + // ESTA es la prueba que faltaba. El menú se renderizaba —el t-if pasaba y + // el DOM lo tenía— pero el contenedor llevaba overflow:hidden para + // redondear la imagen, y el menú cuelga por debajo con top:100%: quedaba + // recortado y era inalcanzable. Contar elementos no lo detecta, porque el + // nodo está ahí; ni :visible, porque un elemento recortado conserva su + // tamaño. Lo que hay que afirmar es que nadie lo recorta. + camaraFalsa(); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); + + await click(".beyond_foto"); + await animationFrame(); + + const menu = queryFirst(".beyond_foto_menu"); + expect(menu).not.toBe(null); + // Solo hasta la hoja del formulario: de ahí para arriba el cliente web + // recorta a propósito (.o_form_view y .o_action_manager son sus + // contenedores de desplazamiento). Lo que no puede recortar es el propio + // widget, que es donde estaba el defecto. + // Solo los dos nodos que este widget controla. De ahí para arriba el + // cliente web recorta a propósito: .o_form_view y .o_action_manager son + // sus contenedores de desplazamiento y siempre llevan overflow:hidden. + for (const selector of [".beyond_foto", ".o_field_widget[name=image_1920]"]) { + const nodo = queryFirst(selector); + if (!nodo) { + continue; + } + const estilo = getComputedStyle(nodo); + expect(`${estilo.overflow} ${estilo.overflowY}`).not.toInclude("hidden", { + message: `${selector} recorta el menú de la foto`, + }); + } +}); + test("un toque fija el menú y otro lo suelta (en táctil no hay hover)", async () => { camaraFalsa(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -100,7 +163,7 @@ test("sin cámara no se ofrece «Tomar fotografía», y sí «Subir archivo»", // Es el caso de las tablets de sucursal mientras producción no tenga TLS: // fuera de contexto seguro el navegador ni siquiera define mediaDevices. sinCamara(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -112,7 +175,7 @@ test("sin cámara no se ofrece «Tomar fotografía», y sí «Subir archivo»", test("con cámara sí se ofrece «Tomar fotografía»", async () => { camaraFalsa(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -125,7 +188,7 @@ test("«Subir archivo» pide la cámara trasera, no la frontal", async () => { // Coherencia con el diálogo propio: el caso de uso es el mostrador // fotografiando al cliente, no una selfie. sinCamara(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -135,7 +198,7 @@ test("«Subir archivo» pide la cámara trasera, no la frontal", async () => { test("«Eliminar» limpia el campo", async () => { camaraFalsa(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -150,7 +213,7 @@ test("cerrar el diálogo apaga la cámara", async () => { // Una cámara que se queda encendida deja el testigo del aparato prendido // y parece que el local está grabando. const pista = camaraFalsa(); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -160,7 +223,7 @@ test("cerrar el diálogo apaga la cámara", async () => { expect(".beyond_camara_video").toHaveCount(1); expect(pista.detenida).toBe(false); - await click(".beyond_camara_dialogo .btn-secondary:last-child"); // Cancelar + await click(".beyond_camara_dialogo .modal-footer button:contains(Cancelar)"); await animationFrame(); expect(pista.detenida).toBe(true); @@ -168,7 +231,7 @@ test("cerrar el diálogo apaga la cámara", async () => { test("con una sola cámara no se ofrece cambiarla", async () => { camaraFalsa({ camaras: 1 }); - await mountView({ type: "form", resModel: "res.partner", resId: 1, arch: VISTA }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); await click(".beyond_foto"); await animationFrame(); @@ -181,3 +244,55 @@ test("con una sola cámara no se ofrece cambiarla", async () => { ); expect(botones).not.toInclude("Cambiar de cámara"); }); + + +test("el diálogo pide la cámara TRASERA por defecto", async () => { + // El caso de uso es el mostrador retratando al cliente, no una selfie. + const pista = camaraFalsa(); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); + + await click(".beyond_foto"); + await animationFrame(); + await click(".beyond_foto_opcion"); + await animationFrame(); + await animationFrame(); + + expect(pista.peticiones[0]).toBe("environment"); +}); + +test("el botón de cambio pasa a la cámara frontal", async () => { + const pista = camaraFalsa({ camaras: 2 }); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); + + await click(".beyond_foto"); + await animationFrame(); + await click(".beyond_foto_opcion"); + await animationFrame(); + await animationFrame(); + + await click(".beyond_camara_dialogo .modal-footer button:contains(Cambiar)"); + await animationFrame(); + await animationFrame(); + + expect(pista.peticiones).toEqual(["environment", "user"]); +}); + +test("cerrar con Escape también apaga la cámara", async () => { + // Cerrar con el teclado es la salida que más se olvida, y una cámara + // encendida deja el testigo del aparato prendido. + const pista = camaraFalsa(); + await mountView({ type: "form", resModel: "beyond.foto", resId: 1, arch: VISTA }); + + await click(".beyond_foto"); + await animationFrame(); + await click(".beyond_foto_opcion"); + await animationFrame(); + await animationFrame(); + expect(".beyond_camara_video").toHaveCount(1); + + await press("Escape"); + await animationFrame(); + + expect(".beyond_camara_dialogo").toHaveCount(0); + expect(pista.detenida).toBe(true); +}); diff --git a/addons/beyond_base/tests/__init__.py b/addons/beyond_base/tests/__init__.py index ebcc205..794d803 100644 --- a/addons/beyond_base/tests/__init__.py +++ b/addons/beyond_base/tests/__init__.py @@ -4,3 +4,4 @@ from . import test_menu_cleanup from . import test_security_groups from . import test_signup from . import test_panel_navbar +from . import test_unitarias_js diff --git a/addons/beyond_base/tests/test_unitarias_js.py b/addons/beyond_base/tests/test_unitarias_js.py new file mode 100644 index 0000000..04ac4e0 --- /dev/null +++ b/addons/beyond_base/tests/test_unitarias_js.py @@ -0,0 +1,32 @@ +# Part of Beyond. Collina Systems proprietary module. +from odoo.tests import HttpCase, tagged + +from odoo.addons.web.tests.test_js import unit_test_error_checker + +# Hoot identifica cada suite por un hash de su ruta. El de «@beyond_base» +# selecciona todas las unitarias de este módulo y ninguna ajena, para no +# arrastrar las ~3700 del core en cada corrida. El algoritmo es el de +# web/tests/test_js.py::HOOTCommon._generate_hash; si algún día cambia, este +# test empieza a correr de más, no de menos. +SUITE_BEYOND = 'd6e526c1' # @beyond_base + + +@tagged('post_install', '-at_install') +class TestBeyondUnitariasJS(HttpCase): + """Corre las unitarias JS de beyond_base en un navegador de verdad. + + Existe porque el runner de hoot vive en el módulo `web`: acotar la suite + con --test-tags=/beyond_base lo deja fuera, y entonces las unitarias no se + ejecutan y la corrida sale verde sin haberlas mirado. Eso ya nos pasó: el + menú de la foto estaba muerto en la interfaz con todas las pruebas en + verde. + """ + + def test_unitarias_de_beyond(self): + self.browser_js( + f'/web/tests?headless&loglevel=2&preset=desktop&timeout=15000' + f'&id={SUITE_BEYOND}', + "", "", login='admin', timeout=1800, + success_signal="[HOOT] Test suite succeeded", + error_checker=unit_test_error_checker, + ) diff --git a/addons/beyond_branch/demo/demo_branches.xml b/addons/beyond_branch/demo/demo_branches.xml index 61ffa77..b7cfd6b 100644 --- a/addons/beyond_branch/demo/demo_branches.xml +++ b/addons/beyond_branch/demo/demo_branches.xml @@ -30,6 +30,7 @@ beyond-demo-2026 + + Alejandro Mcdonald @@ -23,7 +27,7 @@ Av. Juárez 1820, La Paz Puebla Prefiere cita temprano. Alérgico al amoniaco. - + @@ -60,10 +64,12 @@ OJO al revisar: esto corre al INSTALAR, no al actualizar. Los archivos demo se cargan con semántica noupdate y convert.py salta los cuando el modo no es «init», así que una base que ya existía (como - beyond_dev) no se limpia con -u; hay que llamarlo una vez a mano: + beyond_dev) no se limpia sola con una actualización. Para limpiarla una + vez, desde el shell de Odoo: + + env['res.partner']._beyond_demo_limpiar_contactos_hijos() + env.cr.commit() - docker compose exec odoo odoo shell -d beyond_dev --no-http \ - <<< "env['res.partner']._beyond_demo_limpiar_contactos_hijos(); env.cr.commit()" --> diff --git a/addons/beyond_customer/static/demo/cliente_retrato.png b/addons/beyond_customer/static/demo/cliente_retrato.png new file mode 100644 index 0000000..4131af3 Binary files /dev/null and b/addons/beyond_customer/static/demo/cliente_retrato.png differ diff --git a/addons/beyond_customer/static/src/clientes.scss b/addons/beyond_customer/static/src/clientes.scss index 1897f09..a6bc0dc 100644 --- a/addons/beyond_customer/static/src/clientes.scss +++ b/addons/beyond_customer/static/src/clientes.scss @@ -112,9 +112,38 @@ body.beyond_panel { max-width: 40%; } - // Notas: un renglón que crece hasta 132px y luego se desplaza dentro, - // para que la ficha no se estire sin límite y el resto no se mueva. + // ── Ancho de la ficha ───────────────────────────────────────────────── + // El formulario nativo reparte sus grupos en dos columnas. Con la segunda + // vacía —se fueron RFC, sitio, categorías e idioma— la ficha se quedaba + // usando la mitad izquierda de la pantalla y la derecha en blanco. Cada + // grupo pasa a ocupar el ancho completo y se apilan. + .o_form_view .o_form_sheet > .o_group > .o_inner_group { + grid-column: 1 / -1; + + // La columna que quedó sin campos no debe dejar un hueco vertical. + &:empty { display: none; } + } + + // El bloque de dirección nativo mete ciudad y estado en el mismo renglón. + // El diseño los lee uno debajo de otro, cada uno con su marcador. + .o_address_format { + display: block; + + > .o_address_street, + > .o_address_city, + > .o_address_state, + > .o_wrap_field { + display: block; + width: 100%; + } + } + + // Notas: crecen hasta 132px y luego se desplazan dentro, para que la ficha + // no se estire sin límite y el resto no se mueva. Es un campo HTML, así + // que el editable es un div, no un textarea. .beyond_cliente_notas { + .odoo-editor-editable, + .o_field_html > div, textarea { min-height: 22px; max-height: 132px; @@ -124,6 +153,34 @@ body.beyond_panel { font-size: 15px; font-weight: 600; } + + // Sin márgenes de párrafo: el diseño es un renglón que crece, no un + // documento. + .odoo-editor-editable p { margin: 0; } + } + + // ── Pie de acciones ─────────────────────────────────────────────────── + .beyond_cliente_acciones { + display: flex; + justify-content: flex-end; + margin-top: 26px; + padding-top: 14px; + border-top: 1.5px solid $beyond-surface-hover; + } + + // Destructivo pero secundario: es la acción menos frecuente de la ficha y + // no debe competir con Guardar. Contorno, no relleno. + .beyond_boton_destructivo.btn, + .beyond_boton_destructivo.btn-secondary { + background: transparent; + border: 1.5px solid $beyond-panel-rojo; + color: $beyond-panel-rojo; + font-size: 13px; + + &:hover, &:focus-visible { + background: $beyond-panel-rojo-suave; + color: $beyond-panel-rojo; + } } // ── Responsivo ──────────────────────────────────────────────────────── diff --git a/addons/beyond_customer/tests/test_clientes_vistas.py b/addons/beyond_customer/tests/test_clientes_vistas.py index e39e864..87c392b 100644 --- a/addons/beyond_customer/tests/test_clientes_vistas.py +++ b/addons/beyond_customer/tests/test_clientes_vistas.py @@ -169,6 +169,31 @@ class TestClientesVistas(TransactionCase): with self.assertRaises(AccessError): self.cliente.with_user(gerente).action_beyond_anonymize() + def test_las_notas_no_son_texto_plano(self): + """comment es un campo HTML: con widget="text" se leían las etiquetas + en crudo, «

Prefiere cita temprano.

».""" + arch = etree.fromstring(self._arch('beyond_customer.view_beyond_cliente_form')) + notas = arch.xpath("//field[@name='comment']") + self.assertTrue(notas, "la ficha perdió las notas") + self.assertIsNone( + notas[0].get('widget'), + "las notas deben usar el widget propio de un campo HTML") + + def test_anonimizar_va_en_el_pie_y_es_secundario(self): + """En el
quedaba solo y enorme bajo el encabezado, como si + fuera la acción principal de la pantalla. Va al pie, con Guardar y + Descartar, y como acción secundaria.""" + arch = etree.fromstring(self._arch('beyond_customer.view_beyond_cliente_form')) + self.assertFalse( + arch.xpath("//header//button[@name='action_beyond_anonymize']"), + "anonimizar sigue en la franja de estados") + boton = arch.xpath( + "//div[@class='beyond_cliente_acciones']" + "/button[@name='action_beyond_anonymize']") + self.assertTrue(boton, "anonimizar no está en el pie de la ficha") + self.assertIn('btn-secondary', boton[0].get('class'), + "anonimizar no debe competir con Guardar") + # ── La acción y su dominio ─────────────────────────────────────────── def test_el_dominio_de_clientes_sigue_intacto(self): diff --git a/addons/beyond_customer/views/res_partner_views.xml b/addons/beyond_customer/views/res_partner_views.xml index e6706a1..c15e4f3 100644 --- a/addons/beyond_customer/views/res_partner_views.xml +++ b/addons/beyond_customer/views/res_partner_views.xml @@ -169,6 +169,10 @@ no pertenece a una compañía. --> + + + @@ -180,13 +184,14 @@ - + @@ -218,10 +223,22 @@ Contactos nativo conserva el suyo. --> - - - not id + + + +
+
diff --git a/addons/beyond_pos_theme/static/demo/cliente_alejandro.png b/addons/beyond_pos_theme/static/demo/cliente_alejandro.png index 4fcefda..bdff8b4 100644 Binary files a/addons/beyond_pos_theme/static/demo/cliente_alejandro.png and b/addons/beyond_pos_theme/static/demo/cliente_alejandro.png differ diff --git a/addons/beyond_pos_theme/static/demo/cliente_carmen.png b/addons/beyond_pos_theme/static/demo/cliente_carmen.png index 6a9f186..edee4b6 100644 Binary files a/addons/beyond_pos_theme/static/demo/cliente_carmen.png and b/addons/beyond_pos_theme/static/demo/cliente_carmen.png differ diff --git a/addons/beyond_pos_theme/static/demo/cliente_fernanda.png b/addons/beyond_pos_theme/static/demo/cliente_fernanda.png index 9c11640..c1320f1 100644 Binary files a/addons/beyond_pos_theme/static/demo/cliente_fernanda.png and b/addons/beyond_pos_theme/static/demo/cliente_fernanda.png differ diff --git a/scripts/pruebas.sh b/scripts/pruebas.sh index 43512dc..74790ff 100755 --- a/scripts/pruebas.sh +++ b/scripts/pruebas.sh @@ -10,6 +10,13 @@ # # 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 # @@ -22,18 +29,19 @@ 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" ;; + *) MODULOS="$arg"; SUITE_COMPLETA=0 ;; esac done -# Ports of their own: the dev server holds 8069 and the HttpCase tests need to -# bind something. Without this the whole run dies with "Address already in use" -# before a single test starts. +# 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}" @@ -59,6 +67,12 @@ docker compose exec -T db createdb -U odoo -O odoo "$DB" # 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. # @@ -68,8 +82,19 @@ echo "[*] Instalando $MODULOS con datos demo y corriendo su suite..." # 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"). -docker compose exec -T odoo odoo \ - -d "$DB" -i "$MODULOS" --with-demo \ +# --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 \ @@ -101,7 +126,9 @@ INESPERADOS="$(comm -23 <(echo "$REALES") <(echo "$ESPERADOS_ORD") | sed '/^$/d' ARREGLADOS="$(comm -13 <(echo "$REALES") <(echo "$ESPERADOS_ORD") | sed '/^$/d')" echo -if [ -n "$ARREGLADOS" ]; then +# 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/^/ /'