-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from wednesday-solutions/patrol
Patrol - E2E testing
- Loading branch information
Showing
21 changed files
with
1,341 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Description | ||
|
||
## Ticket Link - | ||
|
||
## Screenshot / GIF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import com.example.flutter_template.MainActivity; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import pl.leancode.patrol.PatrolJUnitRunner; | ||
|
||
@RunWith(Parameterized.class) | ||
public class MainActivityTest { | ||
@Parameters(name = "{0}") | ||
public static Object[] testCases() { | ||
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); | ||
instrumentation.setUp(MainActivity.class); | ||
instrumentation.waitForPatrolAppService(); | ||
return instrumentation.listDartTests(); | ||
} | ||
|
||
public MainActivityTest(String dartTestName) { | ||
this.dartTestName = dartTestName; | ||
} | ||
|
||
private final String dartTestName; | ||
|
||
@Test | ||
public void runDartTest() { | ||
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); | ||
instrumentation.runDartTest(dartTestName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:flutter_template/app.dart'; | ||
import 'package:flutter_template/flavors/flavor_config.dart'; | ||
import 'package:flutter_template/presentation/intl/translations/translation_loader.dart'; | ||
import 'package:flutter_template/presentation/template_app.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
Future setupApp(PatrolIntegrationTester patrol) async { | ||
await dotenv.load( | ||
fileName: ".env.qa", | ||
); | ||
|
||
FlavorConfig.initialize(flavorString: "qa"); | ||
|
||
await initialiseApp(); | ||
|
||
await patrol.pumpWidgetAndSettle( | ||
EasyLocalization( | ||
supportedLocales: const [Locale("en", "US"), Locale("hi", "IN")], | ||
path: "assets/translations", | ||
fallbackLocale: const Locale("en", "US"), | ||
assetLoader: const CodegenLoader(), | ||
child: TemplateApp(), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
import 'app_setup.dart'; | ||
import 'test_actions.dart'; | ||
|
||
void main() { | ||
patrolTest( | ||
'user can search cities and add or remove them from favorites', | ||
// ignore: deprecated_member_use | ||
nativeAutomation: true, | ||
(patrol) async { | ||
await setupApp(patrol); | ||
|
||
await _navigateSearchForBengaluruAndMarkFavorite(patrol); | ||
await patrol.tap(find.byIcon(Icons.arrow_back)); | ||
expect(find.text("Bengaluru, IN"), findsOneWidget); | ||
await _navigateSearchForBengaluruAndMarkFavorite( | ||
patrol, | ||
alreadySelected: true, | ||
); | ||
await patrol.tap(find.byIcon(Icons.arrow_back)); | ||
expect(find.text("Bengaluru, IN"), findsNothing); | ||
}, | ||
); | ||
} | ||
|
||
Future _navigateSearchForBengaluruAndMarkFavorite( | ||
PatrolIntegrationTester patrol, { | ||
bool alreadySelected = false, | ||
}) async { | ||
await navigateToSearch(patrol); | ||
await patrol.enterText(find.byType(TextField), "Bengaluru", | ||
settlePolicy: SettlePolicy.settle); | ||
if (alreadySelected) { | ||
await patrol.tap( | ||
find.byIcon(Icons.favorite), | ||
settlePolicy: SettlePolicy.settle, | ||
); | ||
} else { | ||
await patrol.tap( | ||
find.byIcon(Icons.favorite_outline), | ||
settlePolicy: SettlePolicy.settle, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_template/presentation/intl/translations/translation_keys.dart'; | ||
import 'package:flutter_template/presentation/intl/translations/translation_loader.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
import 'app_setup.dart'; | ||
import 'test_actions.dart'; | ||
|
||
void main() { | ||
patrolTest( | ||
"users are able to change the language of the app", | ||
// ignore: deprecated_member_use | ||
nativeAutomation: true, | ||
(patrol) async { | ||
await setupApp(patrol); | ||
|
||
expect(find.text(CodegenLoader.en_US[LocaleKeys.homePageTitle]), | ||
findsOneWidget); | ||
|
||
await navigateToSearch(patrol); | ||
expect(find.text(CodegenLoader.en_US[LocaleKeys.searchPageTitle]), | ||
findsOneWidget); | ||
expect(find.text(CodegenLoader.en_US[LocaleKeys.searchResultsAppearHere]), | ||
findsOneWidget); | ||
|
||
await patrol.tap(find.byIcon(Icons.arrow_back)); | ||
|
||
await patrol.tap(find.byIcon(Icons.language)); | ||
|
||
expect(find.text(CodegenLoader.hi_IN[LocaleKeys.homePageTitle]), | ||
findsOneWidget); | ||
|
||
await navigateToSearch(patrol); | ||
expect(find.text(CodegenLoader.hi_IN[LocaleKeys.searchPageTitle]), | ||
findsOneWidget); | ||
expect(find.text(CodegenLoader.hi_IN[LocaleKeys.searchResultsAppearHere]), | ||
findsOneWidget); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
Future navigateToSearch(PatrolIntegrationTester patrol) async { | ||
await patrol.tap(find.byIcon(Icons.search)); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.