@@ -56,7 +56,8 @@ void main() {
56
56
addTearDown (testBinding.reset);
57
57
selfUser ?? = eg.selfUser;
58
58
zulipFeatureLevel ?? = eg.futureZulipFeatureLevel;
59
- final selfAccount = eg.account (user: selfUser, zulipFeatureLevel: zulipFeatureLevel);
59
+ final selfAccount = eg.account (
60
+ id: eg.selfAccount.id, user: selfUser, zulipFeatureLevel: zulipFeatureLevel);
60
61
await testBinding.globalStore.add (selfAccount, eg.initialSnapshot (
61
62
zulipFeatureLevel: zulipFeatureLevel,
62
63
realmMandatoryTopics: mandatoryTopics,
@@ -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,41 @@ 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
+ // new store replaces the old one
1272
+ final newStore = testBinding.globalStore.perAccountSync (eg.selfAccount.id)! ;
1273
+ check (store).not ((it) => it.identicalTo (newStore));
1274
+
1275
+ // new store has the same basic boring data so the compose box
1276
+ // has its content input instead of no-posting-permission error banner
1277
+ // TODO instead, add data by preparing new store's initial snapshot
1278
+ await newStore.addStream (channel);
1279
+ await newStore.addUser (eg.selfUser);
1280
+ await tester.pump ();
1281
+
1282
+ checkContentInputValue (tester, 'some content' );
1283
+ });
1284
+ });
1242
1285
}
0 commit comments