feat(indicadores): dashboard interactivo multidominio y seguimiento CaCu

This commit is contained in:
Angel Capetillo Zavala
2026-10-22 17:10:35 -06:00
parent 9cc67c0ef2
commit 1fe88dfb45
62 changed files with 4380 additions and 187 deletions
@@ -31,6 +31,22 @@ describe('PlotlyController async', () => {
expect(host.style.visibility).toBe('visible');
expect(state).toHaveBeenLastCalledWith('ready');
});
it('suscribe click una vez, ignora clicks durante react y retira listener al destruir', async () => {
let listener!: (event: unknown) => void;
const on = vi.fn((_name, callback) => { listener = callback; });
const removeListener = vi.fn(), click = vi.fn();
Object.assign(host, { on, removeListener });
controller = new PlotlyController(host, () => Promise.resolve(plotly), state, click);
controller.setFigure(fig(1)); await settle();
listener({ points: [1] }); expect(click).toHaveBeenCalledTimes(1);
const pending = deferred(); vi.mocked(plotly.react).mockReturnValueOnce(pending.promise);
controller.setFigure(fig(2)); await settle(); listener({ points: [2] });
expect(click).toHaveBeenCalledTimes(1);
pending.resolve(); await settle(); expect(on).toHaveBeenCalledTimes(1);
listener({ points: [3] }); expect(click).toHaveBeenCalledTimes(2);
controller.destroy(); expect(removeListener).toHaveBeenCalledWith('plotly_click', listener);
listener({ points: [4] }); expect(click).toHaveBeenCalledTimes(2);
});
it('desactiva el envío externo sin alterar el JSON ni las opciones locales recibidas', async () => {
const figure: PlotlyFigure = {
...fig(1),