chore: test suite `activity_center_persistence_test`

This commit is contained in:
Igor Sirotin 2023-10-06 12:48:30 +01:00 committed by Igor Sirotin
parent da3df63eb1
commit d878884eb5
2 changed files with 404 additions and 395 deletions

File diff suppressed because it is too large Load Diff

View File

@ -329,3 +329,95 @@ func (s *MessengerActivityCenterMessageSuite) TestReplyWithImage() {
s.Require().NotNil(notifResponse.Notifications[0].Message)
s.Require().NotEmpty(notifResponse.Notifications[0].Message.ImageLocalURL)
}
func (s *MessengerActivityCenterMessageSuite) TestMuteCommunityActivityCenterNotifications() {
description := &requests.CreateCommunity{
Membership: protobuf.CommunityPermissions_NO_MEMBERSHIP,
Name: "status",
Color: "#ffffff",
Description: "status community description",
}
alice := s.m
bob := s.newMessenger()
_, err := bob.Start()
s.Require().NoError(err)
// Create an community chat
response, err := bob.CreateCommunity(description, true)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
community := response.Communities()[0]
s.Require().NotNil(community)
chat := CreateOneToOneChat(common.PubkeyToHex(&alice.identity.PublicKey), &alice.identity.PublicKey, bob.transport)
// bob sends a community message
inputMessage := common.NewMessage()
inputMessage.ChatId = chat.ID
inputMessage.Text = "some text"
inputMessage.CommunityID = community.IDString()
err = bob.SaveChat(chat)
s.Require().NoError(err)
_, err = bob.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err)
_, err = WaitOnMessengerResponse(
alice,
func(r *MessengerResponse) bool { return len(r.Communities()) == 1 },
"no messages",
)
s.Require().NoError(err)
// Alice joins the community
response, err = alice.JoinCommunity(context.Background(), community.ID(), true)
s.Require().NoError(err)
s.Require().NotNil(response)
s.Require().Len(response.Communities(), 1)
s.Require().True(response.Communities()[0].Joined())
s.Require().Len(response.Chats(), 1)
defaultCommunityChatID := response.Chats()[0].ID
// Bob mutes the community
time, err := bob.MuteAllCommunityChats(&requests.MuteCommunity{
CommunityID: community.ID(),
MutedType: MuteTillUnmuted,
})
s.Require().NoError(err)
s.Require().NotNil(time)
bobCommunity, err := bob.GetCommunityByID(community.ID())
s.Require().NoError(err)
s.Require().True(bobCommunity.Muted())
// alice sends a community message
inputMessage = common.NewMessage()
inputMessage.ChatId = defaultCommunityChatID
inputMessage.Text = "Good news, @" + common.EveryoneMentionTag + " !"
inputMessage.CommunityID = community.IDString()
response, err = alice.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err)
s.Require().Len(response.Messages(), 1)
s.Require().True(response.Messages()[0].Mentioned)
response, err = WaitOnMessengerResponse(
bob,
func(r *MessengerResponse) bool { return len(r.Messages()) == 1 },
"no messages",
)
s.Require().NoError(err)
s.Require().Len(response.Messages(), 1)
s.Require().True(response.Messages()[0].Mentioned)
s.Require().Len(response.ActivityCenterNotifications(), 0)
}