chore: test mutual state messages on contact remove (#3844)

This commit is contained in:
Mikhail Rogachev 2023-08-03 12:14:13 +04:00 committed by GitHub
parent 60143556ff
commit fbffcdc7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -298,6 +298,16 @@ func (s *MessengerContactRequestSuite) retractContactRequest(contactID string, t
s.Require().Equal(ContactRequestStateNone, resp.Contacts[0].ContactRequestLocalState) s.Require().Equal(ContactRequestStateNone, resp.Contacts[0].ContactRequestLocalState)
s.Require().Equal(ContactRequestStateNone, resp.Contacts[0].ContactRequestRemoteState) s.Require().Equal(ContactRequestStateNone, resp.Contacts[0].ContactRequestRemoteState)
// Check outgoing mutual state message
s.Require().Len(resp.Messages(), 1)
mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED)
s.Require().NotNil(mutualStateUpdate)
myID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
s.Require().Equal(mutualStateUpdate.From, myID)
s.Require().Equal(mutualStateUpdate.ChatId, contactID)
s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(outgoingMutualStateEventRemovedDefaultText, contactID))
// Wait for the message to reach its destination // Wait for the message to reach its destination
resp, err = WaitOnMessengerResponse( resp, err = WaitOnMessengerResponse(
theirMessenger, theirMessenger,
@ -310,7 +320,6 @@ func (s *MessengerContactRequestSuite) retractContactRequest(contactID string, t
s.Require().NotNil(resp) s.Require().NotNil(resp)
s.Require().Len(resp.Contacts, 1) s.Require().Len(resp.Contacts, 1)
myID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
s.Require().Equal(myID, resp.Contacts[0].ID) s.Require().Equal(myID, resp.Contacts[0].ID)
s.Require().False(resp.Contacts[0].added()) s.Require().False(resp.Contacts[0].added())
@ -322,6 +331,15 @@ func (s *MessengerContactRequestSuite) retractContactRequest(contactID string, t
s.Require().Len(resp.ActivityCenterNotifications(), 1) s.Require().Len(resp.ActivityCenterNotifications(), 1)
s.Require().Equal(ActivityCenterNotificationTypeContactRemoved, resp.ActivityCenterNotifications()[0].Type) s.Require().Equal(ActivityCenterNotificationTypeContactRemoved, resp.ActivityCenterNotifications()[0].Type)
s.Require().Equal(resp.ActivityCenterNotifications()[0].Read, false) s.Require().Equal(resp.ActivityCenterNotifications()[0].Read, false)
// Check incoming mutual state message
s.Require().Len(resp.Messages(), 1)
mutualStateUpdate = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED)
s.Require().NotNil(mutualStateUpdate)
s.Require().Equal(mutualStateUpdate.From, myID)
s.Require().Equal(mutualStateUpdate.ChatId, myID)
s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(incomingMutualStateEventRemovedDefaultText, myID))
} }
func (s *MessengerContactRequestSuite) syncInstallationContactV2FromContact(contact *Contact) protobuf.SyncInstallationContactV2 { func (s *MessengerContactRequestSuite) syncInstallationContactV2FromContact(contact *Contact) protobuf.SyncInstallationContactV2 {