-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
193 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/integration_test/fixtures/guidelines/aripiprazole_cyp2d6_poor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:app/common/models/drug/guideline.dart'; | ||
import 'package:app/common/models/drug/warning_level.dart'; | ||
|
||
final aripiprazoleCyp2d6PoorGuideline = Guideline( | ||
id: '6492f8e9918ddcae7349c304', | ||
version: 1, | ||
lookupkey: { | ||
'CYP2D6': ['0.0'], | ||
}, | ||
externalData: [ | ||
GuidelineExtData( | ||
source: 'FDA', | ||
guidelineName: 'Table of Pharmacogenetic Associations (Section 1)', | ||
guidelineUrl: 'https://www.fda.gov/medical-devices/precision-medicine/table-pharmacogenetic-associations#section1', | ||
implications: { | ||
'CYP2D6': 'Results in higher systemic concentrations and higher adverse reaction risk. Dosage adjustment is recommended. Refer to FDA labeling for specific dosing recommendations.', | ||
}, | ||
recommendation: 'Might be included in implication text (imported from FDA, source only states one text per guideline)', | ||
comments: null, | ||
), | ||
], | ||
annotations: GuidelineAnnotations( | ||
implication: 'You break down aripiprazole slower than expected. You have an increased risk for side effects.', | ||
recommendation: 'Aripiprazole may be used at a lower dose. Consult your pharmacist or doctor for more information.', | ||
warningLevel: WarningLevel.yellow, | ||
), | ||
); |
27 changes: 27 additions & 0 deletions
27
app/integration_test/fixtures/guidelines/guideline.dart.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:app/common/models/drug/guideline.dart'; | ||
import 'package:app/common/models/drug/warning_level.dart'; | ||
|
||
final nonCompilingPlaceholdersGuideline = Guideline( | ||
id: null, | ||
version: null, | ||
lookupkey: { | ||
null: [null], | ||
}, | ||
externalData: [ | ||
GuidelineExtData( | ||
source: null, | ||
guidelineName: null, | ||
guidelineUrl: null, | ||
implications: { | ||
null: null, | ||
}, | ||
recommendation: null, | ||
comments: null, | ||
), | ||
], | ||
annotations: GuidelineAnnotations( | ||
implication: null, | ||
recommendation: null, | ||
warningLevel: WarningLevel.null, | ||
), | ||
); |
29 changes: 29 additions & 0 deletions
29
...tegration_test/fixtures/guidelines/pazopanib_hlab5701_positive_ugt1a1_poor_guideline.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:app/common/models/drug/guideline.dart'; | ||
import 'package:app/common/models/drug/warning_level.dart'; | ||
|
||
final pazopanibHlab5701PositiveUgt1a1PoorGuideline = Guideline( | ||
id: '6686a865826414ec5b05c436', | ||
version: 1, | ||
lookupkey: { | ||
'HLA-B': ['*57:01 positive'], | ||
'UGT1A1': ['Poor Metabolizer'], | ||
}, | ||
externalData: [ | ||
GuidelineExtData( | ||
source: 'FDA', | ||
guidelineName: 'Table of Pharmacogenetic Associations (Section 2)', | ||
guidelineUrl: 'https://www.fda.gov/medical-devices/precision-medicine/table-pharmacogenetic-associations#section2', | ||
implications: { | ||
'HLA-B': 'May result in higher adverse reaction risk (liver enzyme elevations). Monitor liver function tests regardless of genotype.', | ||
'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. (Test case 1)', | ||
recommendation: 'You can still use pazopanib at standard dose. Consult your pharmacist or doctor for more information. (Test case 1)', | ||
warningLevel: WarningLevel.yellow, | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import 'package:app/common/module.dart'; | ||
import 'package:app/report/module.dart'; | ||
import 'package:flutter_localizations/flutter_localizations.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
import 'fixtures/guidelines/aripiprazole_cyp2d6_poor.dart'; | ||
import 'fixtures/guidelines/pazopanib_hlab5701_positive_ugt1a1_poor_guideline.dart'; | ||
import 'fixtures/set_user_data.dart'; | ||
|
||
void main() { | ||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps; | ||
|
||
setUp(() { | ||
UserData.instance.labData = null; | ||
UserData.instance.genotypeResults = null; | ||
}); | ||
|
||
Future<void> loadReportPage(WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
ChangeNotifierProvider( | ||
create: (context) => ActiveDrugs(), | ||
child: MaterialApp( | ||
home: Scaffold( | ||
body: Builder( | ||
builder: (context) { | ||
return ReportPage(); | ||
}, | ||
), | ||
), | ||
localizationsDelegates: [ | ||
AppLocalizations.delegate, | ||
GlobalMaterialLocalizations.delegate, | ||
GlobalWidgetsLocalizations.delegate, | ||
GlobalCupertinoLocalizations.delegate, | ||
], | ||
supportedLocales: [Locale('en', '')], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Future<void> testReportContent( | ||
WidgetTester tester, { | ||
required List<Guideline> expectedGuidelines, | ||
required List<GenotypeResult> missingResults, | ||
}) async { | ||
expectedGuidelines.forEach(setUserDataForGuideline); | ||
missingResults.forEach(setGenotypeResult); | ||
await loadReportPage(tester); | ||
final expectedGenes = [ | ||
...expectedGuidelines.flatMap( | ||
(guideline) => guideline.lookupkey.keys | ||
), | ||
...missingResults.map((genotypeResult) => genotypeResult.gene), | ||
]; | ||
expect( | ||
find.byType(GeneCard, skipOffstage: false), | ||
findsNWidgets(expectedGenes.length), | ||
); | ||
for (final gene in expectedGenes.toSet()) { | ||
final expectedGeneOccurrences = | ||
expectedGenes.count((expectedGene) => expectedGene == gene); | ||
expect( | ||
find.textContaining(gene, skipOffstage: false), | ||
findsNWidgets(expectedGeneOccurrences), | ||
); | ||
} | ||
} | ||
|
||
group('integration test for the report page', () { | ||
testWidgets( | ||
'tests that genes for drugs with guidelines are shown', | ||
(tester) async { | ||
final expectedGuidelines = [ | ||
aripiprazoleCyp2d6PoorGuideline, | ||
pazopanibHlab5701PositiveUgt1a1PoorGuideline, | ||
]; | ||
final missingResults = [ | ||
GenotypeResult.missingResult('HLA-B', variant: '*15:02'), | ||
]; | ||
await testReportContent( | ||
tester, | ||
expectedGuidelines: expectedGuidelines, | ||
missingResults: missingResults, | ||
); | ||
}, | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters