mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-26 21:57:12 +01:00
phone: pin the clock in the stageLocalSettings enforcement test
The test staged a 2026-10-01 event through stageLocalSettings, which called stageEnforcementData on the real clock; on 2026-10-16 the event aged past boundEvents' 14-day window and the test went red for everyone. stageLocalSettings now forwards an optional `now` to stageEnforcementData (callers unchanged), and the test passes its fixed clock. phone_app suite: 402 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry
This commit is contained in:
parent
7e40bb138c
commit
2e594f041d
@ -53,7 +53,10 @@ String stampOf(Hlc hlc) => DateTime.fromMillisecondsSinceEpoch(
|
|||||||
/// unless it holds a value from before stamps existed, which goes in at
|
/// unless it holds a value from before stamps existed, which goes in at
|
||||||
/// [_legacyMs] so it is kept when nothing else is known and loses to any
|
/// [_legacyMs] so it is kept when nothing else is known and loses to any
|
||||||
/// stamped peer.
|
/// stamped peer.
|
||||||
Future<void> stageLocalSettings(AlarmSyncService service) async {
|
Future<void> stageLocalSettings(
|
||||||
|
AlarmSyncService service, {
|
||||||
|
DateTime Function()? now,
|
||||||
|
}) async {
|
||||||
final tags = await RoomProofSettings.load();
|
final tags = await RoomProofSettings.load();
|
||||||
await stageField(
|
await stageField(
|
||||||
service,
|
service,
|
||||||
@ -72,7 +75,7 @@ Future<void> stageLocalSettings(AlarmSyncService service) async {
|
|||||||
);
|
);
|
||||||
await _stageEarned(service);
|
await _stageEarned(service);
|
||||||
await stageSessionData(service);
|
await stageSessionData(service);
|
||||||
await stageEnforcementData(service);
|
await stageEnforcementData(service, now: now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pushes the union of the local and logged earned dates when it is new.
|
/// Pushes the union of the local and logged earned dates when it is new.
|
||||||
|
|||||||
@ -73,7 +73,9 @@ void main() {
|
|||||||
..events.add(_event(DateTime(2026, 10, 1, 7, 15), 'lockdown_sent'));
|
..events.add(_event(DateTime(2026, 10, 1, 7, 15), 'lockdown_sent'));
|
||||||
final service = await _open();
|
final service = await _open();
|
||||||
|
|
||||||
await stageLocalSettings(service);
|
// The clock is pinned: on the real one the 2026-10-01 event aged past
|
||||||
|
// boundEvents' 14-day window on 2026-10-16 and the test went red.
|
||||||
|
await stageLocalSettings(service, now: () => now);
|
||||||
|
|
||||||
expect(service.field(ringStartedField)?.$1, ring);
|
expect(service.field(ringStartedField)?.$1, ring);
|
||||||
final escapes = service.field(escapesField)!;
|
final escapes = service.field(escapesField)!;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user