feat(patient): make antecedentes patologicos dropdowns editable with custom notes and options menu
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:hidalyx_drluiscastro/features/patient/data/models/patient_model.
|
||||
import 'package:hidalyx_drluiscastro/features/patient/data/services/patient_service.dart';
|
||||
import 'package:hidalyx_drluiscastro/features/patient/presentation/store/patient_store.dart';
|
||||
import 'package:hidalyx_drluiscastro/features/patient/presentation/views/patient_modal_view.dart';
|
||||
import 'package:hidalyx_drluiscastro/features/patient/presentation/widgets/patient_clinical_tabs.dart';
|
||||
import 'package:hidalyx_drluiscastro/features/patient/presentation/widgets/patient_demographics_form.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
@@ -393,5 +394,69 @@ void main() {
|
||||
expect(success, isTrue);
|
||||
expect(store.estadoEspera, 'atendido');
|
||||
});
|
||||
|
||||
testWidgets('Antec. patologicos fields are editable and allow custom text or clear', (tester) async {
|
||||
await tester.binding.setSurfaceSize(const Size(1200, 900));
|
||||
final store = PatientStore(patientService: MockPatientService());
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: PatientClinicalTabs(store: store),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Tap on the 'Antec. patológicos' tab
|
||||
await tester.tap(find.text('Antec. patológicos'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that section and labels exist
|
||||
expect(find.text('Antecedentes Personales Patológicos'), findsOneWidget);
|
||||
expect(find.text('Alergias'), findsOneWidget);
|
||||
expect(find.text('Infancia'), findsOneWidget);
|
||||
|
||||
// Find the text field for 'Alergias' and enter custom text
|
||||
final alergiasField = find.ancestor(
|
||||
of: find.text('Alergias'),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
expect(alergiasField, findsOneWidget);
|
||||
|
||||
await tester.enterText(alergiasField, 'Ibuprofeno y mariscos');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(store.datAlerg, 'Ibuprofeno y mariscos');
|
||||
|
||||
// Test clear button specifically for Alergias
|
||||
final alergiasClear = find.descendant(
|
||||
of: alergiasField,
|
||||
matching: find.byTooltip('Limpiar'),
|
||||
);
|
||||
expect(alergiasClear, findsOneWidget);
|
||||
await tester.tap(alergiasClear);
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.datAlerg, '');
|
||||
|
||||
// Test opening dropdown menu and selecting an item
|
||||
final dropdownArrow = find.descendant(
|
||||
of: alergiasField,
|
||||
matching: find.byIcon(Icons.arrow_drop_down_rounded),
|
||||
);
|
||||
expect(dropdownArrow, findsOneWidget);
|
||||
await tester.tap(dropdownArrow);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Tap 'Penicilina' from the menu
|
||||
await tester.tap(find.text('Penicilina').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.datAlerg, 'Penicilina');
|
||||
|
||||
// Test appending text to the selected option
|
||||
await tester.enterText(alergiasField, 'Penicilina (shock anafiláctico)');
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.datAlerg, 'Penicilina (shock anafiláctico)');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user