Skip to content

Commit 9087fed

Browse files
authored
test: pin patrol version to 3.14.1 to fix hanging tests (#343)
* ci: pin patrol version to 3.14.1 to fix hanging tests * ci: fix hanging issue on location permission acceptance.
1 parent 76685a7 commit 9087fed

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

.github/workflows/test-and-build.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ jobs:
225225
labels: ubuntu-latest
226226
env:
227227
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
228+
PATROL_ANALYTICS_ENABLED: false
228229
patrol_cli_version: "3.5.0"
229230
working_directory: "example"
230231
steps:
@@ -294,7 +295,8 @@ jobs:
294295
run: flutter build apk --config-only
295296
- name: Run integration tests
296297
working-directory: ${{ env.working_directory }}
297-
run: patrol test --verbose
298+
run: |
299+
patrol test ${{ runner.debug && '--show-flutter-logs --verbose' || '' }}
298300
- name: Upload test report
299301
uses: actions/upload-artifact@v4
300302
if: ${{ always() }}
@@ -312,6 +314,7 @@ jobs:
312314
labels: macos-latest-xlarge
313315
env:
314316
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
317+
PATROL_ANALYTICS_ENABLED: false
315318
patrol_cli_version: "3.5.0"
316319
working_directory: "example"
317320
steps:
@@ -378,7 +381,7 @@ jobs:
378381
id: tests_step
379382
working-directory: ${{ env.working_directory }}
380383
run: |
381-
patrol test --dart-define=MAPS_API_KEY="$MAPS_API_KEY" --verbose -d "$DEVICE_ID"
384+
patrol test --dart-define=MAPS_API_KEY="$MAPS_API_KEY" ${{ runner.debug && '--show-flutter-logs --verbose' || '' }} -d "$DEVICE_ID"
382385
- name: Upload test report
383386
uses: actions/upload-artifact@v4
384387
if: ${{ always() }}

example/integration_test/shared.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ Future<void> checkLocationDialogAcceptance(PatrolIntegrationTester $) async {
163163
final Future<PermissionStatus> locationGranted =
164164
Permission.locationWhenInUse.request();
165165

166-
// Grant location permission.
167-
await $.native.grantPermissionWhenInUse();
166+
if (await $.native
167+
.isPermissionDialogVisible(timeout: const Duration(seconds: 5))) {
168+
// Grant location permission.
169+
await $.native.grantPermissionWhenInUse();
170+
}
168171

169172
// Check that the location permission is granted.
170173
await locationGranted.then((PermissionStatus status) async {

example/integration_test/t01_initialization_test.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ import 'package:flutter/material.dart';
2828
import 'shared.dart';
2929

3030
void main() {
31-
patrol('C01 - Test session initialization errors',
31+
// Patrol runs the tests in alphabetical order, add a prefix to the test
32+
// name to control the order with script:
33+
int testCounter = 0;
34+
String prefix(String name) {
35+
testCounter++;
36+
return 'IT${testCounter.toString().padLeft(2, '0')} $name';
37+
}
38+
39+
patrol(prefix('Test session initialization errors'),
3240
(PatrolIntegrationTester $) async {
3341
await GoogleMapsNavigator.resetTermsAccepted();
3442
expect(await GoogleMapsNavigator.areTermsAccepted(), false);
@@ -174,7 +182,7 @@ void main() {
174182
}
175183
});
176184

177-
patrol('C02 - Test Maps initialization', (PatrolIntegrationTester $) async {
185+
patrol(prefix('Test Maps initialization'), (PatrolIntegrationTester $) async {
178186
final Completer<GoogleNavigationViewController> viewControllerCompleter =
179187
Completer<GoogleNavigationViewController>();
180188

@@ -266,7 +274,7 @@ void main() {
266274
expect(await controller.isNavigationUIEnabled(), true);
267275
});
268276

269-
patrol('C03 - Test Maps initialization without navigation',
277+
patrol(prefix('Test Maps initialization without navigation'),
270278
(PatrolIntegrationTester $) async {
271279
final Completer<GoogleMapViewController> viewControllerCompleter =
272280
Completer<GoogleMapViewController>();

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dev_dependencies:
3636
integration_test:
3737
sdk: flutter
3838
meta: any
39-
patrol: ^3.14.0
39+
patrol: 3.14.1 # Patrol 3.15.1 has hang issues on Android. Pinging to 3.14.1 for now.
4040
pub_semver: ^2.1.4
4141
test_api: any
4242

melos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ scripts:
5151
format:
5252
run: |
5353
melos run format:dart && \
54-
melos run format:ios && \
54+
melos run format:ios && \
5555
melos run format:android
5656
description: |
5757
Formats the code of all packages (Dart, iOS, Android).

0 commit comments

Comments
 (0)