Skip to content

Commit 78a0ebe

Browse files
Merge pull request #53 from hoangnguyen92dn/release/0.2.0
Release - 0.2.0
2 parents 8218551 + f407dcf commit 78a0ebe

File tree

77 files changed

+2183
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2183
-180
lines changed

.github/workflows/android_deploy_production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
env:
3535
ENV_STAGING: ${{ secrets.ENV }}
3636
run: |
37-
echo $ENV > .env
37+
echo "$ENV" > .env
3838
3939
# App Bundle requires Firebase connected to Play Store to upload https://appdistribution.page.link/KPoa
4040
- name: Build Android apk

.github/workflows/android_deploy_staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
env:
3535
ENV_STAGING: ${{ secrets.ENV_STAGING }}
3636
run: |
37-
echo $ENV_STAGING > .env.staging
37+
echo "$ENV_STAGING" > .env.staging
3838
3939
# App Bundle requires Firebase connected to Play Store to upload https://appdistribution.page.link/KPoa
4040
- name: Build Android apk

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Clone the repository
5151

5252
- For example:
5353

54-
`$ fvm flutter drive --driver=test_driver/integration_test.dart --target=integration_test/my_home_page_test.dart --flavor staging`
54+
`$ fvm flutter drive --driver=test_driver/integration_test.dart --target=integration_test/home_screen_test.dart --flavor staging`
5555

5656
- Code coverage integration:
5757

assets/fonts/neuzeit_bold.otf

27.7 KB
Binary file not shown.
File renamed without changes.
2.98 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import 'package:dio/dio.dart';
2+
import 'package:equatable/equatable.dart';
3+
4+
import '../utils/file_util.dart';
5+
6+
class FakeResponseModel extends Equatable {
7+
final int statusCode;
8+
final Map<String, dynamic> json;
9+
10+
const FakeResponseModel(
11+
this.statusCode,
12+
this.json,
13+
);
14+
15+
@override
16+
List<Object?> get props => [
17+
statusCode,
18+
json,
19+
];
20+
}
21+
22+
const String keySignIn = 'signIn';
23+
const String keyUserProfile = 'userProfile';
24+
25+
class FakeData {
26+
FakeData._();
27+
28+
static final Map<String, FakeResponseModel> _apiAndResponse = {};
29+
30+
static Map<String, FakeResponseModel> get apiAndResponse => _apiAndResponse;
31+
32+
static Future<void> initDefault() async {
33+
_apiAndResponse.addAll({
34+
keySignIn: FakeResponseModel(
35+
200,
36+
await FileUtil.loadFile(
37+
'integration_test/fake_data/fake_sign_in_response.json'),
38+
),
39+
keyUserProfile: FakeResponseModel(
40+
200,
41+
await FileUtil.loadFile(
42+
'integration_test/fake_data/fake_user_profile_response.json'),
43+
),
44+
});
45+
}
46+
47+
static void updateResponse(String key, FakeResponseModel newValue) {
48+
_apiAndResponse.update(
49+
key,
50+
(value) => newValue,
51+
ifAbsent: () => newValue,
52+
);
53+
}
54+
}
55+
56+
DioError generateDioError(int statusCode) {
57+
return DioError(
58+
response: Response(
59+
statusCode: statusCode,
60+
requestOptions: RequestOptions(path: ''),
61+
),
62+
type: DioErrorType.badResponse,
63+
requestOptions: RequestOptions(path: ''),
64+
);
65+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:retrofit/retrofit.dart';
3+
import 'package:survey_flutter_ic/api/request/sign_in_request.dart';
4+
import 'package:survey_flutter_ic/api/response/auth_response.dart';
5+
import 'package:survey_flutter_ic/api/service/auth_service.dart';
6+
7+
import '../fake_data.dart';
8+
9+
class FakeAuthService extends Fake implements AuthService {
10+
@override
11+
Future<AuthResponse> signIn(
12+
@Body() SignInRequest body,
13+
) async {
14+
await Future.delayed(const Duration(seconds: 5));
15+
final response = FakeData.apiAndResponse[keySignIn]!;
16+
if (response.statusCode != 200) {
17+
throw generateDioError(response.statusCode);
18+
}
19+
return AuthResponse.fromJson(response.json);
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:survey_flutter_ic/api/response/profile_response.dart';
3+
import 'package:survey_flutter_ic/api/service/user_service.dart';
4+
5+
import '../fake_data.dart';
6+
7+
class FakeUserService extends Fake implements UserService {
8+
@override
9+
Future<ProfileResponse> getProfile() async {
10+
await Future.delayed(const Duration(seconds: 5));
11+
final response = FakeData.apiAndResponse[keyUserProfile]!;
12+
if (response.statusCode != 200) {
13+
throw generateDioError(response.statusCode);
14+
}
15+
return ProfileResponse.fromJson(response.json);
16+
}
17+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:integration_test/integration_test.dart';
3+
import 'package:survey_flutter_ic/ui/home/home_screen.dart';
4+
import 'package:survey_flutter_ic/ui/home/home_widget_id.dart';
5+
6+
import 'utils/test_util.dart';
7+
8+
void main() {
9+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
homeScreenTest();
11+
}
12+
13+
void homeScreenTest() {
14+
group('Home Page', () {
15+
late Finder profileAvatar;
16+
17+
setUpAll(() async {
18+
await TestUtil.setupTestEnvironment();
19+
});
20+
21+
setUp(() {
22+
profileAvatar = find.byKey(HomeWidgetId.profileAvatarImage);
23+
});
24+
25+
testWidgets(
26+
"When the home screen shown, it displays the Home screen correctly",
27+
(WidgetTester tester) async {
28+
await tester
29+
.pumpWidget(TestUtil.pumpWidgetWithShellApp(const HomeScreen()));
30+
await tester.pumpAndSettle();
31+
32+
expect(profileAvatar, findsOneWidget);
33+
});
34+
});
35+
}

0 commit comments

Comments
 (0)