mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-11 14:27:45 +01:00
An optional '' default reads as "this parameter is usually irrelevant", and it made `avoid_redundant_argument_values` fire in the first app to pass '' explicitly -- pushing that app toward deleting the argument, which is exactly the line that must stay for when the Desktop client id arrives. Requiring it forces each app to state which halves it configured. Passing '' still means "not configured"; it just has to be said out loud. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
94 lines
2.8 KiB
Dart
94 lines
2.8 KiB
Dart
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
// Under `flutter test` the io platform gate answers for the host, which is
|
|
// Linux -- so the plugin half is false and the loopback half is live. That
|
|
// is the desktop configuration, and it is the one this suite can exercise
|
|
// honestly; the Android half is asserted on the device instead.
|
|
group('desktopSignInSupported', () {
|
|
test('is true on this host once a desktop client id exists', () {
|
|
expect(desktopSignInSupported('desktop-cid'), isTrue);
|
|
});
|
|
|
|
test('is false without a desktop client id', () {
|
|
// The guard against a button that can only ever fail.
|
|
expect(desktopSignInSupported(''), isFalse);
|
|
});
|
|
});
|
|
|
|
group('googleAnySignInSupported', () {
|
|
test('is true when only the desktop half is configured', () {
|
|
expect(
|
|
googleAnySignInSupported(
|
|
serverClientId: '',
|
|
desktopClientId: 'desktop-cid',
|
|
),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('is false when neither half is configured', () {
|
|
expect(
|
|
googleAnySignInSupported(serverClientId: '', desktopClientId: ''),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('is false on this host when only the plugin half is configured', () {
|
|
// The plugin does not run on Linux, so a Web client id alone buys
|
|
// nothing here -- and the button must not appear.
|
|
expect(
|
|
googleAnySignInSupported(
|
|
serverClientId: 'web-cid',
|
|
desktopClientId: '',
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
});
|
|
|
|
group('googleFlowFor', () {
|
|
test('picks the desktop flow on this host', () {
|
|
expect(
|
|
googleFlowFor(serverClientId: '', desktopClientId: 'd'),
|
|
GoogleFlow.desktop,
|
|
);
|
|
});
|
|
|
|
test('picks nothing when neither half is configured', () {
|
|
expect(
|
|
googleFlowFor(serverClientId: '', desktopClientId: ''),
|
|
GoogleFlow.none,
|
|
);
|
|
});
|
|
|
|
test('picks nothing when only the plugin half is configured here', () {
|
|
// The plugin does not run on Linux, so a Web client id alone must not
|
|
// route anywhere -- that would be a button that cannot succeed.
|
|
expect(
|
|
googleFlowFor(serverClientId: 'web-cid', desktopClientId: ''),
|
|
GoogleFlow.none,
|
|
);
|
|
});
|
|
});
|
|
|
|
group('googleAnyIdToken', () {
|
|
test('returns null when no flow is available', () async {
|
|
expect(
|
|
await googleAnyIdToken(serverClientId: '', desktopClientId: ''),
|
|
isNull,
|
|
);
|
|
});
|
|
|
|
test('returns null when the plugin half alone is configured', () async {
|
|
// Would reach the plugin's platform channel if the gate were wrong,
|
|
// which throws rather than returning null.
|
|
expect(
|
|
await googleAnyIdToken(serverClientId: 'web-cid', desktopClientId: ''),
|
|
isNull,
|
|
);
|
|
});
|
|
});
|
|
}
|