@@ -696,88 +696,6 @@ - (void)testEditServerSideInE2ERoom
696696 }];
697697}
698698
699- // - Send a message in an e2e room
700- // - Edit its local echo
701- // -> We must get notified about the replace event
702- // -> The local echo block must have been called twice
703- - (void )testEditOfEventBeingSentInE2ERoom
704- {
705- // - Send a message in an e2e room
706- [matrixSDKTestsE2EData doE2ETestWithAliceAndBobInARoom: self cryptedBob: YES warnOnUnknowDevices: NO aliceStore: [[MXMemoryStore alloc ] init ] bobStore: [[MXMemoryStore alloc ] init ] readyToTest: ^(MXSession *mxSession, MXSession *bobSession, NSString *roomId, XCTestExpectation *expectation) {
707-
708- MXRoom *room = [mxSession roomWithRoomId: roomId];
709-
710- __block NSString *eventId;
711- __block NSUInteger localEchoBlockCount = 0 ;
712-
713- // - Send a message
714- MXEvent *localEcho;
715- [room sendTextMessage: kOriginalMessageText formattedText: nil threadId: nil localEcho: &localEcho success: ^(NSString *theEventId) {
716- eventId = theEventId;
717- } failure: ^(NSError *error) {
718- XCTFail (@" Cannot set up intial test conditions - error: %@ " , error);
719- [expectation fulfill ];
720- }];
721-
722- // - Edit its local echo
723- [mxSession.aggregations replaceTextMessageEvent: localEcho withTextMessage: kEditedMessageText formattedText: nil localEchoBlock: ^(MXEvent * _Nonnull localEcho) {
724-
725- localEchoBlockCount++;
726-
727- XCTAssertEqual (localEcho.eventType , MXEventTypeRoomMessage);
728-
729- XCTAssertNotNil (localEcho.relatesTo );
730- XCTAssertEqualObjects (localEcho.relatesTo .relationType , MXEventRelationTypeReplace);
731-
732- XCTAssertEqualObjects (localEcho.content [kMXMessageContentKeyNewContent ][kMXMessageTypeKey ], kMXMessageTypeText );
733- XCTAssertEqualObjects (localEcho.content [kMXMessageContentKeyNewContent ][kMXMessageBodyKey ], kEditedMessageText );
734-
735- switch (localEchoBlockCount) {
736- case 1 :
737- // The first local echo must point to a local echo
738- XCTAssertEqual (localEcho.sentState , MXEventSentStateEncrypting);
739- XCTAssertTrue ([localEcho.relatesTo.eventId hasPrefix: kMXEventLocalEventIdPrefix ]);
740- break ;
741- case 2 :
742- // The second local echo must point to the final event id
743- XCTAssertEqual (localEcho.sentState , MXEventSentStateEncrypting);
744- XCTAssertFalse ([localEcho.relatesTo.eventId hasPrefix: kMXEventLocalEventIdPrefix ]);
745- break ;
746-
747- default :
748- break ;
749- }
750-
751- } success: ^(NSString * _Nonnull eventId) {
752- XCTAssertNotNil (eventId);
753- } failure: ^(NSError *error) {
754- XCTFail (@" The operation should not fail - NSError: %@ " , error);
755- [expectation fulfill ];
756- }];
757-
758- // -> We must get notified about the replace event
759- [mxSession.aggregations listenToEditsUpdateInRoom: room.roomId block: ^(MXEvent * _Nonnull replaceEvent) {
760-
761- XCTAssertNotNil (eventId, @" The original event must have been sent before receiving the final edit" );
762-
763- MXEvent *editedEvent = [mxSession.store eventWithEventId: eventId inRoom: room.roomId];
764-
765- XCTAssertNotNil (editedEvent);
766- XCTAssertTrue (editedEvent.contentHasBeenEdited );
767- XCTAssertEqualObjects (editedEvent.unsignedData .relations .replace .eventId , replaceEvent.eventId );
768- XCTAssertEqualObjects (editedEvent.content [kMXMessageBodyKey ], kEditedMessageText );
769-
770- XCTAssertEqualObjects (replaceEvent.relatesTo .eventId , eventId);
771-
772- // -> The local echo block must have been called twice
773- XCTAssertEqual (localEchoBlockCount, 2 );
774-
775- [expectation fulfill ];
776- }];
777- }];
778- }
779-
780-
781699#pragma mark - Edits history
782700
783701// Edit a message a number of times
0 commit comments