@@ -70,12 +70,12 @@ void main() {
7070 return const SizedBox .shrink ();
7171 })));
7272 // First, shows a loading page instead of child.
73- check (tester. any ( find.byType (CircularProgressIndicator ))). isTrue ();
73+ check (find.byType (CircularProgressIndicator )). findsOne ();
7474 check (globalStore).isNull ();
7575
7676 await tester.pump ();
7777 // Then after loading, mounts child instead, with provided store.
78- check (tester. any ( find.byType (CircularProgressIndicator ))). isFalse ();
78+ check (find.byType (CircularProgressIndicator )). findsNothing ();
7979 check (globalStore).identicalTo (testBinding.globalStore);
8080
8181 await testBinding.globalStore.add (eg.selfAccount, eg.initialSnapshot ());
@@ -84,6 +84,56 @@ void main() {
8484 .equals ((accountId: eg.selfAccount.id, account: eg.selfAccount));
8585 });
8686
87+ testWidgets ('GlobalStoreWidget awaits blockingFuture' , (tester) async {
88+ addTearDown (testBinding.reset);
89+
90+ final completer = Completer <void >();
91+ await tester.pumpWidget (Directionality (textDirection: TextDirection .ltr,
92+ child: GlobalStoreWidget (
93+ blockingFuture: completer.future,
94+ child: Text ('done' ))));
95+
96+ await tester.pump ();
97+ await tester.pump ();
98+ await tester.pump ();
99+ // Even after the store must have loaded,
100+ // still shows loading page while blockingFuture is pending.
101+ check (find.byType (CircularProgressIndicator )).findsOne ();
102+ check (find.text ('done' )).findsNothing ();
103+
104+ // Once blockingFuture completes…
105+ completer.complete ();
106+ await tester.pump ();
107+ // … mounts child instead of the loading page.
108+ check (find.byType (CircularProgressIndicator )).findsNothing ();
109+ check (find.text ('done' )).findsOne ();
110+ });
111+
112+ testWidgets ('GlobalStoreWidget handles failed blockingFuture like success' , (tester) async {
113+ addTearDown (testBinding.reset);
114+
115+ final completer = Completer <void >();
116+ await tester.pumpWidget (Directionality (textDirection: TextDirection .ltr,
117+ child: GlobalStoreWidget (
118+ blockingFuture: completer.future,
119+ child: Text ('done' ))));
120+
121+ await tester.pump ();
122+ await tester.pump ();
123+ await tester.pump ();
124+ // Even after the store must have loaded,
125+ // still shows loading page while blockingFuture is pending.
126+ check (find.byType (CircularProgressIndicator )).findsOne ();
127+ check (find.text ('done' )).findsNothing ();
128+
129+ // Once blockingFuture completes, even with an error…
130+ completer.completeError (Exception ('oops' ));
131+ await tester.pump ();
132+ // … mounts child instead of the loading page.
133+ check (find.byType (CircularProgressIndicator )).findsNothing ();
134+ check (find.text ('done' )).findsOne ();
135+ });
136+
87137 testWidgets ('GlobalStoreWidget.of updates dependents' , (tester) async {
88138 addTearDown (testBinding.reset);
89139
0 commit comments