Skip to content

Commit

Permalink
test(#259): mark tutorial as done in present main page tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Apr 9, 2024
1 parent 7674ede commit 6890d52
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 38 deletions.
85 changes: 47 additions & 38 deletions app/integration_test/faq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,62 @@ import 'package:integration_test/integration_test.dart';

void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();

binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps;

group('integration test for the faq page', () {
final appRouter = AppRouter();
final faqWidget = MaterialApp.router(
routeInformationParser: appRouter.defaultRouteParser(),
routerDelegate: appRouter.delegate(
deepLinkBuilder: (_) => DeepLink.path('/main/faq'),
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
);

testWidgets('All questions are loaded and expansion tiles can be open',
(tester) async {
await tester.pumpWidget(faqWidget);
await tester.pumpAndSettle();
late MaterialApp faqWidget;

final expectedNumberOfQuestions = faqList.keys.fold<int>(
0, (number, topic) => number + faqList[topic]!.length
setUpAll(() async {
await initServices();
MetaData.instance.tutorialDone = true;
await MetaData.save();
final appRouter = AppRouter();
faqWidget = MaterialApp.router(
routeInformationParser: appRouter.defaultRouteParser(),
routerDelegate: appRouter.delegate(
deepLinkBuilder: (_) => DeepLink.path('/main/faq'),
),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
);
});

expect(
find
.descendant(
of: find.byKey(ValueKey('questionsColumn')),
matching: find.byType(ExpansionTile),
)
.evaluate()
.length,
expectedNumberOfQuestions,
);
testWidgets(
'All questions are loaded and expansion tiles can be open',
(tester) async {
await tester.pumpWidget(faqWidget);
await tester.pumpAndSettle();

final firstQuestion = faqList[faqList.keys.first]![0];
expect(find.text(firstQuestion.question), findsOneWidget);
expect(find.text(firstQuestion.answer), findsNothing);
final expectedNumberOfQuestions = faqList.keys.fold<int>(
0, (number, topic) => number + faqList[topic]!.length
);

await tester.tap(find.byType(ExpansionTile).first);
await tester.pumpAndSettle();
expect(
find
.descendant(
of: find.byKey(ValueKey('questionsColumn')),
matching: find.byType(ExpansionTile),
)
.evaluate()
.length,
expectedNumberOfQuestions,
);

expect(find.text(firstQuestion.answer), findsOneWidget);
});
final firstQuestion = faqList[faqList.keys.first]![0];
expect(find.text(firstQuestion.question), findsOneWidget);
expect(find.text(firstQuestion.answer), findsNothing);

await tester.tap(find.byType(ExpansionTile).first);
await tester.pumpAndSettle();

expect(find.text(firstQuestion.answer), findsOneWidget);
},
);
});
}
2 changes: 2 additions & 0 deletions app/integration_test/main_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void main() {
group('test the main page', () {
testWidgets('test that tabs change pages', (tester) async {
await initServices();
MetaData.instance.tutorialDone = true;
await MetaData.save();
final appRouter = AppRouter();
await tester.pumpWidget(
ChangeNotifierProvider(
Expand Down
3 changes: 3 additions & 0 deletions app/integration_test/more_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ void main() {

group('test settings page', () {
testWidgets('right things are getting rendered', (tester) async {
await initServices();
MetaData.instance.tutorialDone = true;
await MetaData.save();
final appRouter = AppRouter();
await tester.pumpWidget(MaterialApp.router(
debugShowCheckedModeBanner: false,
Expand Down

0 comments on commit 6890d52

Please sign in to comment.