first commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
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/referrals/presentation/views/doctor_referral_modal_view.dart';
|
||||
import 'package:hidalyx_drluiscastro/features/referrals/services/doctor_referral_pdf_service.dart';
|
||||
|
||||
void main() {
|
||||
group('DoctorReferralModalView Tests', () {
|
||||
testWidgets('renders modal pre-populated with AlfaMedical template', (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: DoctorReferralModalView(
|
||||
patientName: 'CARLOS DIAZ',
|
||||
configStore: configStore,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Referir a Doctor (a)'), findsOneWidget);
|
||||
expect(find.text('Dr. Luis A. Castro Sosa'), findsOneWidget);
|
||||
expect(find.text('CIRUJANO URÓLOGO'), findsOneWidget);
|
||||
expect(find.text('Crear / Imprimir Referimiento'), findsOneWidget);
|
||||
expect(find.text('ESC para salir'), findsOneWidget);
|
||||
|
||||
// Verify default AlfaMedical template content in the text field
|
||||
final textField = tester.widget<TextField>(find.byType(TextField));
|
||||
expect(textField.controller?.text, contains('Paciente: CARLOS DIAZ'));
|
||||
expect(textField.controller?.text, contains('Referido a Doctor (a) Miguelina Pichardo'));
|
||||
expect(textField.controller?.text, contains('Medicina Interna'));
|
||||
expect(textField.controller?.text, contains('Plan: Realizar evaluación cardiovascular para realizar:'));
|
||||
expect(textField.controller?.text, contains('Gracias.'));
|
||||
});
|
||||
|
||||
testWidgets('shows validation message when text is empty', (tester) async {
|
||||
final configStore = ConfigStore();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: DoctorReferralModalView(
|
||||
patientName: 'CARLOS DIAZ',
|
||||
configStore: configStore,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Clear text field
|
||||
await tester.enterText(find.byType(TextField), '');
|
||||
await tester.pump();
|
||||
|
||||
final printBtn = find.text('Crear / Imprimir Referimiento');
|
||||
await tester.tap(printBtn);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Debe redactar el contenido del referimiento.'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('DoctorReferralPdfService Tests', () {
|
||||
test('builds doctor referral pdf bytes with 8.5x5.5 inch format', () async {
|
||||
final bytes = await DoctorReferralPdfService.buildDoctorReferralPdf(
|
||||
doctorName: 'Dr. Luis A. Castro Sosa',
|
||||
specialty: 'Cirujano Urólogo',
|
||||
subspecialty: 'Enfermedades Vias Urinarias',
|
||||
generalContact: 'Santiago, RD. Tel: 809-583-2394',
|
||||
referralText: 'Paciente: CARLOS DIAZ\n\nReferido a Doctor (a) Miguelina Pichardo\nMedicina Interna\n\nPlan: Evaluación cardiovascular previa.',
|
||||
);
|
||||
|
||||
expect(bytes, isNotEmpty);
|
||||
expect(bytes.sublist(0, 4), equals([0x25, 0x50, 0x44, 0x46]));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user