Fakultas Ilmu Komputer UI

Commit 02b099bd authored by Ardian Ghifari's avatar Ardian Ghifari
Browse files

Merge branch 'dev-ardian' into 'PBI-15-redesign_menu'

Add shimmer loading effect

See merge request !77
parents 828e3da4 0ec4b120
Pipeline #82078 failed with stages
in 10 minutes and 48 seconds
......@@ -29,6 +29,7 @@ class KomentarRepository implements BaseKomentarRepository {
final response = await _network.post(
url: '/informasi-fasilitas/lokasi/add-fasilitas/$namaLokasi/',
bodyParams: newKomentarData,
isLogin: true,
);
return response;
}
......
......@@ -10,11 +10,17 @@ import 'package:http/http.dart' as http;
abstract class BaseLokasiRepository {
Future<LokasiListResponse> fetchLokasi();
Future<LokasiListResponse> fetchRecentSearch();
Future<void> saveRecentSearch(Lokasi recentSearch);
Future<dynamic> addNewLokasi(Map<String, dynamic> lokasi);
Future<LokasiListResponse> fetchGooglePlacesLokasi(String lokasi);
String fetchPhoto(String photoReference, int maxHeight, int maxWidth);
Future<void> postSearchHistory(String placeId, String token);
}
......@@ -75,7 +81,9 @@ class LokasiRepository implements BaseLokasiRepository {
@override
Future<dynamic> addNewLokasi(Map<String, dynamic> lokasi) async {
final response = await _network.post(
url: '/informasi-fasilitas/lokasi/add/', bodyParams: lokasi);
url: '/informasi-fasilitas/lokasi/add/',
bodyParams: lokasi,
isLogin: true);
return response;
}
......
......@@ -60,12 +60,16 @@ class _KegiatanTerdekatButtonState extends State<KegiatanTerdekatButton> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(widget.kegiatan.namaKegiatan, //+widget.kegiatan.deskripsi,
style: const TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)),
Flexible(
child: Text(widget.kegiatan.namaKegiatan, //+widget.kegiatan.deskripsi,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: greenPrimary,
fontSize: 16,
fontFamily: 'Muli',
)
),
),
Text('more info>',
style: TextStyle(
color: Colors.grey,
......
......@@ -34,21 +34,21 @@ class CustomTextField extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
RichText(
key: Key(title),
text: TextSpan(
text: title,
style: const TextStyle(
fontSize: 18, color: Colors.black, fontFamily: 'Muli'),
children: <TextSpan>[
if (required)
const TextSpan(text: '*', style: TextStyle(color: red)),
],
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: RichText(
key: Key(title),
text: TextSpan(
text: title,
style: const TextStyle(
fontSize: 18, color: Colors.black, fontFamily: 'Muli'),
children: <TextSpan>[
if (required)
const TextSpan(text: '*', style: TextStyle(color: red)),
],
),
),
),
const SizedBox(
height: 10,
),
TextFormField(
readOnly: readOnly,
onSaved: onSaved,
......
......@@ -58,7 +58,12 @@ dependencies:
firebase_messaging: ^8.0.0-dev.15
carousel_slider: ^3.0.0
flushbar: ^1.10.4
shimmer: ^2.0.0
url_launcher: ^6.0.3
photo_view: ^0.11.1
multi_image_picker: ^4.8.1
permission_handler: ^5.1.0+2
http_parser: ^3.1.4
dev_dependencies:
flutter_test:
......
import 'dart:async';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/filter_fasilitas/add_kegiatan.dart';
import 'package:bisaGo/page/filter_fasilitas/fasilitas.dart';
import 'package:bisaGo/repository/kegiatan_repository.dart';
import 'package:bisaGo/repository/komentar_posting_repository.dart';
import 'package:bisaGo/repository/komentar_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:bisaGo/utils/custom_text_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:mockito/mockito.dart';
import 'package:network_image_mock/network_image_mock.dart';
class MockKomentarRepository extends Fake implements KomentarRepository {}
class MockLokasiRepository extends Fake implements LokasiRepository {
final mockLokasi = {
'placeId': 'lKHBIUnKLJnKjnKLN',
'name': 'Margo City',
'alamat':
'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'static/img/2669211407.jpg',
'no_telp': '02178870888',
'counter': 69,
};
@override
Future<LokasiListResponse> fetchLokasi() async {
return Future.value(LokasiListResponse([Lokasi.fromJson(mockLokasi)]));
}
}
class MockKomentarPostingRepository extends Fake
implements KomentarPostingRepository {}
class MockKegiatanRepository extends Fake implements KegiatanRepository {
final mockKegiatan = {
'id': 1,
'place_id': 'asdfghjkl',
'creator': 'Jovi',
'nama_kegiatan': 'Jalan Sehat',
'penyelenggara': 'Gubernur',
'narahubung': 'Rafif (088012341234)',
'deskripsi': 'Jalan sehat keliling kota',
'time_start': '16-05-2021 06:00:00',
'time_end': '',
'image': '',
};
@override
Future<KegiatanList> fetchKegiatan(String placeId) {
return Future.value(KegiatanList([KegiatanModel.fromJson(mockKegiatan)]));
}
}
void main() {
final mockLokasi = {
'name': 'Margo City',
'alamat':
'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'static/img/2669211407.jpg',
'no_telp': '02178870888',
'counter': 69,
};
final mockKegiatan = {
'id': 1,
'place_id': 'asdfghjkl',
'creator': 'Jovi',
'nama_kegiatan': 'Jalan Sehat',
'penyelenggara': 'Gubernur',
'narahubung': 'Rafif (0880123456123456)',
'deskripsi': 'Jalan sehat keliling kota',
'time_start': '2021-05-15 06:00:00',
'time_end': '2021-05-15 10:00:00',
'image': ['a', 'b', 'c'],
};
setUpAll(() {
final _getIt = GetIt.instance;
_getIt.registerLazySingleton<BaseKomentarRepository>(
() => MockKomentarRepository());
_getIt.registerLazySingleton<BaseKomentarPostingRepository>(
() => MockKomentarPostingRepository());
_getIt.registerLazySingleton<BaseLokasiRepository>(
() => MockLokasiRepository());
_getIt.registerLazySingleton<BaseKegiatanRepository>(
() => MockKegiatanRepository());
});
testWidgets('Test Tambah Kegiatan Page',
(WidgetTester tester) async {
await mockNetworkImagesFor(() => tester.pumpWidget(
MaterialApp(
home: Fasilitas(
lokasi: Lokasi.fromJson(mockLokasi),
kegiatan: KegiatanModel.fromJson(mockKegiatan),
)
)
));
await tester.pump();
expect(find.text('Margo City'), findsOneWidget);
expect(find.text('Kegiatan'), findsOneWidget);
await tester.drag(find.text('Tambah Informasi'), Offset(-500, 0));
await tester.pump();
await tester.tap(find.text('Tambah Kegiatan'));
await tester.pump();
}
);
testWidgets('Test Form Tambah Kegiatan',
(WidgetTester tester) async {
await mockNetworkImagesFor(
() => tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return MaterialApp(
home: Material(
child: AddKegiatan(nama: 'Margo City', placeId: 'asdfghjkl'),
)
);
},
)
)
);
expect(find.byType(CustomTextField), findsWidgets);
expect(find.byType(ElevatedButton), findsOneWidget);
}
);
}
......@@ -3,65 +3,67 @@ import 'package:bisaGo/model/lokasi.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:bisaGo/config/strings.dart';
import 'package:bisaGo/model/komentar.dart';
// import 'package:bisaGo/model/user.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post.dart';
// import 'package:bisaGo/page/profile/profile.dart';
// import 'package:get_it/get_it.dart';
import 'package:mockito/mockito.dart';
import 'package:bisaGo/repository/komentar_posting_repository.dart';
// import 'package:bisaGo/repository/user_repository.dart';
// import 'package:shared_preferences/shared_preferences.dart';
void main() {
// Widget buildTestableWidget(Widget widget) {
// return MediaQuery(data: MediaQueryData(), child: MaterialApp(home: widget));
// }
class MockKomentarPostingRepository extends Fake
implements KomentarPostingRepository {}
// class MockUserRepository extends Fake implements UserRepository {
// final userData = {
// 'is_login': true,
// 'username': 'ardianghi@gmail.com',
// 'name': 'Ardian Ghifari',
// 'email': 'ardianghi@gmail.com',
// 'tanggal_lahir': '1999-01-01',
// 'phone_number': '08581190000',
// 'jenis_kelamin': 'Laki-Laki',
// 'disabilitas': 'Tidak memiliki disabilitas',
// 'pekerjaan': 'Pelajar',
// 'alamat': 'Tidak Tahu'
// };
// @override
// Future<User> fetchUserDetail(String email) async {
// return Future.value(User([UserModel.fromJson(userData)]));
// }
// }
final detailPostData = {
void main() {
const mockFasilitas = {
'id': 119,
'nama_lokasi': 'Margo City',
'deskripsi':
'Ada toilet khusus disabilitas terletak di lantai 2 dekat kintan, kondisinya bagus dan bersih layak pakai.\r\n\r\nAda kursi roda juga di customer service lantai dasar, saya tidak ingat jumlahnya ada berapa, tapi ada lumayan banyak.',
'creator': '',
'date_time': '12-04-2020 14:33:54',
'rating': 3,
'tag': 'KR',
'disabilitas': ['DF'],
'deskripsi': 'loremipsum ipsmum',
'creator': 'Ardian Ghifari',
'email': 'ardianghi@gmail.com',
'date_time': '12-11-2020 02:56:49',
'tag': 'JI',
'disabilitas': ['DS'],
'image': 'static/img/2669211407.jpg',
'is_verified': false
'is_verified': false,
'jumlah': 2,
'rating': 5
};
const mockLokasi = {
'name': 'Margo City',
'alamat':
'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'static/img/2669211407.jpg',
'no_telp': '02178870888',
'counter': 69,
};
final detailPostPage = DetailPostPage(
komentar: KomentarModel.fromJson(detailPostData),
lokasi: Lokasi.fromJson({
'id': 1,
'name': 'Soppeng',
'latitude': 100039203300.0,
'longitude': 100000000000.0,
'alamat': 'Jalan Margonda Raya',
'no_telp': '081111111111',
'image': '/media/test.jpg'
}),
komentar: KomentarModel.fromJson(mockFasilitas),
lokasi: Lokasi.fromJson(mockLokasi),
);
// testWidgets('Detail post positive test', (WidgetTester tester) async {
// // Provide the childWidget to the Container.
// await tester.pumpWidget(buildTestableWidget(detailPostPage));
// expect(find.byKey(Key('appbar-text-${detailPostData['nama_lokasi']}')),
// findsOneWidget);
// expect(find.byKey(Key('desc')), findsOneWidget);
// expect(find.byKey(Key('creator-${detailPostData['creator']}')),
// findsOneWidget);
// expect(find.byKey(Key('timestamp')), findsOneWidget);
// expect(find.byKey(Key('tambah komentar')), findsOneWidget);
// expect(find.byKey(Key('Komentar')), findsOneWidget);
// expect(find.text('${fasilitas[detailPostData['tag']]}'), findsOneWidget);
// expect(find.byKey(Key('Text Jumlah')), findsOneWidget);
// expect(find.byKey(Key('Icon DF')), findsOneWidget);
// expect(find.byKey(Key('Button Ubah Informasi')), findsOneWidget);
// expect(find.byKey(Key('Text Cara Menggunakan')), findsOneWidget);
// expect(find.byKey(Key('Text Field Komentar')), findsOneWidget);
// });
//
// testWidgets('Detail post negative test', (WidgetTester tester) async {
// // Provide the childWidget to the Container.
// await tester.pumpWidget(buildTestableWidget(detailPostPage));
// expect(find.byKey(Key('appbar-text')), findsNothing);
// expect(find.byKey(Key('creator')), findsNothing);
// expect(find.byKey(Key('komentar')), findsNothing);
// expect(find.text('Bidang Miring'), findsNothing);
// expect(find.byKey(Key('Icon DS')), findsNothing);
// });
testWidgets('Create a komentar placeholder', (WidgetTester tester) async {
final detailPostState = detailPostPage.createState();
......@@ -85,6 +87,50 @@ void main() {
);
});
// testWidgets('Show profile if fasilitas creator is clicked - Positive',
// (WidgetTester tester) async {
// final namaKey = find.byKey(Key('creator-${mockFasilitas['email']}'));
// await tester.pumpWidget(MaterialApp(home: detailPostPage));
// await tester.pump();
// await tester.tap(namaKey);
// await tester.pump();
// expect(find.byType(Profile), findsOneWidget);
// expect(find.text('Ardian Ghifari'), findsOneWidget);
// });
// testWidgets('Show profile if fasilitas creator is clicked - Negative',
// (WidgetTester tester) async {
// final namaKey = find.byKey(Key('creator-${mockFasilitas['email']}'));
// await tester.pumpWidget(MaterialApp(home: detailPostPage));
// await tester.pump();
// await tester.tap(namaKey);
// await tester.pump();
// expect(find.byType(DetailPostPage), findsNothing);
// expect(find.text('Ariq'), findsNothing);
// });
// testWidgets('Show profile if komentar creator is clicked - Positive',
// (WidgetTester tester) async {
// final namaKey = find.byKey(Key('komentar-Ardian Ghifari-1'));
// await tester.pumpWidget(MaterialApp(home: detailPostPage));
// await tester.pump();
// await tester.tap(namaKey);
// await tester.pump();
// expect(find.byType(Profile), findsOneWidget);
// expect(find.text('Ardian Ghifari'), findsOneWidget);
// });
// testWidgets('Show profile if komentar creator is clicked - Negative',
// (WidgetTester tester) async {
// final namaKey = find.byKey(Key('komentar-Ardian Ghifari-1'));
// await tester.pumpWidget(MaterialApp(home: detailPostPage));
// await tester.pump();
// await tester.tap(namaKey);
// await tester.pump();
// expect(find.byType(DetailPostPage), findsNothing);
// expect(find.text('Ariq'), findsNothing);
// });
test('Should decrypt tag code', () {
expect(getTag('KR'), tags['KR']);
});
......
import 'package:bisaGo/page/filter_fasilitas/kegiatan_image_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:network_image_mock/network_image_mock.dart';
void main() {
testWidgets('Test Kegiatan Image View',
(WidgetTester tester) async {
await mockNetworkImagesFor(
() => tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return MaterialApp(
home: Material(
child: KegiatanImageView(''),
)
);
},
)
)
);
expect(find.byType(KegiatanImageView), findsOneWidget);
}
);
}
\ No newline at end of file
import 'package:bisaGo/page/filter_fasilitas/kegiatan_list_images.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:network_image_mock/network_image_mock.dart';
void main() {
testWidgets('Test Kegiatan List Images',
(WidgetTester tester) async {
await mockNetworkImagesFor(
() => tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return MaterialApp(
home: Material(
child: KegiatanListImages([''], 'Makan bersama'),
)
);
},
)
)
);
expect(find.byType(KegiatanListImages), findsWidgets);
expect(find.text('Makan bersama'), findsOneWidget);
}
);
}
\ No newline at end of file
......@@ -107,6 +107,12 @@ void main() {
await tester.pump();
}
// testWidgets('Shimmer loading exists - Positive',
// (WidgetTester tester) async {
// await tester.pumpWidget(MaterialApp(home: Dashboard()));
// expect(find.byKey(Key('Shimmer loading')), findsOneWidget);
// });
testWidgets(
'when tapping text form field, should navigate to pencarian page',
(WidgetTester tester) async {
......
......@@ -85,12 +85,12 @@ void main() {
final komentarPostingModel =
KomentarPostingModel.fromJson(komentarPostingData);
final komentarPostingWithConstructor = KomentarPostingModel(
id: 2,
deskripsi: 'This is a test',
creator: 'Test',
creatorEmail: 'test@email.com',
creatorPicture: 'test.jpg',
created: DateTime.now());
id: 2,
deskripsi: 'This is a test',
creator: 'Test',
creatorEmail: 'test@email.com',
creatorPicture: 'test.jpg',
created: DateTime.now());
expect(komentarPostingModel, isInstanceOf<KomentarPostingModel>());
expect(
komentarPostingWithConstructor, isInstanceOf<KomentarPostingModel>());
......
......@@ -22,7 +22,7 @@ void main() {
expect(find.byType(Icon), findsNWidgets(5));
expect(find.byType(Row), findsNWidgets(6));
expect(find.byType(Scaffold), findsOneWidget);
expect(find.byType(SizedBox), findsNWidgets(61));
expect(find.byType(SizedBox), findsNWidgets(53));
expect(find.byType(TextButton), findsNWidgets(3));
//negative test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment