fix: improve transfer recognition and local data safety

This commit is contained in:
2026-07-26 21:36:46 +08:00
parent 7df25edd96
commit 882293343e
21 changed files with 505 additions and 128 deletions
@@ -82,4 +82,29 @@ void main() {
throwsStateError,
);
});
test('云端回写失败时保留待同步的本地账单', () {
final database = LocalDatabase.inMemoryForTesting();
addTearDown(database.close);
final local = database.createTransaction({
'ledgerId': 1,
'categoryId': 1,
'type': 'expense',
'amount': 28,
'occurredAt': '2026-07-25T03:00:00.000Z',
'source': 'manual',
});
final localId = local['id'] as int;
expect(
() => database.replaceLocalTransaction(localId, {
...local,
'id': 42,
'occurredAt': 'invalid-time',
}),
throwsFormatException,
);
expect(database.transaction(localId), isNotNull);
expect(database.transaction(42), isNull);
});
}