@@ -325,10 +325,35 @@ void main() {
325
325
]);
326
326
});
327
327
328
+ // Technically the topic *was* unresolved, so MessageEditState.none
329
+ // would be valid and preferable -- if it didn't need more intense
330
+ // computation than we're comfortable with in a hot codepath, i.e.,
331
+ // a regex test instead of a simple `startsWith` / `substring` check.
332
+ // See comment on the implementation, and discussion:
333
+ // https://github.com/zulip/zulip-flutter/pull/1242#discussion_r1917592157
328
334
test ('Unresolving topic with a weird prefix -> moved' , () {
329
335
checkEditState (MessageEditState .moved,
330
336
[{'prev_topic' : '✔ ✔old_topic' , 'topic' : 'old_topic' }]);
331
337
});
338
+
339
+ // Similar reasoning as in the previous test.
340
+ // Also, Zulip doesn't produce topics with a weird resolved-topic prefix,
341
+ // so this case can only be produced by unusual input in an
342
+ // edit/move-topic UI. A "moved" marker seems like a fine response
343
+ // in that circumstance.
344
+ test ('Resolving topic with a weird prefix -> moved' , () {
345
+ checkEditState (MessageEditState .moved,
346
+ [{'prev_topic' : 'old_topic' , 'topic' : '✔ ✔old_topic' }]);
347
+ });
348
+
349
+ // Similar reasoning as the previous test, including that this case had to
350
+ // involve unusual input in an edit/move-topic UI.
351
+ // Here the computation burden would have come from calling
352
+ // [TopicName.canonicalize].
353
+ test ('Topic was resolved but with changed case -> moved' , () {
354
+ checkEditState (MessageEditState .moved,
355
+ [{'prev_topic' : 'old ToPiC' , 'topic' : '✔ OLD tOpIc' }]);
356
+ });
332
357
});
333
358
});
334
359
}
0 commit comments