Skip to content

Commit

Permalink
Add test cases for quickstart, custom endpoint, and token
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Feb 9, 2024
1 parent 752c829 commit c7ca898
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ void main() {
String? password = const String.fromEnvironment("PASSWORD");
String? name = const String.fromEnvironment("NAME");

String token = "";

testWidgets('Run app and login', (tester) async {
await prep(tester, username, password, name, true);
await prep(tester, username, password, name, true, "https://ep2.vypal.me",
false, "");
SharedPreferences prefs = await SharedPreferences.getInstance();
token = prefs.getString("token") ?? "";
expect(find.text(name), findsWidgets);
expect(find.text("Username"), findsNothing);
});

testWidgets('Test TimeTable page', (tester) async {
await prep(tester, username, password, name, false);
await prep(tester, username, password, name, false, "", false, token);

await tester.pump(const Duration(seconds: 1));

Expand All @@ -43,7 +49,7 @@ void main() {
});

testWidgets('Test TimeTable page scroll', (tester) async {
await prep(tester, username, password, name, false);
await prep(tester, username, password, name, false, "", true, token);

await tester.tap(find.byType(NavigationDestination).at(1));
await tester.pump(const Duration(seconds: 1));
Expand All @@ -68,9 +74,21 @@ void main() {
});
}

Future<void> prep(WidgetTester tester, String username, String password,
String name, bool enableiCanteen) async {
SharedPreferences.setMockInitialValues({"ice": enableiCanteen});
Future<void> prep(
WidgetTester tester,
String username,
String password,
String name,
bool enableiCanteen,
String customEndPoint,
bool quickstart,
String token) async {
SharedPreferences.setMockInitialValues({
"ice": enableiCanteen,
"customEndpoint": customEndPoint,
"quickstart": quickstart,
"token": token
});
final FlutterExceptionHandler? originalOnError = FlutterError.onError;
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
Expand Down

0 comments on commit c7ca898

Please sign in to comment.