Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit b4989f04 authored by Fakhira Devina's avatar Fakhira Devina
Browse files
parents e28b03c4 68058279
No related branches found
No related tags found
14 merge requests!148Draft: Sync staging,!124Sprint 1, 2, & 3,!103Tentang Disabilitas page,!94Final bisago,!93All features done,!75merge staging to PBI 8,!46Halaman detail postingan,!41Menyelesaikan PBI-7 Informasi Sekolah dengan Dukungan Disabilitas,!39aleady made front end for informasi layanan disabilitas,!29Dev feriyal - test fungsional pencarian,!20Initial Merge for spirit 2,!19Initial merge for Sprint 2,!16Dashboard feature,!13Dev afrah
Pipeline #54868 failed
......@@ -62,11 +62,12 @@ class DashboardState extends State<Dashboard> {
}
}
void _navigateToPencarianPage(BuildContext context) {
void _navigateToPencarianPage(BuildContext context) {
final route = MaterialPageRoute(builder: (_) => Pencarian());
Navigator.of(context).push(route);
}
static const textFieldKey = Key('Text Field Mau Kemana');
@override
Widget build(BuildContext context) {
return Scaffold(
......
import 'package:flutter/material.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
class MockNavigatorObserver extends Mock implements NavigatorObserver {}
void main() {
group('Dashboard navigation tests', () {
NavigatorObserver mockObserver;
setUp(() {
mockObserver = MockNavigatorObserver();
});
Future<Null> _buildDashboardPage(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Dashboard(),
/// This mocked observer will now receive all navigation events
/// that happen in our app.
navigatorObservers: [mockObserver],
));
/// The tester.pumpWidget() call above just built our app widget
/// and triggered the pushObserver method on the mockObserver once.
verify(mockObserver.didPush(any, any));
}
Future<Null> _navigateToPencarianPage(WidgetTester tester) async {
final textFieldKey = Key("Text Field Mau Kemana");
await tester.tap(find.byKey(textFieldKey));
await tester.pumpAndSettle();
}
testWidgets(
'when tapping text form field, should navigate to pencarina page',
(WidgetTester tester) async {
final textFieldKeyPencarian = Key("Text Field Mau Kemana");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
verify(mockObserver.didPush(any, any));
expect(find.byKey(textFieldKeyPencarian), findsOneWidget);
});
testWidgets('tapping the back button should navigate back to the dashboard',
(WidgetTester tester) async {
final backIconKey = Key("Back Icon Key");
await _buildDashboardPage(tester);
await _navigateToPencarianPage(tester);
final Route pushedRoute =verify(mockObserver.didPush(captureAny, any)).captured.single;
String popResult;
pushedRoute.popped.then((result) => popResult = result);
await tester.tap(find.byKey(backIconKey));
await tester.pumpAndSettle();
expect(popResult, 'Take me back');
});
});
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment