mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 12:27:42 +01:00
Some checks failed
One-tap sign-in for a fresh install, matching the pattern already shipped in todo and crdt_sync_dart: openFirebaseWithGoogle() (google_platform.dart abstracts the plugin's platform-channel dependence), isFirebaseConfigured() that reads the stored session rather than trusting the account marker alone (a marker with no live session is what made a synced phone read as "not connected" for a full session), and storedAccount() for read-back without the desktop-wrapper fallback that throws on Android. Also generalizes crdt_sync_dart's ref pin to v0.10.0 and vendors the override-guard script for the pre-commit hook already wired to it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KdSp6Nbrs9xvsWkCMDN9a1
34 lines
1.3 KiB
Dart
34 lines
1.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:diet_guard_app/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 {
|
|
// A build without --dart-define=GOOGLE_SERVER_CLIENT_ID must fall back
|
|
// rather than failing deep inside the plugin with an opaque message.
|
|
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');
|
|
});
|
|
});
|
|
}
|