Files
hidalyx-drluiscastro/test/widget_test.dart
T
2026-09-21 16:33:51 -04:00

85 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/presentation/widgets/dashboard_app_bar.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/data/models/dashboard_metrics_model.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/data/models/patient_summary_model.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/presentation/widgets/dashboard_metrics_cards.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/presentation/widgets/recent_patients_card.dart';
import 'package:hidalyx_drluiscastro/features/dashboard/presentation/widgets/today_appointments_card.dart';
void main() {
testWidgets('DashboardAppBar renders doctor name, specialty and quick actions', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
appBar: DashboardAppBar(
doctorName: 'Dr. Luis A. Castro Sosa',
specialty: 'Cirujano Urólogo',
),
),
),
);
expect(find.text('Dr. Luis A. Castro Sosa'), findsOneWidget);
expect(find.text('Cirujano Urólogo'), findsOneWidget);
expect(find.text('Nuevo Paciente'), findsOneWidget);
expect(find.text('Buscar Paciente'), findsOneWidget);
});
testWidgets('Dashboard cards and lists render properly inside IntrinsicHeight without layout crash', (WidgetTester tester) async {
const mockPatients = [
PatientSummaryModel(
id: 1,
nombre: 'CARLOS JUAN',
apellido: 'ARIAS GOMEZ',
cedula: 'UNIVERSAL',
telefono: '829-552-4105',
fecReg: '17/07/2026',
fecProxCita: '25/02/2027',
seguro: 'Sí',
motCons: 'CHEQUEO DE RUTINA',
),
];
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
DashboardMetricsCards(
metrics: DashboardMetricsModel(
nuevosPacientes: 0,
consultadosHoy: 0,
citasHoy: 1,
pacientesMasculinos: 11078,
pacientesFemeninos: 2634,
totalPacientes: 13712,
),
),
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: RecentPatientsCard(patients: mockPatients)),
Expanded(child: TodayAppointmentsCard(appointments: mockPatients)),
],
),
),
],
),
),
),
),
);
expect(find.text('Total Nuevos Pacientes'), findsOneWidget);
expect(find.text('Pacientes Nuevos'), findsOneWidget);
expect(find.text('Citas para Hoy'), findsOneWidget);
expect(find.text('CARLOS JUAN ARIAS GOMEZ'), findsNWidgets(2));
});
}