From 4ad70b52278dc7856bd9e1b8f9fe47d24b3bfa38 Mon Sep 17 00:00:00 2001 From: Miguel Barra Date: Mon, 27 Jul 2026 15:16:40 -0400 Subject: [PATCH] refactor(dbo-1087): eliminar bitcoin y dolar_intercambio --- .../indicadores/[codigo]/[anio]/route.test.ts | 2 +- app/dev/ui/page.tsx | 11 +--------- app/opengraph-image.tsx | 2 +- components/Converter.test.tsx | 2 -- components/IndicatorCard.test.tsx | 20 ------------------- components/IndicatorCard.tsx | 14 +------------ e2e/mocks.ts | 14 ------------- hooks/useIndicadorHistory.test.tsx | 12 +++++------ lib/format.ts | 4 ++-- types/indicador.ts | 4 ---- 10 files changed, 12 insertions(+), 73 deletions(-) diff --git a/app/api/indicadores/[codigo]/[anio]/route.test.ts b/app/api/indicadores/[codigo]/[anio]/route.test.ts index 4504950..1bd2d83 100644 --- a/app/api/indicadores/[codigo]/[anio]/route.test.ts +++ b/app/api/indicadores/[codigo]/[anio]/route.test.ts @@ -67,7 +67,7 @@ describe('GET /api/indicadores/[codigo]/[anio]', () => { it('responde 502 cuando la API externa falla para un codigo y anio validos', async () => { vi.mocked(fetch).mockRejectedValueOnce(new Error('fetch failed')); - const response = await callRoute('dolar_intercambio', '2026'); + const response = await callRoute('dolar', '2026'); expect(response.status).toBe(502); const body = (await response.json()) as { error: string }; diff --git a/app/dev/ui/page.tsx b/app/dev/ui/page.tsx index 93d8725..8d05a7c 100644 --- a/app/dev/ui/page.tsx +++ b/app/dev/ui/page.tsx @@ -25,14 +25,6 @@ const ipcEjemplo: Indicador = { valor: -0.2, }; -const dolarIntercambioEjemplo: Indicador = { - codigo: 'dolar_intercambio', - nombre: 'Dolar acuerdo', - unidad_medida: 'Pesos', - fecha: '2014-01-02T00:00:00.000Z', - valor: 758.87, -}; - function Section({ title, children }: { title: string; children: React.ReactNode }) { return (
@@ -90,7 +82,6 @@ export default function UiShowcasePage() {
-
@@ -102,7 +93,7 @@ export default function UiShowcasePage() {
- +
diff --git a/app/opengraph-image.tsx b/app/opengraph-image.tsx index 829e2f5..7b0fee3 100644 --- a/app/opengraph-image.tsx +++ b/app/opengraph-image.tsx @@ -8,7 +8,7 @@ const indicators = [ { code: 'UF', value: '$39.412,87', trend: 'up' as const, delta: '+0,03%' }, { code: 'Dólar', value: '$963,12', trend: 'down' as const, delta: '-0,21%' }, { code: 'Euro', value: '$1.041,55', trend: 'up' as const, delta: '+0,14%' }, - { code: 'Bitcoin', value: '$62.480.900', trend: 'up' as const, delta: '+1,86%' }, + { code: 'Cobre', value: 'US$6,17/lb', trend: 'up' as const, delta: '+0,52%' }, ]; const trendColor = { up: '#34d399', down: '#f87171' }; diff --git a/components/Converter.test.tsx b/components/Converter.test.tsx index 0dc3cea..c19a451 100644 --- a/components/Converter.test.tsx +++ b/components/Converter.test.tsx @@ -29,7 +29,6 @@ function makeSnapshot(): IndicadoresSnapshot { uf: makeIndicador({ codigo: 'uf', nombre: 'Unidad de fomento (UF)', valor: 40000 }), ivp: generico('ivp'), dolar: generico('dolar'), - dolar_intercambio: generico('dolar_intercambio'), euro: generico('euro'), ipc: makeIndicador({ codigo: 'ipc', @@ -42,7 +41,6 @@ function makeSnapshot(): IndicadoresSnapshot { tpm: generico('tpm'), libra_cobre: generico('libra_cobre'), tasa_desempleo: generico('tasa_desempleo'), - bitcoin: generico('bitcoin'), }; } diff --git a/components/IndicatorCard.test.tsx b/components/IndicatorCard.test.tsx index 7e81242..a1090cd 100644 --- a/components/IndicatorCard.test.tsx +++ b/components/IndicatorCard.test.tsx @@ -19,14 +19,6 @@ const ipcEjemplo: Indicador = { valor: -0.2, }; -const dolarIntercambioEjemplo: Indicador = { - codigo: 'dolar_intercambio', - nombre: 'Dólar acuerdo', - unidad_medida: 'Pesos', - fecha: '2014-11-13T03:00:00.000Z', - valor: 758.87, -}; - describe('IndicatorCard', () => { beforeEach(() => { window.localStorage.clear(); @@ -58,16 +50,4 @@ describe('IndicatorCard', () => { render(); expect(screen.queryByText('Dato no disponible')).not.toBeInTheDocument(); }); - - it('muestra la nota accesible de dolar_intercambio', () => { - render(); - expect( - screen.getByRole('img', { name: /sin actualizacion desde 2014/i }), - ).toBeInTheDocument(); - }); - - it('no muestra la nota de dolar_intercambio para otros indicadores', () => { - render(); - expect(screen.queryByRole('img')).not.toBeInTheDocument(); - }); }); diff --git a/components/IndicatorCard.tsx b/components/IndicatorCard.tsx index 1912be8..5aa6da5 100644 --- a/components/IndicatorCard.tsx +++ b/components/IndicatorCard.tsx @@ -56,19 +56,7 @@ export function IndicatorCard({ {isLoading ? ( ) : ( - <> - {codigo} - {codigo === 'dolar_intercambio' && ( - - † - - )} - + {codigo} )} { it('recupera datos parciales si un solo anio falla (error aislado)', async () => { vi.mocked(fetch).mockImplementation(async (input) => { const url = String(input); - if (url.includes('/dolar_intercambio/2026')) { + if (url.includes('/euro/2026')) { return { ok: false, status: 502, json: async () => ({ error: 'sin datos' }) } as Response; } return { ok: true, json: async () => ({ - codigo: 'dolar_intercambio', - nombre: 'Dolar acuerdo', + codigo: 'euro', + nombre: 'Euro', unidad_medida: 'Pesos', - serie: [{ fecha: '2025-11-13T00:00:00.000Z', valor: 758.87 }], + serie: [{ fecha: '2025-12-01T00:00:00.000Z', valor: 1080 }], }), } as Response; }); - const { result } = renderHook(() => useIndicadorHistory('dolar_intercambio', fechaAncla), { + const { result } = renderHook(() => useIndicadorHistory('euro', fechaAncla), { wrapper, }); await waitFor(() => expect(result.current.isLoading).toBe(false)); - expect(result.current.data).toEqual([{ fecha: '2025-11-13T00:00:00.000Z', valor: 758.87 }]); + expect(result.current.data).toEqual([{ fecha: '2025-12-01T00:00:00.000Z', valor: 1080 }]); expect(result.current.error).toBeUndefined(); }); diff --git a/lib/format.ts b/lib/format.ts index 70ba666..664802c 100644 --- a/lib/format.ts +++ b/lib/format.ts @@ -34,8 +34,8 @@ export function formatFecha(fecha: string | Date): string { } export function formatValorPorUnidad(valor: number, unidadMedida?: string): string { - // Solo existen formatCLP/formatPorcentaje (MDI-010): los indicadores con - // unidad "Dolar" (bitcoin, libra_cobre) se muestran con formatCLP por ahora. + // Solo existen formatCLP/formatPorcentaje (MDI-010): libra_cobre (unidad + // "Dolar") se muestra con formatCLP por ahora. if (unidadMedida === 'Porcentaje') { return formatPorcentaje(valor); } diff --git a/types/indicador.ts b/types/indicador.ts index 321e3e2..949372c 100644 --- a/types/indicador.ts +++ b/types/indicador.ts @@ -2,7 +2,6 @@ export const INDICADOR_CODIGOS = [ 'uf', 'ivp', 'dolar', - 'dolar_intercambio', 'euro', 'ipc', 'utm', @@ -10,7 +9,6 @@ export const INDICADOR_CODIGOS = [ 'tpm', 'libra_cobre', 'tasa_desempleo', - 'bitcoin', ] as const; export type IndicadorCodigo = (typeof INDICADOR_CODIGOS)[number]; @@ -30,7 +28,6 @@ export interface IndicadoresSnapshot { uf: Indicador; ivp: Indicador; dolar: Indicador; - dolar_intercambio: Indicador; euro: Indicador; ipc: Indicador; utm: Indicador; @@ -38,7 +35,6 @@ export interface IndicadoresSnapshot { tpm: Indicador; libra_cobre: Indicador; tasa_desempleo: Indicador; - bitcoin: Indicador; } export interface SerieHistoricaPunto {