11import 'dart:async' ;
22
33import 'package:checks/checks.dart' ;
4- import 'package:drift/drift.dart' ;
54import 'package:flutter/material.dart' ;
65import 'package:flutter/services.dart' ;
76import 'package:flutter_test/flutter_test.dart' ;
@@ -11,8 +10,8 @@ import 'package:zulip/api/model/web_auth.dart';
1110import 'package:zulip/api/route/account.dart' ;
1211import 'package:zulip/api/route/realm.dart' ;
1312import 'package:zulip/model/binding.dart' ;
14- import 'package:zulip/model/database.dart' ;
1513import 'package:zulip/model/localizations.dart' ;
14+ import 'package:zulip/model/store.dart' ;
1615import 'package:zulip/widgets/app.dart' ;
1716import 'package:zulip/widgets/home.dart' ;
1817import 'package:zulip/widgets/login.dart' ;
@@ -258,11 +257,7 @@ void main() {
258257 await login (tester, eg.selfAccount);
259258 check (testBinding.globalStore.accounts).single
260259 .equals (eg.selfAccount.copyWith (
261- id: testBinding.globalStore.accounts.single.id,
262- // TODO store value from server settings during login flow
263- realmName: Value (null ),
264- // TODO store value from server settings during login flow
265- realmIcon: Value (null )));
260+ id: testBinding.globalStore.accounts.single.id));
266261 });
267262
268263 testWidgets ('logging into a second account' , (tester) async {
@@ -279,12 +274,7 @@ void main() {
279274 await login (tester, eg.otherAccount);
280275 final newAccount = testBinding.globalStore.accounts.singleWhere (
281276 (account) => account != eg.selfAccount);
282- check (newAccount).equals (eg.otherAccount.copyWith (
283- id: newAccount.id,
284- // TODO store value from server settings during login flow
285- realmName: Value (null ),
286- // TODO store value from server settings during login flow
287- realmIcon: Value (null )));
277+ check (newAccount).equals (eg.otherAccount.copyWith (id: newAccount.id));
288278 check (poppedRoutes).length.equals (2 );
289279 check (pushedRoutes).single.isA <WidgetRoute >().page.isA <HomePage >();
290280 });
@@ -309,11 +299,7 @@ void main() {
309299 await tester.idle ();
310300 check (testBinding.globalStore.accounts).single
311301 .equals (eg.selfAccount.copyWith (
312- id: testBinding.globalStore.accounts.single.id,
313- // TODO store value from server settings during login flow
314- realmName: Value (null ),
315- // TODO store value from server settings during login flow
316- realmIcon: Value (null )));
302+ id: testBinding.globalStore.accounts.single.id));
317303 });
318304
319305 testWidgets ('account already exists' , (tester) async {
@@ -340,6 +326,30 @@ void main() {
340326 expectedTitle: zulipLocalizations.errorAccountLoggedInTitle)));
341327 });
342328
329+ testWidgets ('creates account with data from server settings' , (tester) async {
330+ final serverSettings = eg.serverSettings (
331+ realmName: 'Some organization' ,
332+ realmIcon: Uri .parse ('/some-image.png' ),
333+ zulipFeatureLevel: 427 ,
334+ zulipVersion: '12.0-dev-524-ga557b1e721' ,
335+ zulipMergeBase: '12.0-dev-523-g72e3b94855' ,
336+ );
337+ await prepare (tester, serverSettings);
338+ takeStartingRoutes ();
339+ check (pushedRoutes).isEmpty ();
340+ check (testBinding.globalStore.accounts).isEmpty ();
341+
342+ await login (tester, eg.selfAccount);
343+ check (testBinding.globalStore.accounts).single
344+ .equals (eg.selfAccount.copyWith (
345+ id: testBinding.globalStore.accounts.single.id,
346+ realmName: Value ('Some organization' ),
347+ realmIcon: Value (Uri .parse ('/some-image.png' )),
348+ zulipFeatureLevel: 427 ,
349+ zulipVersion: '12.0-dev-524-ga557b1e721' ,
350+ zulipMergeBase: Value ('12.0-dev-523-g72e3b94855' )));
351+ });
352+
343353 // TODO test validators on the TextFormField widgets
344354 // TODO test _getUserId case
345355 // TODO test handling failure in fetchApiKey request
@@ -390,12 +400,7 @@ void main() {
390400 check (testBinding.takeCloseInAppWebViewCallCount ()).equals (1 );
391401
392402 final account = testBinding.globalStore.accounts.single;
393- check (account).equals (eg.selfAccount.copyWith (
394- id: account.id,
395- // TODO store value from server settings during login flow
396- realmName: Value (null ),
397- // TODO store value from server settings during login flow
398- realmIcon: Value (null )));
403+ check (account).equals (eg.selfAccount.copyWith (id: account.id));
399404 check (pushedRoutes).single.isA <MaterialAccountWidgetRoute >()
400405 ..accountId.equals (account.id)
401406 ..page.isA <HomePage >();
0 commit comments