Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
pilar
pilar-mobile
Commits
7f1b9719
Commit
7f1b9719
authored
Apr 08, 2021
by
Azhar Difa Arnanda
💬
Browse files
Merge branch 'dev' into 'master'
Dev See merge request
!7
parents
f1d55e38
480b0b78
Pipeline
#70300
passed with stages
in 7 minutes and 52 seconds
Changes
30
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
7f1b9719
image
:
tiangppl/pilarmobile:latest
image
:
cirrusci/flutter:1.22.6
before_script
:
-
export PATH=$PATH:/sdk/android-sdk-linux/platform-tools/
-
echo flutter.sdk=/sdk/flutter > android/local.properties
-
mkdir -p assets/cfg
-
cp $APP_SETTINGS assets/cfg/app_settings.json
-
touch assets/cfg/app_settings.json
-
echo $APP_SETTINGS > assets/cfg/app_settings.json
-
flutter pub get
-
flutter clean
stages
:
-
lint
-
test
-
sonarqube
-
build
-
deploy
lint:flutter:
stage
:
lint
...
...
@@ -22,99 +19,9 @@ lint:flutter:
test:flutter:
stage
:
test
script
:
-
flutter test --coverage
--test-randomize-ordering-seed=random
-
flutter test --machine > tests.output
-
lcov --summary coverage/lcov.info
-
flutter test --coverage
-
lcov -r coverage/lcov.info '*/__test*__/*' -o coverage/lcov_cleaned.info
-
genhtml coverage/lcov_cleaned.info --output=coverage
artifacts
:
expire_in
:
1 hour
paths
:
-
coverage/lcov.info
-
tests.output
sonarqube
:
dependencies
:
-
test:flutter
stage
:
sonarqube
before_script
:
-
export PATH=$PATH:/sdk/flutter/bin/cache/dart-sdk/bin
-
flutter pub get
script
:
-
sonar-scanner -Dsonar.login=$SONARQUBE_TOKEN -Dsonar.branch.name=$CI_COMMIT_REF_NAME -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
build:appbundle:
stage
:
build
script
:
-
cp $APP_SETTINGS assets/cfg/app_settings.json
-
mv $KEY_PROPERTIES_ANDROID android/key.properties
-
echo $KEYSTORE_ANDROID | base64 -d > android/app/key.jks
-
echo $CI_PIPELINE_IID
-
mkdir symbols
-
flutter build appbundle --build-number $CI_PIPELINE_IID --obfuscate --split-debug-info=symbols
artifacts
:
paths
:
-
build/app/outputs/bundle/release
-
symbols
expire_in
:
3 days
only
:
-
staging
build:appbundle-prod:
stage
:
build
script
:
-
cp $APP_SETTINGS_PROD assets/cfg/app_settings.json
-
mv $KEY_PROPERTIES_ANDROID android/key.properties
-
echo $KEYSTORE_ANDROID | base64 -d > android/app/key.jks
-
echo $CI_PIPELINE_IID
-
mkdir symbols
-
flutter build appbundle --build-number $CI_PIPELINE_IID --obfuscate --split-debug-info=symbols
artifacts
:
paths
:
-
build/app/outputs/bundle/release
-
symbols
expire_in
:
3 days
only
:
-
master
deploy:play-internal:
image
:
ruby:2.6.5
stage
:
deploy
variables
:
LC_ALL
:
"
en_US.UTF-8"
LANG
:
"
en_US.UTF-8"
dependencies
:
-
build:appbundle
environment
:
name
:
Play Store internal
before_script
:
-
mv $KEY_FASTLANE_ANDROID android/key-fastlane.json
-
mv android/fastlane/metadata/android/id/changelogs/changelogs.txt android/fastlane/metadata/android/id/changelogs/$CI_PIPELINE_IID.txt
-
cd android
-
gem install bundler
-
bundle install
script
:
-
bundle exec fastlane supply --aab ../build/app/outputs/bundle/release/app-release.aab --track internal
only
:
-
staging
deploy:play-alpha:
image
:
ruby:2.6.5
stage
:
deploy
variables
:
LC_ALL
:
"
en_US.UTF-8"
LANG
:
"
en_US.UTF-8"
dependencies
:
-
build:appbundle-prod
environment
:
name
:
Play Store alpha
before_script
:
-
mv $KEY_FASTLANE_ANDROID android/key-fastlane.json
-
mv android/fastlane/metadata/android/id/changelogs/changelogs.txt android/fastlane/metadata/android/id/changelogs/$CI_PIPELINE_IID.txt
-
cd android
-
gem install bundler
-
bundle install
script
:
-
bundle exec fastlane supply --aab ../build/app/outputs/bundle/release/app-release.aab --track alpha
only
:
-
master
when
:
manual
\ No newline at end of file
-
coverage
\ No newline at end of file
README.md
View file @
7f1b9719
# home_industry
[

](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/
2020/ppl-c/diskominfo-depok-tpu-online/post-rpl
-mobile/commits/
master
)
[

](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/
2020/ppl-c/diskominfo-depok-tpu-online/post-rpl
-mobile/-/commits/
master
)
[

](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/
sosial/pilar/pilar
-mobile/
-/
commits/
dev
)
[

](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/
sosial/pilar/pilar
-mobile/-/commits/
dev
)
Home Industry is a platform that sell various goods
...
...
lib/Component/bottom_navigation_bar.dart
View file @
7f1b9719
...
...
@@ -130,19 +130,19 @@ class _BottomNavigationState extends State<BottomNavigation> {
icon:
Icon
(
Icons
.
home
,
),
title:
Text
(
'Home'
)
)
,
label:
'Home'
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
archive
),
title:
Text
(
'Donasi saya'
)
)
,
icon:
Icon
(
Icons
.
archive
),
label:
'Donasi saya'
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
receipt
,
),
title:
Text
(
'Belanja Saya'
)
)
,
label:
'Belanja Saya'
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
person_outline
,
),
title:
Text
(
'Akun'
)
)
label:
'Akun'
)
],
currentIndex:
_selectedIndex
,
selectedItemColor:
Theme
.
of
(
context
).
primaryColor
,
...
...
lib/Component/custom_input_form.dart
View file @
7f1b9719
...
...
@@ -57,7 +57,7 @@ class _CustomTextInputFormState extends State<CustomTextInputForm> {
textInputAction:
widget
.
textInputAction
,
keyboardType:
widget
.
isNumberOnly
?
TextInputType
.
number
:
null
,
inputFormatters:
widget
.
isNumberOnly
?
<
TextInputFormatter
>[
Whitelist
ingTextInputFormatter
.
digitsOnly
]
?
<
TextInputFormatter
>[
Filter
ingTextInputFormatter
.
digitsOnly
]
:
null
,
validator:
(
value
)
{
if
(
value
.
isEmpty
)
{
...
...
lib/Component/price_text_formatter.dart
View file @
7f1b9719
...
...
@@ -3,18 +3,19 @@ import 'package:intl/intl.dart';
class
PriceTextFormatter
extends
StatelessWidget
{
final
NumberFormat
formatter
=
NumberFormat
.
currency
(
decimalDigits:
0
,
symbol:
'Rp'
);
NumberFormat
.
currency
(
decimalDigits:
0
,
symbol:
'Rp
'
);
final
String
price
;
final
String
unit
;
final
TextStyle
style
;
final
Key
keyText
;
PriceTextFormatter
({
Key
key
,
@required
this
.
price
,
this
.
style
,
this
.
keyText
})
PriceTextFormatter
({
Key
key
,
@required
this
.
price
,
this
.
unit
,
this
.
style
,
this
.
keyText
})
:
assert
(
price
!=
null
),
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Text
(
formatter
.
format
(
double
.
parse
(
price
)),
unit
!=
null
?
formatter
.
format
(
double
.
parse
(
price
))
+
' / '
+
unit
:
formatter
.
format
(
double
.
parse
(
price
)),
key:
keyText
,
overflow:
TextOverflow
.
ellipsis
,
maxLines:
1
,
...
...
lib/Pages/Cart/cart.dart
View file @
7f1b9719
...
...
@@ -195,6 +195,7 @@ class _CartDescription extends StatelessWidget {
),
PriceTextFormatter
(
price:
'
${cartItem.product.price}
'
,
unit:
'
${cartItem.product.unit}
'
,
),
],
),
...
...
@@ -248,7 +249,7 @@ class _CartDescription extends StatelessWidget {
fontSize:
15
),
children:
<
TextSpan
>[
TextSpan
(
text:
'
${cartItem.quantity}
'
,
text:
'
${cartItem.quantity}
${cartItem.product.unit}
'
,
style:
TextStyle
(
color:
Theme
.
of
(
context
).
primaryColor
,
fontSize:
16
,
...
...
@@ -373,6 +374,7 @@ class _ModalCartItem extends StatelessWidget {
children:
<
Widget
>[
PriceTextFormatter
(
price:
cartItem
.
product
.
price
,
unit:
cartItem
.
product
.
unit
,
style:
TextStyle
(
color:
Theme
.
of
(
context
)
.
primaryColor
,
...
...
@@ -380,7 +382,7 @@ class _ModalCartItem extends StatelessWidget {
),
Text
(
'Stok: '
'
${cartItem.product.stock}
'
,
'
${cartItem.product.stock}
${cartItem.product.unit}
'
,
style:
const
TextStyle
(
fontSize:
17
),
)
],
...
...
lib/Pages/Product/component/list_product_grid.dart
View file @
7f1b9719
...
...
@@ -156,6 +156,7 @@ class ProductGrid extends StatelessWidget {
),
PriceTextFormatter
(
price:
_product
.
price
,
unit:
_product
.
unit
,
),
],
),
...
...
lib/Pages/Product/component/product_item_list.dart
View file @
7f1b9719
...
...
@@ -90,13 +90,14 @@ class _ProductDescription extends StatelessWidget {
children:
<
Widget
>[
PriceTextFormatter
(
price:
'
${product.price}
'
,
unit:
'
${product.unit}
'
,
style:
const
TextStyle
(
fontSize:
15
,
color:
Colors
.
black87
,
),
),
Text
(
'Stock:
${product.stock}
'
,
'Stock:
${product.stock}
${product.unit}
'
,
style:
const
TextStyle
(
fontSize:
15
,
color:
Colors
.
black54
,
...
...
lib/Pages/Product/detail_product.dart
View file @
7f1b9719
...
...
@@ -98,13 +98,14 @@ class _BodyDetailProduct extends StatelessWidget {
children:
<
Widget
>[
PriceTextFormatter
(
price:
product
.
price
,
unit:
product
.
unit
,
style:
TextStyle
(
color:
Theme
.
of
(
context
)
.
primaryColor
,
fontSize:
20
),
),
Text
(
'Stok:
${product.stock}
'
,
'Stok:
${product.stock}
${product.unit}
'
,
style:
const
TextStyle
(
fontSize:
17
),
)
...
...
lib/Pages/Product/model/product/product.dart
View file @
7f1b9719
...
...
@@ -14,6 +14,7 @@ class Product extends Equatable {
final
String
subcategoryName
;
final
String
description
;
final
String
price
;
final
String
unit
;
@JsonKey
(
nullable:
true
)
final
int
stock
;
...
...
@@ -31,7 +32,8 @@ class Product extends Equatable {
this
.
description
,
this
.
price
,
this
.
stock
,
this
.
image
});
this
.
image
,
this
.
unit
});
factory
Product
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$ProductFromJson
(
json
);
...
...
@@ -49,5 +51,6 @@ class Product extends Equatable {
price
,
stock
,
image
,
unit
,
];
}
lib/Pages/Product/model/product/product.g.dart
View file @
7f1b9719
...
...
@@ -18,6 +18,7 @@ Product _$ProductFromJson(Map<String, dynamic> json) {
price:
json
[
'price'
]
as
String
,
stock:
json
[
'stock'
]
as
int
,
image:
json
[
'image'
]
as
String
,
unit:
json
[
'unit'
]
as
String
,
);
}
...
...
@@ -32,4 +33,5 @@ Map<String, dynamic> _$ProductToJson(Product instance) => <String, dynamic>{
'price'
:
instance
.
price
,
'stock'
:
instance
.
stock
,
'image'
:
instance
.
image
,
'unit'
:
instance
.
unit
,
};
lib/Pages/Summary/summary_page.dart
View file @
7f1b9719
...
...
@@ -464,7 +464,7 @@ class _Donation extends StatelessWidget {
scrollPadding:
const
EdgeInsets
.
only
(
bottom:
80
),
scrollPhysics:
const
BouncingScrollPhysics
(),
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
Whitelist
ingTextInputFormatter
.
digitsOnly
],
inputFormatters:
[
Filter
ingTextInputFormatter
.
digitsOnly
],
onSubmitted:
(
donation
)
{
BlocProvider
.
of
<
SummaryBloc
>(
context
)
.
add
(
AddDonation
(
double
.
parse
(
donation
)));
...
...
test/bottom_navigation_bar_test.dart
View file @
7f1b9719
...
...
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:home_industry/Component/bottom_navigation_bar.dart'
;
import
'package:home_industry/Component/custom_circular.dart'
;
import
'package:home_industry/Component/modal_bottom_admin_info.dart'
;
import
'package:home_industry/Component/router.dart'
;
import
'package:home_industry/Component/router.dart'
as
router
;
import
'package:home_industry/Pages/Cart/bloc/bloc.dart'
;
import
'package:home_industry/Pages/Profile/bloc/bloc.dart'
;
import
'package:home_industry/Pages/Profile/model/profile.dart'
;
...
...
@@ -46,7 +46,7 @@ void main() {
child:
BlocProvider
<
CartBloc
>.
value
(
value:
cartBloc
,
child:
MaterialApp
(
onGenerateRoute:
Router
.
generateRoute
,
onGenerateRoute:
router
.
Router
.
generateRoute
,
home:
Scaffold
(
bottomNavigationBar:
BlocProvider
<
ProfileBloc
>.
value
(
value:
bloc
,
...
...
test/cart_page_test.dart
View file @
7f1b9719
...
...
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:home_industry/Component/price_text_formatter.dart'
;
import
'package:home_industry/Component/router.dart'
;
import
'package:home_industry/Component/router.dart'
as
router
;
import
'package:home_industry/Pages/Cart/bloc/bloc.dart'
;
import
'package:home_industry/Pages/Cart/cart.dart'
;
import
'package:home_industry/Pages/Cart/model/cart_entity.dart'
;
...
...
@@ -427,7 +427,7 @@ void main() {
testedWidget
=
BlocProvider
<
CartBloc
>.
value
(
value:
cartBloc
,
child:
MaterialApp
(
onGenerateRoute:
Router
.
generateRoute
,
onGenerateRoute:
router
.
Router
.
generateRoute
,
home:
const
CartView
(),
));
});
...
...
test/category_page_test.dart
View file @
7f1b9719
import
'package:badges/badges.dart'
;
import
'package:bloc_test/bloc_test.dart'
;
import
'package:dio/dio.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
hide
Router
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:home_industry/Component/custom_circular.dart'
;
...
...
test/detail_order_test.dart
View file @
7f1b9719
...
...
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:home_industry/Component/modal_bottom_admin_info.dart'
;
import
'package:home_industry/Component/router.dart'
;
import
'package:home_industry/Component/router.dart'
as
router
;
import
'package:home_industry/Pages/Transactions/bloc/bloc.dart'
;
import
'package:home_industry/Pages/Transactions/detail_bloc/bloc.dart'
;
import
'package:home_industry/Pages/Transactions/detail_bloc/detail_order_bloc.dart'
;
...
...
@@ -63,7 +63,7 @@ void main() {
value:
changeBottomNavigationBarBloc
)
],
child:
MaterialApp
(
onGenerateRoute:
Router
.
generateRoute
,
onGenerateRoute:
router
.
Router
.
generateRoute
,
home:
MyDetailOrder
(),
),
),
...
...
@@ -87,7 +87,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Ubah bukti pembayaran'
),
findsOneWidget
);
await
tester
.
fling
(
find
.
text
(
'GTXWP3PJ'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
...
...
@@ -102,7 +102,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Ubah bukti pembayaran'
),
findsOneWidget
);
});
...
...
@@ -112,7 +112,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsOneWidget
);
});
...
...
@@ -122,7 +122,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Batalkan'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -142,7 +142,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Pengembalian dana'
));
await
tester
.
pump
(
Duration
(
seconds:
1
));
expect
(
find
.
byType
(
AdminInfo
),
findsOneWidget
);
...
...
@@ -156,7 +156,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Batalkan'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -172,7 +172,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Barang diterima'
),
findsOneWidget
);
expect
(
find
.
text
(
'Barang akan dikirim pada hari Sabtu, 18 Oktober 2020'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Barang diterima'
));
...
...
@@ -189,7 +189,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Barang diterima'
),
findsOneWidget
);
expect
(
find
.
text
(
'Barang akan dikirim pada hari Sabtu, 18 Oktober 2020'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Barang diterima'
));
...
...
@@ -206,7 +206,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
visibility
));
await
tester
.
pumpAndSettle
();
...
...
@@ -223,7 +223,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsOneWidget
);
expect
(
find
.
text
(
'Transfer'
),
findsOneWidget
);
expect
(
find
.
byType
(
StepProgressIndicator
),
findsOneWidget
);
...
...
@@ -235,7 +235,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Unggah bukti pembayaran'
),
findsNothing
);
expect
(
find
.
text
(
'Transfer'
),
findsOneWidget
);
expect
(
find
.
byType
(
StepProgressIndicator
),
findsNothing
);
...
...
@@ -274,7 +274,7 @@ void main() {
.
thenAnswer
((
_
)
=>
FetchOrderSuccess
(
Transaction
.
fromJson
(
json
)));
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'GTXWP3PJ'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
155.040'
),
findsOneWidget
);
expect
(
find
.
text
(
'Ubah bukti pembayaran'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Ubah bukti pembayaran'
));
await
tester
.
pumpAndSettle
();
...
...
test/detail_product_test.dart
View file @
7f1b9719
...
...
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:home_industry/Component/price_text_formatter.dart'
;
import
'package:home_industry/Component/router.dart'
;
import
'package:home_industry/Component/router.dart'
as
router
;
import
'package:home_industry/Pages/Cart/bloc/bloc.dart'
;
import
'package:home_industry/Pages/Product/detail_product.dart'
;
import
'package:home_industry/Pages/Product/model/product/product.dart'
;
...
...
@@ -34,12 +34,13 @@ void main() {
subcategory:
'idsub'
,
price:
'10000'
,
description:
'testttt'
,
image:
null
);
image:
null
,
unit:
'Kg'
);
cartBloc
=
CartBlocMock
();
widgetTested
=
BlocProvider
<
CartBloc
>.
value
(
value:
cartBloc
,
child:
MaterialApp
(
onGenerateRoute:
Router
.
generateRoute
,
onGenerateRoute:
router
.
Router
.
generateRoute
,
home:
RepositoryProvider
<
ProductRepository
>.
value
(
value:
prodRep
,
child:
DetailProduct
(
product:
product
))),
);
...
...
@@ -54,9 +55,9 @@ void main() {
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
});
testWidgets
(
'Test detail loaded cart loaded out of stok'
,
...
...
@@ -72,20 +73,21 @@ void main() {
subcategory:
'idsub'
,
price:
'10000'
,
description:
'testttt'
,
image:
null
);
image:
null
,
unit:
'Kg'
);
final
widget
=
BlocProvider
<
CartBloc
>.
value
(
value:
cartBloc
,
child:
MaterialApp
(
onGenerateRoute:
Router
.
generateRoute
,
onGenerateRoute:
router
.
Router
.
generateRoute
,
home:
RepositoryProvider
<
ProductRepository
>.
value
(
value:
prodRep
,
child:
DetailProduct
(
product:
prod
))),
);
await
tester
.
pumpWidget
(
widget
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 0
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'HABIS'
),
findsOneWidget
);
});
...
...
@@ -95,9 +97,9 @@ void main() {
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
Badge
),
findsNothing
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
});
testWidgets
(
'Test detail loaded cart loaded tap'
,
...
...
@@ -106,9 +108,9 @@ void main() {
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
shopping_cart
));
await
tester
.
pump
(
Duration
(
seconds:
3
));
expect
(
find
.
text
(
'Keranjang'
,
skipOffstage:
false
),
findsOneWidget
);
...
...
@@ -120,9 +122,9 @@ void main() {
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
add
));
await
tester
.
pump
();
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
add
));
...
...
@@ -140,9 +142,9 @@ void main() {
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Stok: 10
Kg
'
),
findsOneWidget
);
expect
(
find
.
text
(
'testttt'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp10.000'
),
findsOneWidget
);
expect
(
find
.
text
(
'Rp
10.000
/ Kg
'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
add
));
await
tester
.
pump
();
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
add
));
...
...
@@ -161,9 +163,9 @@ void main() {
await
tester
.
pumpWidget
(
widgetTested
);
expect
(
find
.
text
(
'kue'
),
findsOneWidget
);
expect
(
find
.
byType
(
PriceTextFormatter
),