@@ -455,6 +455,7 @@ void main() {
455
455
bool ? sendNotificationToNewThread,
456
456
String ? content,
457
457
int ? streamId,
458
+ String ? prevContentSha256,
458
459
required Map <String , String > expected,
459
460
}) async {
460
461
final result = await updateMessage (connection,
@@ -465,14 +466,43 @@ void main() {
465
466
sendNotificationToNewThread: sendNotificationToNewThread,
466
467
content: content,
467
468
streamId: streamId,
469
+ prevContentSha256: prevContentSha256,
468
470
);
469
471
check (connection.lastRequest).isA< http.Request > ()
470
472
..method.equals ('PATCH' )
471
473
..url.path.equals ('/api/v1/messages/$messageId ' )
472
- ..bodyFields.deepEquals (expected);
474
+ ..bodyFields.deepEquals (expected)
475
+ ..bodyFields.length.equals (expected.length);
473
476
return result;
474
477
}
475
478
479
+ test ('pure content change' , () {
480
+ return FakeApiConnection .with_ ((connection) async {
481
+ connection.prepare (json: UpdateMessageResult ().toJson ());
482
+ await checkUpdateMessage (connection,
483
+ messageId: eg.streamMessage ().id,
484
+ content: 'asdf' ,
485
+ prevContentSha256: '34a780ad578b997db55b260beb60b501f3e04d30ba1a51fcf43cd8dd1241780d' ,
486
+ expected: {
487
+ 'content' : 'asdf' ,
488
+ 'prev_content_sha256' : '34a780ad578b997db55b260beb60b501f3e04d30ba1a51fcf43cd8dd1241780d' ,
489
+ });
490
+ });
491
+ });
492
+
493
+ test ('pure content change (legacy, before prev_content_sha256)' , () {
494
+ return FakeApiConnection .with_ (zulipFeatureLevel: 378 , (connection) async {
495
+ connection.prepare (json: UpdateMessageResult ().toJson ());
496
+ await checkUpdateMessage (connection,
497
+ messageId: eg.streamMessage ().id,
498
+ content: 'asdf' ,
499
+ prevContentSha256: '34a780ad578b997db55b260beb60b501f3e04d30ba1a51fcf43cd8dd1241780d' ,
500
+ expected: {
501
+ 'content' : 'asdf' ,
502
+ });
503
+ });
504
+ });
505
+
476
506
test ('topic/content change' , () {
477
507
// A separate test exercises `streamId`;
478
508
// the API doesn't allow changing channel and content at the same time.
0 commit comments