2026-09-21 16:33:51 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
import 'package:hidalyx_drluiscastro/features/config/presentation/store/config_store.dart';
|
|
|
|
|
import 'package:hidalyx_drluiscastro/features/patient/presentation/widgets/clinical_documents_dropdown.dart';
|
|
|
|
|
import 'package:hidalyx_drluiscastro/features/prescription/presentation/views/prescription_modal_view.dart';
|
|
|
|
|
import 'package:hidalyx_drluiscastro/features/prescription/services/prescription_pdf_service.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
group('ClinicalDocumentsDropdown Tests', () {
|
|
|
|
|
testWidgets('renders dropdown button with title and icon', (tester) async {
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: Scaffold(
|
|
|
|
|
body: ClinicalDocumentsDropdown(
|
|
|
|
|
onSelect: (_) {},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(find.text('Documentos Clínicos'), findsOneWidget);
|
|
|
|
|
expect(find.byIcon(Icons.description_outlined), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('opens menu and displays Receta Médica option', (tester) async {
|
|
|
|
|
ClinicalDocumentType? selected;
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: Scaffold(
|
|
|
|
|
body: ClinicalDocumentsDropdown(
|
|
|
|
|
onSelect: (type) => selected = type,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Documentos Clínicos'));
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect(find.text('Receta Médica'), findsOneWidget);
|
|
|
|
|
expect(find.text('Formato media carta institucional'), findsOneWidget);
|
|
|
|
|
expect(find.text('Autorización De Seguro'), findsOneWidget);
|
|
|
|
|
expect(find.text('Referir a Doctor(a)'), findsOneWidget);
|
|
|
|
|
expect(find.text('Referir a Departamento'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Receta Médica'));
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect(selected, equals(ClinicalDocumentType.recetaMedica));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('PrescriptionModalView Tests', () {
|
|
|
|
|
testWidgets('renders patient name, doctor header and prescription fields', (tester) async {
|
|
|
|
|
final configStore = ConfigStore();
|
|
|
|
|
configStore.nombreDoctor = 'Dr. Luis A. Castro Sosa';
|
|
|
|
|
configStore.especialidad = 'Cirujano Urólogo';
|
|
|
|
|
configStore.descripEspecialidad = 'Enfermedades Vías Urinarias';
|
|
|
|
|
configStore.descripGeneral = 'Santiago, RD';
|
|
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: Scaffold(
|
|
|
|
|
body: PrescriptionModalView(
|
|
|
|
|
patientName: 'JUAN PEREZ',
|
|
|
|
|
configStore: configStore,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect(find.text('Emisión de Receta Médica'), findsOneWidget);
|
|
|
|
|
expect(find.text('Dr. Luis A. Castro Sosa'), findsOneWidget);
|
|
|
|
|
expect(find.text('CIRUJANO URÓLOGO'), findsOneWidget);
|
|
|
|
|
expect(find.text('ENFERMEDADES VÍAS URINARIAS'), findsOneWidget);
|
|
|
|
|
expect(find.text('JUAN PEREZ'), findsOneWidget);
|
|
|
|
|
expect(find.text('Crear / Imprimir Receta'), findsOneWidget);
|
|
|
|
|
expect(find.text('ESC para salir'), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('inserts bullet when clicking viñeta button', (tester) async {
|
|
|
|
|
final configStore = ConfigStore();
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: Scaffold(
|
|
|
|
|
body: PrescriptionModalView(
|
|
|
|
|
patientName: 'CARLOS ARIAS',
|
|
|
|
|
configStore: configStore,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
final bulletBtn = find.text('Insertar viñeta (•)');
|
|
|
|
|
expect(bulletBtn, findsOneWidget);
|
|
|
|
|
|
|
|
|
|
await tester.tap(bulletBtn);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect(find.text('• '), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('PrescriptionPdfService Tests', () {
|
2026-09-21 22:37:39 -04:00
|
|
|
test('builds prescription pdf bytes with correct page format and layout', () async {
|
2026-09-21 16:33:51 -04:00
|
|
|
final bytes = await PrescriptionPdfService.buildPrescriptionPdf(
|
|
|
|
|
doctorName: 'Dr. Luis A. Castro Sosa',
|
|
|
|
|
specialty: 'Cirujano Urólogo',
|
|
|
|
|
subspecialty: 'Enfermedades Vias Urinarias',
|
|
|
|
|
generalContact: 'Santiago, RD. Tel: 809-583-2394',
|
|
|
|
|
patientName: 'JUAN PEREZ',
|
|
|
|
|
prescriptionText: '1. Ciprofloxacina 500mg\nTomar 1 tableta cada 12 horas por 7 días.',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(bytes, isNotEmpty);
|
|
|
|
|
expect(bytes.sublist(0, 4), equals([0x25, 0x50, 0x44, 0x46]));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|