feat(ui): redisenar catalogo y filtros UX-06C
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const root = new URL('../src/app/features/indicadores/', import.meta.url);
|
||||
const read = path => readFileSync(new URL(path, root), 'utf8');
|
||||
|
||||
test('UX-06C: geometría prevista conserva título flexible, flecha lateral y foco visible', () => {
|
||||
const card = read('indicador-catalog-card.ts');
|
||||
const styles = card.slice(card.indexOf(' styles:'), card.indexOf('export class'));
|
||||
assert.match(styles, /grid-template-columns:\s*minmax\(0, 1fr\) auto/);
|
||||
assert.match(styles, /header button\s*\{[^}]*justify-self:\s*end/);
|
||||
assert.match(styles, /header button\s*\{[^}]*min-width:\s*48px;\s*min-height:\s*48px/);
|
||||
assert.match(styles, /button:focus-visible\s*\{[^}]*outline:/);
|
||||
assert.match(styles, /overflow-wrap:\s*anywhere/);
|
||||
});
|
||||
|
||||
test('UX-06C: navegación centrada sin banda blanca ni sticky añadido', () => {
|
||||
const styles = read('indicadores-page.scss');
|
||||
const nav = styles.match(/(?:^|\n)nav\s*\{([^}]*)\}/)?.[1];
|
||||
assert.ok(nav);
|
||||
assert.match(nav, /justify-content:\s*center/);
|
||||
assert.match(nav, /flex-wrap:\s*wrap/);
|
||||
assert.doesNotMatch(nav, /background|border:/);
|
||||
assert.doesNotMatch(styles, /position:\s*(sticky|fixed)/);
|
||||
assert.match(styles, /nav a\[aria-current='page'\]\s*\{[^}]*text-decoration:\s*underline/);
|
||||
});
|
||||
|
||||
test('UX-06C: filtros preparados para valores largos y apilamiento móvil con ayudas dinámicas', () => {
|
||||
const styles = read('indicador-period-filters.scss');
|
||||
const template = read('indicador-period-filters.html');
|
||||
assert.match(styles, /\.select-value\s*\{[^}]*white-space:\s*normal;[^}]*overflow-wrap:\s*anywhere/);
|
||||
assert.match(styles, /@media\s*\(max-width:\s*550px\)[\s\S]*flex:\s*1 1 100%/);
|
||||
assert.match(styles, /mat-form-field\s*\{[^}]*min-width:\s*0/);
|
||||
const fields = template.match(/<mat-form-field\b[^>]*>/g);
|
||||
assert.equal(fields.length, 5);
|
||||
assert.ok(fields.every(field => field.includes('subscriptSizing="dynamic"')));
|
||||
assert.doesNotMatch(styles, /overflow:\s*hidden|z-index|\.mat-mdc-|::ng-deep/);
|
||||
});
|
||||
@@ -2,6 +2,7 @@ import { DOCUMENT } from '@angular/common';
|
||||
import { ChangeDetectorRef, Component, ElementRef, inject, Input, OnChanges, ViewChild } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { Dominio, Indicador, Tema } from './indicadores.models';
|
||||
import { IndicadoresMemory } from './indicadores-memory';
|
||||
import { indicatorIdentity, figureIdentity, identityElementId } from './indicadores-identities';
|
||||
@@ -9,18 +10,21 @@ import { IndicadorFigurePanel } from './indicador-figure-panel';
|
||||
|
||||
@Component({
|
||||
selector: 'app-indicador-catalog-card',
|
||||
imports: [MatButtonModule, MatCardModule, IndicadorFigurePanel],
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule, IndicadorFigurePanel],
|
||||
template: `
|
||||
<mat-card>
|
||||
<header>
|
||||
<h2 [id]="titleId">{{ indicador.titulo }}</h2>
|
||||
<p>{{ indicador.id }} · Contrato {{ indicador.contrato }} · {{ indicador.figuras.length }} figuras publicadas</p>
|
||||
<button #toggleButton mat-stroked-button [attr.aria-expanded]="expanded"
|
||||
<div class="card-identity">
|
||||
<h2 [id]="titleId">{{ indicador.titulo }}</h2>
|
||||
<p class="indicator-id">{{ indicador.id }}</p>
|
||||
</div>
|
||||
<button #toggleButton mat-icon-button type="button" [attr.aria-expanded]="expanded"
|
||||
[attr.aria-controls]="contentId" [attr.aria-label]="(expanded ? 'Contraer ' : 'Expandir ') + dominio + ' · ' + indicador.id + ' · ' + indicador.titulo"
|
||||
(click)="toggle()">{{ expanded ? 'Contraer' : 'Expandir' }}</button>
|
||||
(click)="toggle()"><mat-icon aria-hidden="true">{{ expanded ? 'expand_less' : 'expand_more' }}</mat-icon></button>
|
||||
</header>
|
||||
<div #content [id]="contentId" [attr.aria-labelledby]="titleId">
|
||||
@if (expanded) {
|
||||
<p class="catalog-metadata">Contrato {{ indicador.contrato }} · {{ indicador.figuras.length }} figuras publicadas</p>
|
||||
@for (figure of indicador.figuras; track panelIdentity(figure)) {
|
||||
<app-indicador-figure-panel [dominio]="dominio" [indicador]="indicador" [figuraId]="figure" [tema]="tema" />
|
||||
} @empty { <p role="status">El indicador no tiene figuras disponibles.</p> }
|
||||
@@ -28,7 +32,21 @@ import { IndicadorFigurePanel } from './indicador-figure-panel';
|
||||
</div>
|
||||
</mat-card>
|
||||
`,
|
||||
styles: ':host { display: block; margin: 1rem 0; } mat-card { padding: 1.25rem; } h2, p { overflow-wrap: anywhere; } h2 { margin-top: 0; }',
|
||||
styles: `
|
||||
:host { display: block; min-width: 0; margin: var(--issste-space-4) 0; }
|
||||
mat-card { padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface);
|
||||
color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); box-shadow: none; }
|
||||
header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--issste-space-3); }
|
||||
.card-identity { min-width: 0; }
|
||||
h2, p { overflow-wrap: anywhere; }
|
||||
h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 700; font-size: 1.5rem; line-height: 1.25; }
|
||||
.indicator-id { margin: var(--issste-space-1) 0 0; color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
||||
header button { justify-self: end; flex-shrink: 0; min-width: 48px; min-height: 48px; color: var(--issste-text); }
|
||||
button:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; }
|
||||
.catalog-metadata { margin: var(--issste-space-4) 0 0; padding-top: var(--issste-space-4);
|
||||
border-top: 1px solid var(--issste-border); color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
||||
@media (max-width: 550px) { h2 { font-size: 1.25rem; } header { gap: var(--issste-space-2); } }
|
||||
`,
|
||||
})
|
||||
export class IndicadorCatalogCard implements OnChanges {
|
||||
@Input({ required: true }) dominio!: Dominio;
|
||||
|
||||
@@ -25,7 +25,12 @@ import { figureIdentity, identityElementId } from './indicadores-identities';
|
||||
[figuraId]="figuraId" [dominio]="dominio" [tema]="tema" (retry)="requestFigure()" />
|
||||
</section>
|
||||
`,
|
||||
styles: ':host { display: block; min-width: 0; } section { margin-top: 1.5rem; } h3 { overflow-wrap: anywhere; }',
|
||||
styles: `
|
||||
:host { display: block; min-width: 0; }
|
||||
section { margin-top: var(--issste-space-6); padding-top: var(--issste-space-4); border-top: 1px solid var(--issste-border); }
|
||||
h3 { margin: 0 0 var(--issste-space-4); overflow-wrap: anywhere; color: var(--issste-text);
|
||||
font-family: var(--issste-font-heading); font-weight: 600; font-size: 1.25rem; line-height: 1.4; }
|
||||
`,
|
||||
})
|
||||
export class IndicadorFigurePanel implements OnChanges, OnDestroy {
|
||||
@Input({ required: true }) dominio!: Dominio;
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
<section aria-label="Filtros de periodos de la figura">
|
||||
<div class="fields">
|
||||
@if (types.length > 1) {
|
||||
<mat-form-field><mat-label>Granularidad</mat-label>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Granularidad</mat-label>
|
||||
<mat-select [ngModel]="state.tipo" (ngModelChange)="changeTipo($event)">
|
||||
@for (tipo of types; track tipo) { <mat-option [value]="tipo">{{ tipo === 'mes' ? 'Mes' : 'Semestre' }}</mat-option> }
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
}
|
||||
@if (state.tipo === types[0]) {
|
||||
<mat-form-field><mat-label>Modalidad</mat-label>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Modalidad</mat-label>
|
||||
<mat-select [ngModel]="entry.draft.mode === 'todos' ? 'todos' : 'manual'" (ngModelChange)="changeMode($event)">
|
||||
<mat-select-trigger><span class="select-value">{{ entry.draft.mode === 'todos' ? (state.tipo === 'mes' ? 'Todos los meses con reporte' : 'Todos los semestres con reporte') : 'Elegir periodos' }}</span></mat-select-trigger>
|
||||
<mat-option value="todos">Todos los {{ state.tipo === 'mes' ? 'meses' : 'semestres' }} con reporte</mat-option>
|
||||
<mat-option value="manual">Elegir periodos</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
}
|
||||
@if (entry.draft.mode !== 'todos') {
|
||||
<mat-form-field><mat-label>Periodos seleccionados</mat-label>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Periodos seleccionados</mat-label>
|
||||
<mat-select multiple [ngModel]="selectedPeriods" (ngModelChange)="select($event)">
|
||||
<mat-select-trigger><span class="select-value">{{ selectedPeriods.join(', ') }}</span></mat-select-trigger>
|
||||
@for (period of entry.added; track period) { <mat-option [value]="period">{{ period }}</mat-option> }
|
||||
</mat-select>
|
||||
<mat-hint>Disponibilidad desconocida hasta consultar.</mat-hint>
|
||||
@@ -25,26 +27,26 @@
|
||||
}
|
||||
</div>
|
||||
@if (entry.draft.mode !== 'todos') {
|
||||
<p>Periodos agregados por ti. Su disponibilidad se desconoce hasta consultar; esta lista no es un inventario de reportes.</p>
|
||||
<div class="fields">
|
||||
<mat-form-field><mat-label>Año</mat-label><input matInput [(ngModel)]="year" inputmode="numeric" maxlength="4" /></mat-form-field>
|
||||
<mat-form-field><mat-label>{{ state.tipo === 'mes' ? 'Mes' : 'Semestre' }}</mat-label>
|
||||
<p class="filter-help">Periodos agregados por ti. Su disponibilidad se desconoce hasta consultar; esta lista no es un inventario de reportes.</p>
|
||||
<div class="fields period-builder">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Año</mat-label><input matInput [(ngModel)]="year" inputmode="numeric" maxlength="4" /></mat-form-field>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>{{ state.tipo === 'mes' ? 'Mes' : 'Semestre' }}</mat-label>
|
||||
<mat-select [(ngModel)]="unit">
|
||||
@for (value of state.tipo === 'mes' ? months : ['S1', 'S2']; track value) { <mat-option [value]="value">{{ value }}</mat-option> }
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-stroked-button (click)="add()">Agregar periodo</button>
|
||||
<button type="button" mat-stroked-button (click)="add()">Agregar periodo</button>
|
||||
</div>
|
||||
<div class="remove" aria-label="Eliminar periodos agregados">
|
||||
@for (period of entry.added; track period) {
|
||||
<button mat-button (click)="remove(period)" [attr.aria-label]="'Eliminar periodo ' + period">Eliminar {{ period }}</button>
|
||||
<button type="button" mat-button (click)="remove(period)" [attr.aria-label]="'Eliminar periodo ' + period">Eliminar {{ period }}</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (error) { <p class="error" role="alert">{{ error }}</p> }
|
||||
<p>Selección en edición: {{ summary }}</p>
|
||||
<p class="draft-summary">Selección en edición: {{ summary }}</p>
|
||||
@if (!canApply) { <p role="status">Selecciona al menos un periodo válido para aplicar.</p> }
|
||||
@if (hasPending) { <p role="status">Hay cambios sin aplicar.</p> }
|
||||
<button mat-flat-button [disabled]="!canApply" (click)="apply.emit()">Aplicar</button>
|
||||
<p>Filtros de la consulta aplicada: {{ appliedSummary }}</p>
|
||||
@if (hasPending) { <p class="pending" role="status">Hay cambios sin aplicar.</p> }
|
||||
<button class="apply-button" type="button" mat-flat-button [disabled]="!canApply" (click)="apply.emit()">Aplicar</button>
|
||||
<p class="applied-summary">Filtros de la consulta aplicada: {{ appliedSummary }}</p>
|
||||
</section>
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
:host { display: block; margin: 1rem 0; }
|
||||
.fields { display: flex; flex-wrap: wrap; align-items: start; gap: 1rem; }
|
||||
mat-form-field { flex: 1; min-width: 160px; }
|
||||
:host { display: block; min-width: 0; margin: var(--issste-space-4) 0; }
|
||||
section { min-width: 0; }
|
||||
.fields { display: flex; flex-wrap: wrap; align-items: start; gap: var(--issste-space-3); }
|
||||
mat-form-field { flex: 1 1 14rem; min-width: 0; max-width: 24rem; }
|
||||
.period-builder mat-form-field { flex: 0 1 10rem; }
|
||||
.period-builder button { margin-top: var(--issste-space-2); min-height: 44px; }
|
||||
p { overflow-wrap: anywhere; line-height: 1.5; margin: var(--issste-space-3) 0; }
|
||||
.select-value { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
|
||||
.filter-help, .applied-summary { color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
||||
.draft-summary { font-weight: 500; }
|
||||
.pending { border-left: 3px solid var(--issste-text); padding-left: var(--issste-space-3); }
|
||||
.error { color: var(--mat-sys-error); }
|
||||
.remove { display: flex; flex-wrap: wrap; gap: .5rem; }
|
||||
.remove { display: flex; flex-wrap: wrap; gap: var(--issste-space-2); }
|
||||
.remove button { min-height: 44px; }
|
||||
.apply-button { min-height: 44px; margin-top: var(--issste-space-2); }
|
||||
@media (max-width: 550px) {
|
||||
mat-form-field, .period-builder mat-form-field { flex: 1 1 100%; max-width: none; }
|
||||
.period-builder button { margin-top: 0; }
|
||||
}
|
||||
|
||||
@@ -18,6 +18,28 @@ describe('UX-04 control asistido', () => {
|
||||
control = fixture.componentInstance;
|
||||
});
|
||||
afterEach(() => fixture.destroy());
|
||||
it('UX-06C: valores largos del trigger preservan Todos, selección explícita y borrador vacío', async () => {
|
||||
await fixture.whenStable(); fixture.detectChanges();
|
||||
expect(fixture.nativeElement.querySelector('.select-value')?.textContent).toContain('Todos los semestres con reporte');
|
||||
fixture.componentRef.setInput('state', {
|
||||
...control.state, editors: { ...control.state.editors, semestre: {
|
||||
added: ['2025-S1', '2025-S2'], draft: { mode: 'explicit', periodos: ['2025-S1', '2025-S2'] },
|
||||
} },
|
||||
});
|
||||
fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges();
|
||||
const values = Array.from(fixture.nativeElement.querySelectorAll('.select-value') as NodeListOf<HTMLElement>);
|
||||
expect(values.map(e => e.textContent)).toContain('2025-S1, 2025-S2');
|
||||
expect(values.map(e => e.textContent)).toContain('Elegir periodos');
|
||||
fixture.componentRef.setInput('state', {
|
||||
...control.state, editors: { ...control.state.editors, semestre: {
|
||||
added: ['2025-S1', '2025-S2'], draft: { mode: 'empty' },
|
||||
} },
|
||||
});
|
||||
fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges();
|
||||
expect(control.canApply).toBe(false);
|
||||
expect(control.state.applied?.selection.mode).toBe('todos');
|
||||
expect(fixture.nativeElement.querySelector('.apply-button').disabled).toBe(true);
|
||||
});
|
||||
it('UX-04A: el selector vacío no reescribe el FormControl en cada detección', async () => {
|
||||
// Bound the pre-fix reproduction: do not wait for an unstable fixture forever.
|
||||
fixture.changeDetectorRef.detach();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<mat-card class="state"><p role="status">No hay indicadores disponibles en el catálogo.</p>
|
||||
<button mat-stroked-button (click)="retryCatalog()">Actualizar catálogo</button></mat-card>
|
||||
} @else {
|
||||
<mat-form-field><mat-label>Tema del dominio</mat-label>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Tema del dominio</mat-label>
|
||||
<mat-select [ngModel]="tema" (ngModelChange)="changeTema($event)">
|
||||
<mat-option value="claro">Claro</mat-option><mat-option value="oscuro">Oscuro</mat-option>
|
||||
</mat-select>
|
||||
@@ -29,7 +29,7 @@
|
||||
<p role="status">{{ catalog().length }} indicadores publicados</p>
|
||||
@if (searchVisible()) {
|
||||
<div class="catalog-search">
|
||||
<mat-form-field subscriptSizing="dynamic">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-label>Buscar indicadores</mat-label>
|
||||
<input matInput type="search" [ngModel]="searchQuery()" (ngModelChange)="changeSearchQuery($event)"
|
||||
placeholder="Título o identificador" aria-describedby="catalog-search-help catalog-search-result" />
|
||||
|
||||
@@ -7,7 +7,7 @@ header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
||||
.state { padding: 1.25rem; margin: 0; }
|
||||
mat-form-field { width: 100%; max-width: 24rem; }
|
||||
@media (max-width: 550px) { h1 { font-size: var(--mat-sys-headline-medium-size); line-height: var(--mat-sys-headline-medium-line-height); } }
|
||||
.catalog-search { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
|
||||
.catalog-search { display: flex; align-items: flex-start; gap: var(--issste-space-3); flex-wrap: wrap; margin-top: var(--issste-space-4); }
|
||||
.catalog-search button { margin-top: .5rem; }
|
||||
.search-result { color: var(--mat-sys-on-surface-variant); font: var(--mat-sys-body-medium); }
|
||||
|
||||
@@ -16,15 +16,18 @@ nav {
|
||||
flex-wrap: wrap;
|
||||
gap: var(--issste-space-2);
|
||||
padding: var(--issste-space-2);
|
||||
background: var(--issste-surface);
|
||||
border: 1px solid var(--issste-border);
|
||||
justify-content: center;
|
||||
margin: var(--issste-space-4) 0;
|
||||
border-radius: var(--issste-radius);
|
||||
}
|
||||
|
||||
nav a {
|
||||
flex: 1 1 4rem;
|
||||
flex: 0 1 6rem;
|
||||
max-width: 10rem;
|
||||
color: var(--issste-text);
|
||||
border: 1px solid var(--issste-border);
|
||||
background: var(--issste-surface);
|
||||
min-height: 44px;
|
||||
border-radius: var(--issste-radius);
|
||||
}
|
||||
|
||||
@@ -34,3 +37,11 @@ nav a[aria-current='page'] {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: .25em;
|
||||
}
|
||||
|
||||
.catalog-search mat-form-field { flex: 1 1 18rem; min-width: 0; max-width: 32rem; }
|
||||
.search-result { overflow-wrap: anywhere; margin: var(--issste-space-2) 0 var(--issste-space-4); }
|
||||
@media (max-width: 550px) {
|
||||
.catalog-search mat-form-field { flex-basis: 100%; max-width: none; }
|
||||
.catalog-search button { margin-top: 0; min-height: 44px; }
|
||||
nav { gap: var(--issste-space-2); padding-inline: 0; }
|
||||
}
|
||||
|
||||
@@ -41,6 +41,56 @@ describe('UX-05B catálogo expandible', () => {
|
||||
function flushAll() { http.match(r => r.url.includes('/figuras/')).forEach(r => r.flush({ data: [{ y: [0, null] }], layout: {} })); fixture.detectChanges(); }
|
||||
function control(index = 0) { return fixture.debugElement.queryAll(By.directive(IndicadorPeriodFilters))[index].componentInstance as IndicadorPeriodFilters; }
|
||||
|
||||
it('UX-06C: tarjeta contraída contiene solo identidad y flecha decorativa en un botón nativo', () => {
|
||||
load();
|
||||
const host = fixture.nativeElement.querySelector('app-indicador-catalog-card') as HTMLElement;
|
||||
const header = host.querySelector('header')!;
|
||||
expect(header.querySelector('h2')?.textContent).toBe('Uno');
|
||||
expect(header.querySelector('.indicator-id')?.textContent).toBe('i1');
|
||||
expect(host.textContent).not.toContain('Contrato');
|
||||
expect(host.textContent).not.toContain('figuras publicadas');
|
||||
expect(host.querySelectorAll('app-indicador-figure-panel')).toHaveLength(0);
|
||||
const button = header.querySelector('button')!;
|
||||
expect(button.type).toBe('button');
|
||||
expect(button.tabIndex).toBe(0);
|
||||
expect(button.getAttribute('aria-expanded')).toBe('false');
|
||||
expect(button.getAttribute('aria-label')).toContain('Expandir tea · i1 · Uno');
|
||||
expect(button.querySelector('mat-icon')?.textContent?.trim()).toBe('expand_more');
|
||||
expect(button.querySelector('mat-icon')?.getAttribute('aria-hidden')).toBe('true');
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('UX-06C: conserva encabezado, botón y relación accesible al abrir varias figuras y contraer', () => {
|
||||
load();
|
||||
const host = fixture.nativeElement.querySelector('app-indicador-catalog-card') as HTMLElement;
|
||||
const header = host.querySelector('header')!;
|
||||
const button = header.querySelector('button')!;
|
||||
const contentId = button.getAttribute('aria-controls')!;
|
||||
button.click(); fixture.detectChanges(); flushAll();
|
||||
expect(host.querySelector('header')).toBe(header);
|
||||
expect(header.querySelector('button')).toBe(button);
|
||||
expect(button.getAttribute('aria-controls')).toBe(contentId);
|
||||
expect(button.getAttribute('aria-expanded')).toBe('true');
|
||||
expect(button.querySelector('mat-icon')?.textContent?.trim()).toBe('expand_less');
|
||||
expect(button.getAttribute('aria-label')).toContain('Contraer tea · i1 · Uno');
|
||||
expect(header.textContent).not.toContain('Contrato');
|
||||
expect(host.querySelector('.catalog-metadata')?.textContent).toContain('Contrato C1 · 2 figuras publicadas');
|
||||
expect(host.querySelectorAll('app-indicador-figure-panel')).toHaveLength(2);
|
||||
button.click(); fixture.detectChanges();
|
||||
expect(host.querySelector('.catalog-metadata')).toBeNull();
|
||||
expect(host.querySelectorAll('app-indicador-figure-panel')).toHaveLength(0);
|
||||
expect(button.querySelector('mat-icon')?.textContent?.trim()).toBe('expand_more');
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('UX-06C: conserva título largo completo y el control separado de la identidad', () => {
|
||||
const title = 'Distribución de indicadores con un título extenso y múltiples palabras para revisión responsive';
|
||||
load([{ ...item, titulo: title }, second]);
|
||||
const header = fixture.nativeElement.querySelector('app-indicador-catalog-card header') as HTMLElement;
|
||||
expect(header.querySelector('h2')?.textContent).toBe(title);
|
||||
expect(header.querySelector('.card-identity button')).toBeNull();
|
||||
expect(header.lastElementChild?.tagName).toBe('BUTTON');
|
||||
expect(header.querySelector('button')?.getAttribute('aria-label')).toContain(title);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('UX-06B conserva una navegación con rutas y estado activo en los tres dominios', () => {
|
||||
const domains = ['tea', 'cacu', 'cama'] as const;
|
||||
for (const domain of domains) {
|
||||
|
||||
@@ -17,8 +17,9 @@ describe('UX-05B ciclo de vida con componentes Plotly y runtime simulado', () =>
|
||||
vi.resetAllMocks(); disconnects.length = 0;
|
||||
runtime.react.mockResolvedValue(undefined); runtime.Plots.resize.mockResolvedValue(undefined);
|
||||
vi.stubGlobal('ResizeObserver', class {
|
||||
disconnect = vi.fn(); observe = vi.fn();
|
||||
constructor() { disconnects.push(this.disconnect); }
|
||||
disconnect = vi.fn(); unobserve = vi.fn();
|
||||
// Material outline labels also observe size; track only Plotly hosts here.
|
||||
observe = vi.fn((target: Element) => { if (target.classList.contains('plot')) disconnects.push(this.disconnect); });
|
||||
});
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting(),
|
||||
{ provide: PLOTLY_LOADER, useValue: () => Promise.resolve(runtime) }] });
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('UX-05C búsqueda local y partición estable', () => {
|
||||
const disconnect = vi.fn();
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks(); runtime.react.mockResolvedValue(undefined); runtime.Plots.resize.mockResolvedValue(undefined);
|
||||
vi.stubGlobal('ResizeObserver', class { observe = vi.fn(); disconnect = disconnect; });
|
||||
vi.stubGlobal('ResizeObserver', class { observe = vi.fn(); unobserve = vi.fn(); disconnect = disconnect; });
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresPage], providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting(),
|
||||
{ provide: PLOTLY_LOADER, useValue: () => Promise.resolve(runtime) }] });
|
||||
fixture = TestBed.createComponent(IndicadoresPage); page = fixture.componentInstance;
|
||||
|
||||
Reference in New Issue
Block a user