wake-alarm/phone_app/test/google_sign_in_backend_test.dart
Krzysztof kuhy Rudnicki 37a7829757 phone_app: add Google sign-in support for the Firebase sync account
Same pattern as todo, diet_guard_app, and workout_app: openFirebaseWithGoogle()
(google_platform.dart abstracts the plugin's platform-channel dependence),
isFirebaseConfigured() reading the stored session rather than the account
marker alone, and the settings screen offering "Sign in with Google" ahead
of the password form.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdSp6Nbrs9xvsWkCMDN9a1
2026-08-14 11:26:33 +02:00

35 lines
1.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:wake_alarm_sync/services/google_sign_in_backend.dart';
void main() {
group('googleIdToken', () {
test('returns the token the sign-in function yields', () async {
// The injected path: proves the closure is what feeds crdt_sync, and
// that no platform channel is touched to get there.
expect(
await googleIdToken(signInFn: () async => 'a-token'),
'a-token',
);
});
test('passes a null cancellation straight through', () async {
// Dismissing the picker is an ordinary outcome, not an error: the
// caller falls back to the password path.
expect(await googleIdToken(signInFn: () async => null), isNull);
});
test('reports "not configured" when the client id is missing', () async {
// Passed explicitly rather than relying on the const: an app whose
// client id is filled in would otherwise reach the real plugin here.
// The behaviour under test is the empty-id fallback itself.
expect(await googleIdToken(serverClientId: ''), isNull);
});
test('pins the uid the security rules expect', () {
// If this ever drifts from database.rules.json, a Google sign-in would
// be accepted here and then denied every read and write.
expect(kSyncUid, 'OvA2REQyLIhAHOEjzwS1o877rgG3');
});
});
}