@@ -28,6 +28,7 @@ import '../api/fake_api.dart';
28
28
import '../example_data.dart' as eg;
29
29
import '../flutter_checks.dart' ;
30
30
import '../model/binding.dart' ;
31
+ import '../model/store_checks.dart' ;
31
32
import '../model/test_store.dart' ;
32
33
import '../model/typing_status_test.dart' ;
33
34
import '../stdlib_checks.dart' ;
@@ -58,14 +59,14 @@ void main() {
58
59
zulipFeatureLevel ?? = eg.futureZulipFeatureLevel;
59
60
final selfAccount = eg.account (user: selfUser, zulipFeatureLevel: zulipFeatureLevel);
60
61
await testBinding.globalStore.add (selfAccount, eg.initialSnapshot (
62
+ realmUsers: [selfUser, ...otherUsers],
63
+ streams: streams,
61
64
zulipFeatureLevel: zulipFeatureLevel,
62
65
realmMandatoryTopics: mandatoryTopics,
63
66
));
64
67
65
68
store = await testBinding.globalStore.perAccount (selfAccount.id);
66
69
67
- await store.addUsers ([selfUser, ...otherUsers]);
68
- await store.addStreams (streams);
69
70
connection = store.connection as FakeApiConnection ;
70
71
71
72
await tester.pumpWidget (TestZulipApp (accountId: selfAccount.id,
@@ -111,6 +112,11 @@ void main() {
111
112
await tester.enterText (contentInputFinder, content);
112
113
}
113
114
115
+ void checkContentInputValue (WidgetTester tester, String expected) {
116
+ check (tester.widget <TextField >(contentInputFinder))
117
+ .controller.isNotNull ().value.text.equals (expected);
118
+ }
119
+
114
120
Future <void > tapSendButton (WidgetTester tester) async {
115
121
connection.prepare (json: SendMessageResult (id: 123 ).toJson ());
116
122
await tester.tap (find.byIcon (ZulipIcons .send));
@@ -1239,4 +1245,39 @@ void main() {
1239
1245
maxHeight: verticalPadding + 170 * 1.5 , maxVisibleLines: 6 );
1240
1246
});
1241
1247
});
1248
+
1249
+ group ('ComposeBoxState new-event-queue transition' , () {
1250
+ testWidgets ('content input not cleared when store changes' , (tester) async {
1251
+ // Regression test for: https://github.com/zulip/zulip-flutter/issues/1470
1252
+
1253
+ TypingNotifier .debugEnable = false ;
1254
+ addTearDown (TypingNotifier .debugReset);
1255
+
1256
+ final channel = eg.stream ();
1257
+ await prepareComposeBox (tester,
1258
+ narrow: eg.topicNarrow (channel.streamId, 'topic' ), streams: [channel]);
1259
+
1260
+ await enterContent (tester, 'some content' );
1261
+ checkContentInputValue (tester, 'some content' );
1262
+
1263
+ store.updateMachine!
1264
+ ..debugPauseLoop ()
1265
+ ..poll ()
1266
+ ..debugPrepareLoopError (
1267
+ eg.apiExceptionBadEventQueueId (queueId: store.queueId))
1268
+ ..debugAdvanceLoop ();
1269
+ await tester.pump ();
1270
+
1271
+ final newStore = testBinding.globalStore.perAccountSync (store.accountId)! ;
1272
+ check (newStore)
1273
+ // a new store has replaced the old one
1274
+ ..not ((it) => it.identicalTo (store))
1275
+ // new store has the same boring data, in order to present a compose box
1276
+ // that allows composing, instead of a no-posting-permission banner
1277
+ ..accountId.equals (store.accountId)
1278
+ ..streams.containsKey (channel.streamId);
1279
+
1280
+ checkContentInputValue (tester, 'some content' );
1281
+ });
1282
+ });
1242
1283
}
0 commit comments