feat(web): alineación configurable (align) de las columnas del detalle de los documentos

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GeorgeandClaude Sonnet 5.5 committed 2026-10-16 11:23:44 -05:00
1 parent f25037f651
commit 8a38bd0502
5 files changed
+36 -8

No files matched your search

@@ -464,3 +464,29 @@ describe('LinesGrid: columnas bloqueadas', () => {
expect(el.querySelector<HTMLInputElement>('input[data-r="0"][data-c="0"]')!.readOnly).toBe(false);
});
});
describe('LinesGrid: alineación de las columnas', () => {
it('por defecto las numéricas van a la derecha y el resto a la izquierda; `align` lo cambia', async () => {
await TestBed.configureTestingModule({
imports: [Host],
providers: [provideHttpClient(), provideHttpClientTesting()],
}).compileComponents();
const fixture = TestBed.createComponent(Host);
fixture.componentInstance.columns = [
{ key: 'Texto', title: 'Texto' },
{ key: 'Cantidad', title: 'Cantidad', type: 'number' },
{ key: 'Codigo', title: 'Código', align: 'right' },
{ key: 'Centrado', title: 'Centrado', align: 'center' },
{ key: 'Importe', title: 'Importe', type: 'number', align: 'left' },
];
fixture.componentInstance.lines.set([{ Texto: 'a', Cantidad: 1, Codigo: 'x', Centrado: 'c', Importe: 5 }]);
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const el = fixture.nativeElement as HTMLElement;
const heads = [...el.querySelectorAll<HTMLElement>('thead th')].slice(1, -1).map((t) => t.style.textAlign);
const cells = [0, 1, 2, 3, 4].map((c) => el.querySelector<HTMLInputElement>(`input[data-r="0"][data-c="${c}"]`)!.style.textAlign);
expect(heads).toEqual(['left', 'right', 'right', 'center', 'left']);
expect(cells).toEqual(['left', 'right', 'right', 'center', 'left']);
});
});