From 6543ddad7b9684bb134605121301d6dfc67fe225 Mon Sep 17 00:00:00 2001 From: Angel Capetillo Zavala Date: Fri, 25 Sep 2026 10:53:05 -0600 Subject: [PATCH] Update: Opciones de exportar --- src/app/action-selection.html | 12 +++ src/app/action-selection.scss | 14 +++ src/app/action-selection.ts | 14 +++ src/app/app.spec.ts | 103 +++++++++++++++++++ src/app/dashboard/dashboard.html | 21 ++-- src/app/dashboard/dashboard.scss | 16 +++ src/app/dashboard/dashboard.ts | 34 +++++- src/app/dashboard/export-results-dialog.html | 30 ++++++ src/app/dashboard/export-results-dialog.scss | 28 +++++ src/app/dashboard/export-results-dialog.ts | 20 ++++ src/app/home.ts | 3 +- src/app/information-upload-dialog.html | 15 ++- src/app/information-upload-dialog.ts | 31 ++++-- 13 files changed, 320 insertions(+), 21 deletions(-) create mode 100644 src/app/action-selection.html create mode 100644 src/app/action-selection.scss create mode 100644 src/app/action-selection.ts create mode 100644 src/app/dashboard/export-results-dialog.html create mode 100644 src/app/dashboard/export-results-dialog.scss create mode 100644 src/app/dashboard/export-results-dialog.ts diff --git a/src/app/action-selection.html b/src/app/action-selection.html new file mode 100644 index 0000000..0e62ede --- /dev/null +++ b/src/app/action-selection.html @@ -0,0 +1,12 @@ +
+ + +
diff --git a/src/app/action-selection.scss b/src/app/action-selection.scss new file mode 100644 index 0000000..566b3ce --- /dev/null +++ b/src/app/action-selection.scss @@ -0,0 +1,14 @@ +@use 'upload-button' as button; + +:host { display: block; } +.action-options { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); } +.action-card { align-items: center; background: #fff; border: 1px solid var(--color-border); border-radius: 9px; color: var(--color-text); cursor: pointer; display: flex; gap: 16px; min-height: 126px; padding: 20px; position: relative; text-align: left; transition: background-color .18s ease, border-color .18s ease; } +.action-card:hover { background: var(--color-surface-hover); border-color: var(--color-primary); } +.action-card:focus-visible { @include button.focus; } +.action-card--selected { background: #fbfcf6; border: 2px solid var(--color-primary); padding: 19px; } +.action-card__icon { align-items: center; background: var(--color-step); border-radius: 8px; color: #71882b; display: inline-flex; flex: 0 0 46px; height: 46px; justify-content: center; } +.action-card__copy { display: grid; gap: 6px; min-width: 0; } +.action-card__title { font-size: 16px; font-weight: 600; } +.action-card__description { color: var(--color-text-secondary); font-size: 13px; line-height: 1.45; } +.action-card__check { color: #71882b; margin-left: auto; } +@media (max-width: 600px) { .action-options { grid-template-columns: 1fr; } .action-card { min-height: 94px; padding: 16px; } .action-card--selected { padding: 15px; } } diff --git a/src/app/action-selection.ts b/src/app/action-selection.ts new file mode 100644 index 0000000..dbc6d60 --- /dev/null +++ b/src/app/action-selection.ts @@ -0,0 +1,14 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { MatIconModule } from '@angular/material/icon'; +import type { UploadIntent } from './information-upload-dialog'; + +@Component({ + imports: [MatIconModule], + selector: 'app-action-selection', + styleUrl: './action-selection.scss', + templateUrl: './action-selection.html', +}) +export class ActionSelectionComponent { + @Input() intent: UploadIntent | null = null; + @Output() readonly intentChange = new EventEmitter(); +} diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index c5af2f0..3d0e0c3 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -499,6 +499,109 @@ describe('App', () => { expect(root.querySelector('.dashboard__demo')?.textContent).toContain('Datos de demostración'); expect(root.querySelectorAll('.kpi')).toHaveLength(3); expect(root.querySelectorAll('app-plotly-chart')).toHaveLength(3); + expect(root.querySelector('.dashboard__back')?.textContent).toContain('Volver al inicio'); + expect(root.querySelector('.dashboard__export')?.textContent).toContain('Exportar'); expect(root.querySelector('.site-footer img')).not.toBeNull(); }); + + it('returns to Home and supports local PDF and Excel selection in the export dialog', async () => { + const fixture = TestBed.createComponent(App); + fixture.detectChanges(); + const root = fixture.nativeElement as HTMLElement; + const router = TestBed.inject(Router); + await router.navigateByUrl('/dashboard'); + await fixture.whenStable(); + fixture.detectChanges(); + root.querySelector('.dashboard__back')!.click(); + await fixture.whenStable(); + fixture.detectChanges(); + expect(router.url).toBe('/'); + expect((fixture.nativeElement as HTMLElement).querySelector('app-home')).not.toBeNull(); + + await router.navigateByUrl('/dashboard'); + await fixture.whenStable(); + fixture.detectChanges(); + root.querySelector('.dashboard__export')!.click(); + fixture.detectChanges(); + await fixture.whenStable(); + const overlay = document.querySelector('.cdk-overlay-container')!; + const dialogRef = TestBed.inject(MatDialog).openDialogs[0]; + const detect = () => dialogRef.componentRef?.changeDetectorRef.detectChanges(); + const options = () => overlay.querySelectorAll('.export-option'); + expect(overlay.querySelector('#export-title')?.textContent).toContain('Exportar resultados'); + expect(options()[0].getAttribute('aria-pressed')).toBe('false'); + expect(options()[1].getAttribute('aria-pressed')).toBe('false'); + expect(overlay.querySelector('.export-dialog__submit')?.disabled).toBe(true); + options()[0].focus(); + options()[0].click(); + detect(); + expect(options()[0].getAttribute('aria-pressed')).toBe('true'); + expect(overlay.querySelector('.export-option--selected strong')?.textContent).toBe('PDF'); + options()[1].click(); + detect(); + expect(options()[0].getAttribute('aria-pressed')).toBe('false'); + expect(options()[1].getAttribute('aria-pressed')).toBe('true'); + expect(overlay.querySelector('.export-dialog__submit')?.hasAttribute('disabled')).toBe(true); + overlay.querySelector('.export-dialog__cancel')!.click(); + fixture.detectChanges(); + await new Promise((resolve) => setTimeout(resolve, 200)); + expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0); + expect(router.url).toBe('/dashboard'); + + root.querySelector('.dashboard__export')!.click(); + fixture.detectChanges(); + await fixture.whenStable(); + const reopenedOverlay = document.querySelector('.cdk-overlay-container')!; + expect(reopenedOverlay.querySelectorAll('.export-option--selected')).toHaveLength(0); + reopenedOverlay.querySelector('.export-dialog__close')!.click(); + fixture.detectChanges(); + await new Promise((resolve) => setTimeout(resolve, 200)); + expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0); + expect(router.url).toBe('/dashboard'); + }); + + it('opens the Dashboard action step, preserves its intent on back, and cancels without leaving results', async () => { + const fixture = TestBed.createComponent(App); + fixture.detectChanges(); + const router = TestBed.inject(Router); + await router.navigateByUrl('/dashboard'); + await fixture.whenStable(); + fixture.detectChanges(); + const dashboard = fixture.nativeElement as HTMLElement; + dashboard.querySelector('.dashboard__upload')!.click(); + fixture.detectChanges(); + await fixture.whenStable(); + const overlay = document.querySelector('.cdk-overlay-container')!; + const dialog = TestBed.inject(MatDialog).openDialogs[0].componentRef!; + const detect = () => dialog.changeDetectorRef.detectChanges(); + expect(overlay.querySelector('.action-options')).not.toBeNull(); + const continueButton = overlay.querySelector('.upload-dialog__continue')!; + expect(continueButton.disabled).toBe(true); + const cards = overlay.querySelectorAll('.action-card'); + cards[0].click(); + detect(); + expect(continueButton.disabled).toBe(false); + continueButton.click(); + detect(); + expect(overlay.querySelector('.source-options')).not.toBeNull(); + overlay.querySelector('.upload-dialog__back')!.click(); + detect(); + expect(overlay.querySelector('.action-card')?.getAttribute('aria-pressed')).toBe('true'); + overlay.querySelectorAll('.action-card')[1].click(); + detect(); + expect(continueButton.disabled).toBe(false); + continueButton.click(); + detect(); + overlay.querySelector('.source-card')!.click(); + detect(); + continueButton.click(); + detect(); + expect(overlay.querySelector('.file-configuration')).not.toBeNull(); + overlay.querySelector('.upload-dialog__cancel')!.click(); + fixture.detectChanges(); + await new Promise((resolve) => setTimeout(resolve, 200)); + expect(TestBed.inject(MatDialog).openDialogs).toHaveLength(0); + expect(router.url).toBe('/dashboard'); + expect((fixture.nativeElement as HTMLElement).querySelector('#dashboard-title')).not.toBeNull(); + }); }); diff --git a/src/app/dashboard/dashboard.html b/src/app/dashboard/dashboard.html index 9b5c82a..b682552 100644 --- a/src/app/dashboard/dashboard.html +++ b/src/app/dashboard/dashboard.html @@ -1,12 +1,19 @@
-
-

ISSSTELEON · Análisis de información

-

Resultados del análisis

-