wake-alarm/phone_app/test/services/alarm_publisher_test.dart
Krzysztof kuhy Rudnicki 38fb4f3763 Add motion tokens and haptics to the phone app
Motion tokens hand-copied from DOCS-motion.md into theme.dart; every
page route goes through appRoute() (slow, decelerate in, accelerate
out, instant under Remove animations). mediumImpact on the picker
confirm, heavyImpact on a refused time. The Clock app line shows only
when the SET_ALARM handoff finished before its 3 s timeout. Sound is
skipped on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:09:48 +01:00

50 lines
1.7 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:wake_alarm_sync/services/alarm_publisher.dart';
import '../fake_secure_storage.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
setUp(() {
installFakeSecureStorage();
SharedPreferences.setMockInitialValues(<String, Object>{});
});
test('an unconfigured install is told to connect a backend', () async {
final message = await AlarmPublisher().publish(
service: null,
hour: 8,
minute: 0,
);
expect(message, contains('Connect a sync backend'));
});
test('a missing store is not reported as a missing backend', () async {
// The regression this guards. Both causes used to return the same
// "connect a backend" line, so a store that failed to open looked like a
// setup step the user had never done — while Firebase was connected the
// whole time and the real fault was a null service. The advice pointed at
// something that was not broken, and nothing published for weeks.
SharedPreferences.setMockInitialValues(<String, Object>{
'github_token': 'ghp_configured',
});
final message = await AlarmPublisher().publish(
service: null,
hour: 8,
minute: 0,
);
expect(message, isNot(contains('Connect a sync backend')));
expect(message, contains('Sync store unavailable'));
});
test('the Clock line names the time only when the handoff completed', () {
expect(
syncedStatus(6, 5, inClock: true),
'Synced to PC ✓ Clock app set 06:05 ✓',
);
expect(syncedStatus(6, 5, inClock: false), 'Synced to PC ✓');
});
}