@@ -17,6 +17,7 @@ import '../example_data.dart' as eg;
17
17
import '../fake_async.dart' ;
18
18
import '../stdlib_checks.dart' ;
19
19
import 'binding.dart' ;
20
+ import 'store_checks.dart' ;
20
21
import 'test_store.dart' ;
21
22
22
23
void main () {
@@ -187,10 +188,11 @@ void main() {
187
188
late TestGlobalStore globalStore;
188
189
late FakeApiConnection connection;
189
190
190
- Future <void > prepareStore () async {
191
+ Future <void > prepareStore ({ Account ? account} ) async {
191
192
globalStore = TestGlobalStore (accounts: []);
192
- await globalStore.insertAccount (eg.selfAccount.toCompanion (false ));
193
- connection = (globalStore.apiConnectionFromAccount (eg.selfAccount)
193
+ account ?? = eg.selfAccount;
194
+ await globalStore.insertAccount (account.toCompanion (false ));
195
+ connection = (globalStore.apiConnectionFromAccount (account)
194
196
as FakeApiConnection );
195
197
UpdateMachine .debugEnableRegisterNotificationToken = false ;
196
198
addTearDown (() => UpdateMachine .debugEnableRegisterNotificationToken = true );
@@ -220,6 +222,32 @@ void main() {
220
222
users.map ((expected) => (it) => it.fullName.equals (expected.fullName)));
221
223
}));
222
224
225
+ test ('updates account from snapshot' , () => awaitFakeAsync ((async ) async {
226
+ final account = eg.account (user: eg.selfUser,
227
+ zulipVersion: '6.0+gabcd' ,
228
+ zulipMergeBase: '6.0' ,
229
+ zulipFeatureLevel: 123 ,
230
+ );
231
+ await prepareStore (account: account);
232
+ check (globalStore.getAccount (account.id)).isNotNull ()
233
+ ..zulipVersion.equals ('6.0+gabcd' )
234
+ ..zulipMergeBase.equals ('6.0' )
235
+ ..zulipFeatureLevel.equals (123 );
236
+
237
+ connection.prepare (json: eg.initialSnapshot (
238
+ zulipVersion: '8.0+g9876' ,
239
+ zulipMergeBase: '8.0' ,
240
+ zulipFeatureLevel: 234 ,
241
+ ).toJson ());
242
+ final updateMachine = await UpdateMachine .load (globalStore, account.id);
243
+ updateMachine.debugPauseLoop ();
244
+ check (globalStore.getAccount (account.id)).isNotNull ()
245
+ ..identicalTo (updateMachine.store.account)
246
+ ..zulipVersion.equals ('8.0+g9876' )
247
+ ..zulipMergeBase.equals ('8.0' )
248
+ ..zulipFeatureLevel.equals (234 );
249
+ }));
250
+
223
251
test ('retries registerQueue on NetworkError' , () => awaitFakeAsync ((async ) async {
224
252
await prepareStore ();
225
253
0 commit comments