Skip to content

Commit

Permalink
test(app): fix further tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Nov 29, 2024
1 parent 943f2d0 commit 828ab91
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
14 changes: 10 additions & 4 deletions app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,20 @@ void main() {
) as Switch;
expect(activitySelection.onChanged, isLoading ? isNull : isNotNull);
expect(activitySelection.value, expectDrugToBeActive ? isTrue : isFalse);
await tester.tap(find.byKey(Key('drug-information-expansion-tile')));
await tester.pumpAndSettle();
// Drug details
expect(
find.textContaining(
drug.annotations.drugclass
drug.annotations.drugclass,
skipOffstage: false,
),
findsOneWidget,
);
expect(find.text(drug.annotations.indication), findsOneWidget);
expect(
find.text(drug.annotations.indication, skipOffstage: false),
findsOneWidget,
);
// Guideline details
final card = tester.firstWidget(
find.byKey(
Expand Down Expand Up @@ -147,7 +153,7 @@ void main() {
findsOneWidget,
);
expect(
find.text(context.l10n.drugs_page_no_guidelines_text),
find.textContaining(context.l10n.drugs_page_no_guidelines_text),
findsOneWidget,
);
if (drug.guidelines.isNotEmpty) {
Expand All @@ -170,7 +176,7 @@ void main() {
findsOneWidget,
);
expect(
find.text(relevantGuideline.annotations.implication),
find.textContaining(relevantGuideline.annotations.implication),
findsOneWidget,
);
expect(
Expand Down
2 changes: 1 addition & 1 deletion app/integration_test/report_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void main() {
home: Scaffold(
body: Builder(
builder: (context) {
return ReportPage();
return ReportPage(onlyShowWholeReport: true);
},
),
),
Expand Down
1 change: 1 addition & 0 deletions app/lib/drug/widgets/annotation_cards/drug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DrugAnnotationCards extends StatelessWidget {
),
SizedBox(height: PharMeTheme.smallSpace),
PrettyExpansionTile(
key: Key('drug-information-expansion-tile'),
title: SubHeader(context.l10n.drugs_page_header_drug),
visualDensity: VisualDensity.compact,
titlePadding: EdgeInsets.zero,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/drug/widgets/annotation_cards/guideline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GuidelineAnnotationCard extends StatelessWidget {
Text.rich(
TextSpan(
children: [
TextSpan(
if (implicationText != null) TextSpan(
text: context.l10n.drugs_page_implication_description,
),
TextSpan(text: '\n'),
Expand Down
21 changes: 14 additions & 7 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class ListOption {

@RoutePage()
class ReportPage extends HookWidget {
const ReportPage({@visibleForTesting this.onlyShowWholeReport = false});

// Currently for testing but might use in the future
final bool onlyShowWholeReport;

@override
Widget build(BuildContext context) {
final currentListOption = useState(0);
Expand Down Expand Up @@ -115,13 +120,15 @@ class ReportPage extends HookWidget {
ActiveDrugs activeDrugs,
ValueNotifier<int> currentListOptionIndex,
) {
final listOptions = [
ListOption(
label: context.l10n.report_current_medications,
drugSubset: activeDrugs.names,
),
ListOption(label: context.l10n.report_all_medications),
];
final listOptions = onlyShowWholeReport
? [ListOption(label: context.l10n.report_all_medications)]
: [
ListOption(
label: context.l10n.report_current_medications,
drugSubset: activeDrugs.names,
),
ListOption(label: context.l10n.report_all_medications),
];
final currentListOption = listOptions[currentListOptionIndex.value];
final geneCards = _buildGeneCards(
drugsToFilterBy: currentListOption.drugSubset,
Expand Down

0 comments on commit 828ab91

Please sign in to comment.