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/insurance_auth/presentation/views/insurance_auth_modal_view.dart';
|
|
|
|
|
import 'package:hidalyx_drluiscastro/features/insurance_auth/services/insurance_auth_pdf_service.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
group('InsuranceAuthModalView Tests', () {
|
|
|
|
|
testWidgets('renders all fields matching AlfaMedical specification', (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: InsuranceAuthModalView(
|
|
|
|
|
patientName: 'MARIA SANTOS',
|
|
|
|
|
initialDiagnosis: 'Litiasis renal derecha',
|
|
|
|
|
configStore: configStore,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect(find.text('Autorización De Seguro (ARS)'), findsOneWidget);
|
|
|
|
|
expect(find.text('Dr. Luis A. Castro Sosa'), findsOneWidget);
|
|
|
|
|
expect(find.text('CIRUJANO URÓLOGO'), findsOneWidget);
|
|
|
|
|
expect(find.text('MARIA SANTOS'), findsOneWidget);
|
|
|
|
|
expect(find.text('Litiasis renal derecha'), findsOneWidget);
|
|
|
|
|
expect(find.text('Crear / Imprimir Autorización'), findsOneWidget);
|
|
|
|
|
expect(find.text('ESC para salir'), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('shows validation message when required fields are missing', (tester) async {
|
|
|
|
|
final configStore = ConfigStore();
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: Scaffold(
|
|
|
|
|
body: InsuranceAuthModalView(
|
|
|
|
|
patientName: '',
|
|
|
|
|
configStore: configStore,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
final printBtn = find.text('Crear / Imprimir Autorización');
|
|
|
|
|
await tester.tap(printBtn);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect(find.text('Debe indicar el nombre del paciente.'), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('InsuranceAuthPdfService Tests', () {
|
2026-09-21 17:21:00 -04:00
|
|
|
test('builds insurance auth pdf bytes with media carta vertical format', () async {
|
2026-09-21 16:33:51 -04:00
|
|
|
final bytes = await InsuranceAuthPdfService.buildInsuranceAuthPdf(
|
|
|
|
|
doctorName: 'Dr. Luis A. Castro Sosa',
|
|
|
|
|
specialty: 'Cirujano Urólogo',
|
|
|
|
|
subspecialty: 'Enfermedades Vias Urinarias',
|
|
|
|
|
generalContact: 'Santiago, RD. Tel: 809-583-2394',
|
|
|
|
|
arsName: 'Humano Seguros, S.A.',
|
|
|
|
|
patientName: 'MARIA SANTOS',
|
|
|
|
|
surgeryText: 'Ureterolitotomía endoscópica láser',
|
|
|
|
|
diagnosisText: 'Cálculo ureteral obstructivo',
|
|
|
|
|
anesthesia: 'Raquídea',
|
|
|
|
|
daysOfStay: '1',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(bytes, isNotEmpty);
|
|
|
|
|
expect(bytes.sublist(0, 4), equals([0x25, 0x50, 0x44, 0x46]));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|