# Part of Beyond. Collina Systems proprietary module. import pathlib from odoo.modules.module import get_manifest from odoo.addons.beyond_branch.tests.common import BeyondBranchCase from odoo.tests import TransactionCase, tagged from odoo.tools import file_open @tagged('post_install', '-at_install') class TestBeyondPosThemeAssets(TransactionCase): """Fase 0 (spike D1): el tema queda registrado en el bundle del POS y sus archivos existen. La evaluación visual es manual contra las pantallas de referencia (ADR-001).""" def test_assets_declarados_en_bundle_pos(self): manifest = get_manifest('beyond_pos_theme') bundle = manifest['assets'].get('point_of_sale._assets_pos', []) self.assertIn('beyond_pos_theme/static/src/scss/beyond_pos.scss', bundle) self.assertIn('beyond_pos_theme/static/src/xml/product_card.xml', bundle) def test_archivos_del_tema_existen(self): for path in ( 'beyond_pos_theme/static/src/scss/beyond_pos.scss', 'beyond_pos_theme/static/src/xml/product_card.xml', ): with file_open(path) as handle: self.assertTrue(handle.read().strip(), f"{path} está vacío") def test_la_tarjeta_no_pinta_el_precio_base(self): """ADR-009: con lista de precios por sucursal, list_price en la tarjeta es un número que la caja no cobra. El precio sale del getter beyondPrice, que aplica la lista de la sucursal.""" with file_open('beyond_pos_theme/static/src/xml/product_card.xml') as handle: plantilla = handle.read() self.assertIn('beyondPrice', plantilla) self.assertNotIn('props.product.list_price', plantilla) manifest = get_manifest('beyond_pos_theme') bundle = manifest['assets'].get('point_of_sale._assets_pos', []) self.assertIn( 'beyond_pos_theme/static/src/product_card/product_card.js', bundle, 'el getter tiene que viajar en el bundle del POS') with file_open('beyond_pos_theme/static/src/product_card/product_card.js') as handle: self.assertIn('getPrice', handle.read()) def test_herencia_extiende_product_card(self): with file_open('beyond_pos_theme/static/src/xml/product_card.xml') as handle: contenido = handle.read() self.assertIn('t-inherit="point_of_sale.ProductCard"', contenido) self.assertIn('t-inherit-mode="extension"', contenido) def _xpath_del_parche(self, archivo): """Los xpath de nuestras herencias, para comprobarlos contra la plantilla REAL del core que trae esta imagen de Odoo. Se busca por nombre bajo static/src y no en una carpeta fija: las piezas viven junto a lo que retocan —control_buttons, navbar— y clavar la ruta obligaba a tocar este ayudante en cada pieza nueva. """ import re raiz = pathlib.Path('/mnt/extra-addons/beyond_pos_theme/static/src') piezas = list(raiz.rglob(archivo)) self.assertEqual(len(piezas), 1, f'no se encontró {archivo} bajo {raiz}') return re.findall(r'