Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/google-test-cleanup-on-failure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Preconditions:
- `up` has built the test app. The build links `@clerk/expo-google-signin` and `@clerk/expo-biometrics` from the workspace. The test app's `app.json` lists the `@clerk/expo-google-signin` config plugin, beside those of `@clerk/expo` and `@clerk/expo-native-components`, and holds three placeholder values under `extra`: a web client ID, an iOS client ID, and the iOS URL scheme that the plugin registers. They belong to no Google project.
- `specs/features/native-modules/biometric-availability.settings.json` turns biometric sign-in on for the instance (`auth_biometric.used_for_sign_in`). The hook reads that as `trusted_device_sign_in_enabled` in the environment's native settings, which the file declares as the expected value. `run` applies it before the test of that spec file. The Google spec file runs on the standard settings, so a run of both has two settings groups.

- **Google sign-in.** Run `integration/expo-native/bin/control-clerk-expo run native-modules/google-sign-in --platform ios`, and again with `--platform android`. The test taps `Native modules` on the home and taps `google-sign-in-button`. On iOS it waits for the system prompt that names `accounts.google.com` and dismisses it with `device.alert('dismiss')`. It then expects `google-result` to say `Google sign-in was cancelled`. On Android it waits for a node whose id begins `com.google.android.gms:id/`, which is a page of Google Play services, and presses back once. When `google-result` appears within 5 seconds, it expects `Google sign-in was cancelled`, as on iOS. When nothing appears, it force-stops Google Play services with `adb shell am force-stop com.google.android.gms` and does not check the result. Either way it then expects no `com.google.android.gms:id/` node on screen. That last check matters: Google Play services keeps its add-account flow running after the app is force-stopped, and its next page would otherwise cover whichever test runs next. Screenshots `google-system-prompt` always, and `google-cancelled` when the app reported the cancel.
- **Google sign-in.** Run `integration/expo-native/bin/control-clerk-expo run native-modules/google-sign-in --platform ios`, and again with `--platform android`. The test taps `Native modules` on the home and taps `google-sign-in-button`. On iOS it waits for the system prompt that names `accounts.google.com` and dismisses it with `device.alert('dismiss')`. It then expects `google-result` to say `Google sign-in was cancelled`. On Android it waits for a node whose id begins `com.google.android.gms:id/`, which is a page of Google Play services, and presses back once. When `google-result` appears within 5 seconds, it expects `Google sign-in was cancelled`, as on iOS. When nothing appears, it force-stops Google Play services with `adb shell am force-stop com.google.android.gms` and does not check the result. Either way it then expects no `com.google.android.gms:id/` node on screen. That last check matters: Google Play services keeps its add-account flow running after the app is force-stopped, and its next page would otherwise cover whichever test runs next. For the same reason, when any step after the tap on `google-sign-in-button` fails on Android, the test force-stops Google Play services before it reports the failure. Screenshots `google-system-prompt` always, and `google-cancelled` when the app reported the cancel.
- **Biometric availability.** Run `run native-modules/biometric-availability` on each platform. The test opens the same screen, taps `biometric-availability-button`, and expects `biometric-availability-result` to say `biometric availability: biometric_authentication_unavailable` on iOS and `biometric availability: no_local_credential` on Android. Screenshot `biometric-availability`.
- **Proof.** Each screenshot shows the result text under its button. Both tests pass on iOS and Android.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,37 @@ test('useSignInWithGoogle opens the native Google sign-in, and cancelling it end
await host.launch();
await host.tap(homeLinks(screen).nativeModules);
await host.tap(screen.getByTestId('google-sign-in-button'));
if (platform === 'android') {
await expect
.poll(() => googlePage.count().catch(() => 0), {
timeout: GOOGLE_UI_TIMEOUT_MS,
message: 'a page of Google Play services is on screen',
})
.toBeGreaterThan(0);
} else {
await expect(screen.getByText(/accounts\.google\.com/)).toBeVisible({ timeout: GOOGLE_UI_TIMEOUT_MS });
}
await host.screenshot('google-system-prompt');
let cancelled = true;
if (platform === 'android') {
await device.back();
cancelled = await googleResult.waitFor({ timeout: BACK_OUT_MS }).then(
() => true,
() => false,
);
try {
if (platform === 'android') {
await expect
.poll(() => googlePage.count().catch(() => 0), {
timeout: GOOGLE_UI_TIMEOUT_MS,
message: 'a page of Google Play services is on screen',
})
.toBeGreaterThan(0);
} else {
await expect(screen.getByText(/accounts\.google\.com/)).toBeVisible({ timeout: GOOGLE_UI_TIMEOUT_MS });
}
await host.screenshot('google-system-prompt');
let cancelled = true;
if (platform === 'android') {
await device.back();
cancelled = await googleResult.waitFor({ timeout: BACK_OUT_MS }).then(
() => true,
() => false,
);
if (!cancelled) await forceStopGooglePlayServices();
await expect(googlePage).toHaveCount(0, { timeout: 15_000 });
} else {
await device.alert('dismiss');
}
if (cancelled) {
await expect(googleResult).toHaveText('Google sign-in was cancelled', { timeout: 15_000 });
await host.screenshot('google-cancelled');
}
} catch (error) {
// Without a Google account, Google Play services can show a page that back does not close, and its add-account flow outlives the app and covers the next test.
if (!cancelled) await forceStopGooglePlayServices();
await expect(googlePage).toHaveCount(0, { timeout: 15_000 });
} else {
await device.alert('dismiss');
}
if (cancelled) {
await expect(googleResult).toHaveText('Google sign-in was cancelled', { timeout: 15_000 });
await host.screenshot('google-cancelled');
if (platform === 'android') await forceStopGooglePlayServices().catch(() => {});
throw error;
}
});
Loading