diff --git a/app/integration_test/drugs_test.dart b/app/integration_test/drugs_test.dart index b615be88..f95b55c0 100644 --- a/app/integration_test/drugs_test.dart +++ b/app/integration_test/drugs_test.dart @@ -8,6 +8,7 @@ import 'package:mocktail/mocktail.dart'; import 'package:provider/provider.dart'; import 'fixtures/drugs/with_any_fallback_guideline.dart'; +import 'fixtures/drugs/with_multiple_any_other_fallback_guidelines.dart'; import 'fixtures/drugs/with_proper_guideline.dart'; import 'fixtures/drugs/without_guidelines.dart'; import 'fixtures/set_user_data_for_drug.dart'; @@ -74,6 +75,30 @@ void main() { drug: drugWithAnyFallbackGuideline, ); }); + + testWidgets('test drug content with any other fallback guidelines', (tester) async { + // Work in progress; this should fail! + // Open TODOs: + // 1. Start with easy case (not pazopanib, add fixture for FDA w/ HLA-B) + // 2. Set user data for different guidelines and test that selected + // guidelines are different (may want to refactor set user data + // to be useful here) + // 3. Add all pazopanib guidelines for complex case + Future testPerGuideline(Drug drug) async { + for ( + final guideline in drug.guidelines + ) { + await _expectDrugContent( + tester, + mockDrugsCubit, + drug: drug, + guideline: guideline, + ); + } + } + // await testPerGuideline(drugWithAnyOtherFallbackGuideline); + await testPerGuideline(drugWithMultipleAnyOtherFallbackGuidelines); + }); }); } @@ -84,9 +109,11 @@ Future _expectDrugContent( bool isLoading = false, bool expectNoGuidelines = false, bool expectDrugToBeActive = false, + Guideline? guideline, }) async { when(() => mockDrugsCubit.state) .thenReturn(isLoading ? DrugState.loading() : DrugState.loaded()); + final relevantGuideline = guideline ?? drug.guidelines.first; await tester.pumpWidget( ChangeNotifierProvider( create: (context) => ActiveDrugs(), @@ -138,7 +165,7 @@ Future _expectDrugContent( card.color, expectNoGuidelines ? WarningLevel.green.color - : drug.guidelines.first.annotations.warningLevel.color, + : relevantGuideline.annotations.warningLevel.color, ); expect(find.byType(Disclaimer), findsOneWidget); final context = tester.element(find.byType(Scaffold).first); @@ -158,16 +185,16 @@ Future _expectDrugContent( } else { expect( find.byTooltip(context.l10n.drugs_page_tooltip_guideline_present( - drug.guidelines.first.externalData.first.source, + relevantGuideline.externalData.first.source, )), findsOneWidget, ); expect( - find.text(drug.guidelines.first.annotations.implication), + find.text(relevantGuideline.annotations.implication), findsOneWidget, ); expect( - find.textContaining(drug.guidelines.first.annotations.recommendation), + find.textContaining(relevantGuideline.annotations.recommendation), findsOneWidget, ); for (final genotypeKey in drug.guidelineGenotypes) { diff --git a/app/integration_test/fixtures/drugs/with_multiple_any_other_fallback_guidelines.dart b/app/integration_test/fixtures/drugs/with_multiple_any_other_fallback_guidelines.dart new file mode 100644 index 00000000..affa8d1a --- /dev/null +++ b/app/integration_test/fixtures/drugs/with_multiple_any_other_fallback_guidelines.dart @@ -0,0 +1,43 @@ +import 'package:app/common/models/drug/drug.dart'; +import 'package:app/common/models/drug/guideline.dart'; +import 'package:app/common/models/drug/warning_level.dart'; + +final drugWithMultipleAnyOtherFallbackGuidelines = Drug( + id: '6686a865826414ec5b05c44e', + version: 1, + name: 'pazopanib', + rxNorm: 'RxNorm:714438', + annotations: DrugAnnotations( + drugclass: 'Anti-cancer', + indication: 'Pazopanib is used to treat cancer.', + brandNames: ['Votrient'], + ), + guidelines: [ + Guideline( + id: '66b50b2433cbe5c07ee31651', + version: 1, + lookupkey: { + 'HLA-B': ['~'], + 'UGT1A1': ['Poor Metabolizer'], + }, + externalData: [ + GuidelineExtData( + source: 'CPIC', + guidelineName: 'Table of Pharmacogenetic Associations (Section 2)', + guidelineUrl: 'https://www.fda.gov/medical-devices/precision-medicine/table-pharmacogenetic-associations#section2', + implications: { + 'HLA-B': 'Standard procedure', + 'UGT1A1': 'Results in higher adverse reaction risk (hyperbilirubinemia).', + }, + recommendation: 'Might be included in implication text (imported from FDA, source only states one text per guideline)', + comments: null, + ), + ], + annotations: GuidelineAnnotations( + implication: 'You have an increased risk for side effects.', + recommendation: 'You can still use pazopanib at standard dose. Consult your pharmacist or doctor for more information.', + warningLevel: WarningLevel.yellow, + ), + ), + ], +); \ No newline at end of file diff --git a/pharme.code-workspace b/pharme.code-workspace index d0139c9b..b303f968 100644 --- a/pharme.code-workspace +++ b/pharme.code-workspace @@ -98,7 +98,8 @@ "unstaged", "userdata", "Vicoprofen", - "voriconazole" + "voriconazole", + "Votrient" ] } }