mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* lint fix * CI * added new migration mocks * Used setup for tests * some comment * Removed unnecesseery nil check * Form validation * WIP tests * WIP tests * WIP tests * fix: mock content flagging config selector with correct reasons format * fix: add mock for getContentFlaggingConfig in flag post modal test * Updated error code order in API docs * removed empty files * Added tests * lint fixes * minor tweak * lint fix * type fix * fixed test * nit * test enhancements * API WIP * API WIP * creating values * creating content flagging channel and properties * Able to save properties * Added another property field * WIP * WIP * Added validations * Added data validations and hidden post if confifgured to * lint fixes * Added API spec * Added some tests * Added tests for getContentReviewBot * test: add comprehensive tests for getContentReviewChannels function * Added more app layer tests * Added TestCanFlagPost * test: Add comprehensive tests for FlagPost function * Added all app layer tests * Removed a file that was reamoved downstream * test: add content flagging test file * test: add comprehensive tests for FlagContentRequest.IsValid method * Added model tests * test: add comprehensive tests for SqlPropertyValueStore.CreateMany * test: add comprehensive tests for flagPost() API function * Added API tests * linter fix * WIP * sent post flagging confirmation message * fixed i18n nissues * fixed i18n nissues * CI * WIP * WIP * Added API call * test: add test for Client4.flagPost API call in FlagPostModal * fix: remove userEvent.setup() from flag post modal test * test: wrap submit button click in act for proper state updates * Updated tests * lint fix * Updated test * fix: reset contentFlaggingGroupId for test isolation in content flagging tests * removed cached group ID * removed debug log * CI * Updated to allow special characters in comments * Handled empty comment * Created getContentFlaggingFields API * created getPostPropertyValues API * Used finally * WIP * Created useContentFlaggingFields hook * WIP * WIP * Added option to retain data for reviewers * Displayed deleted post's preview * DIsplayed all properties * Adding field name i18n * WIP - managing i18n able texts * Finished displaying all fields * Manual cleanup * lint fixes * team role filter logic fix * Fixed tests * created new API to fetch flagged posts * lint fix * Added new client methods * test: add comprehensive tests for content flagging APIs * Added new API tests * fixed openapi spec * Fixed DataSpillageReport tests * Fixed PostMarkdown test * Fixed PostPreviewPropertyRenderer test * Added metadata to card renderer * test fixes * Added no comment placeholder * Added view detail button * Created RemoveFlaggedMessageConfirmationModal modal * Added key and remove flag request modal * IMplemented delete flagged post * Handled edge cases of deleting flagged post * keep message * UI integration * Added WS event for post report update and handled deleted files of flagged post * Added error handling in keep/remove forms * i18n fixes * Fixed test * Updated OpenAPI specs * fixed types * fixed types * refactoring * refactor: improve test mocking for data spillage report component * test mock updates * Fixed tests * Updated reducer * not resetting mocks * Added migrations for content flagging tables * Created new structure * review fixes * Used correct ot name * WIP * review fixes * review fixes * Added new property translations * CI * CI * CI * Improved test * fixed test * CI * New UI component * WIP * Updated settings APIs * cached DB data * used cached reviewer data * Updated tests * Lint fixes * test: add tests for saveContentFlaggingSettings and getContentFlaggingSettings APIs * test fix * test: add tests for SaveContentFlaggingConfig and GetContentFlaggingConfigReviewerIDs * Updated tests * test: add content flagging test for local cache layer * test: add comprehensive tests for content flagging store cache * Updated tests * lint fix * Updated mobile text * Added content flagging SQL store mocks * Added API specs for new APIs * fixed tests * feat: add TestContentFlaggingStore function for content flagging store testing * feat: add comprehensive tests for content flagging store * Added SQL store tests * test: add content flagging test for local cache layer * test: add tests for content flagging store caching * Added cache layer tests * Updated tests * Fixed * Handled JSON error * fixes * fixes * Fixed retry layer test * fixerdf i18n * Fixed test * CI * building index concurrently * CI * fixed a test * CI * cleanup * Integrate flag post api (#33798) * WIP * WIP * Added API call * test: add test for Client4.flagPost API call in FlagPostModal * fix: remove userEvent.setup() from flag post modal test * test: wrap submit button click in act for proper state updates * Updated tests * lint fix * CI * Updated to allow special characters in comments * Handled empty comment * Used finally * CI * Fixed test * Spillage card integration (#33832) * Created getContentFlaggingFields API * created getPostPropertyValues API * WIP * Created useContentFlaggingFields hook * WIP * WIP * Added option to retain data for reviewers * Displayed deleted post's preview * DIsplayed all properties * Adding field name i18n * WIP - managing i18n able texts * Finished displaying all fields * Manual cleanup * lint fixes * team role filter logic fix * Fixed tests * created new API to fetch flagged posts * lint fix * Added new client methods * test: add comprehensive tests for content flagging APIs * Added new API tests * fixed openapi spec * Fixed DataSpillageReport tests * Fixed PostMarkdown test * Fixed PostPreviewPropertyRenderer test * Added metadata to card renderer * test fixes * Added no comment placeholder * Fixed test * refactor: improve test mocking for data spillage report component * test mock updates * Updated reducer * not resetting mocks * WIP * review fixes * CI * Fixed * fixes * Content flagging actions implementation (#33852) * Added view detail button * Created RemoveFlaggedMessageConfirmationModal modal * Added key and remove flag request modal * IMplemented delete flagged post * Handled edge cases of deleting flagged post * keep message * UI integration * Added WS event for post report update and handled deleted files of flagged post * Added error handling in keep/remove forms * i18n fixes * Updated OpenAPI specs * fixed types * fixed types * refactoring * Fixed tests * review fixes * Added new property translations * Improved test * fixed test * CI * fixes * CI * fixed a test * CI * Review fixes --------- Co-authored-by: Hanzo Dev <[email protected]>
120 lines
5.0 KiB
Go
120 lines
5.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package retrylayer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/lib/pq"
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
|
)
|
|
|
|
func genStore() *mocks.Store {
|
|
mock := &mocks.Store{}
|
|
mock.On("Audit").Return(&mocks.AuditStore{})
|
|
mock.On("Bot").Return(&mocks.BotStore{})
|
|
mock.On("Channel").Return(&mocks.ChannelStore{})
|
|
mock.On("ChannelMemberHistory").Return(&mocks.ChannelMemberHistoryStore{})
|
|
mock.On("ChannelBookmark").Return(&mocks.ChannelBookmarkStore{})
|
|
mock.On("ClusterDiscovery").Return(&mocks.ClusterDiscoveryStore{})
|
|
mock.On("RemoteCluster").Return(&mocks.RemoteClusterStore{})
|
|
mock.On("Command").Return(&mocks.CommandStore{})
|
|
mock.On("CommandWebhook").Return(&mocks.CommandWebhookStore{})
|
|
mock.On("Compliance").Return(&mocks.ComplianceStore{})
|
|
mock.On("Emoji").Return(&mocks.EmojiStore{})
|
|
mock.On("FileInfo").Return(&mocks.FileInfoStore{})
|
|
mock.On("UploadSession").Return(&mocks.UploadSessionStore{})
|
|
mock.On("Group").Return(&mocks.GroupStore{})
|
|
mock.On("Job").Return(&mocks.JobStore{})
|
|
mock.On("License").Return(&mocks.LicenseStore{})
|
|
mock.On("LinkMetadata").Return(&mocks.LinkMetadataStore{})
|
|
mock.On("SharedChannel").Return(&mocks.SharedChannelStore{})
|
|
mock.On("OAuth").Return(&mocks.OAuthStore{})
|
|
mock.On("OutgoingOAuthConnection").Return(&mocks.OutgoingOAuthConnectionStore{})
|
|
mock.On("Plugin").Return(&mocks.PluginStore{})
|
|
mock.On("Post").Return(&mocks.PostStore{})
|
|
mock.On("Thread").Return(&mocks.ThreadStore{})
|
|
mock.On("Preference").Return(&mocks.PreferenceStore{})
|
|
mock.On("ProductNotices").Return(&mocks.ProductNoticesStore{})
|
|
mock.On("Reaction").Return(&mocks.ReactionStore{})
|
|
mock.On("RetentionPolicy").Return(&mocks.RetentionPolicyStore{})
|
|
mock.On("Role").Return(&mocks.RoleStore{})
|
|
mock.On("Scheme").Return(&mocks.SchemeStore{})
|
|
mock.On("Session").Return(&mocks.SessionStore{})
|
|
mock.On("Status").Return(&mocks.StatusStore{})
|
|
mock.On("System").Return(&mocks.SystemStore{})
|
|
mock.On("Team").Return(&mocks.TeamStore{})
|
|
mock.On("TermsOfService").Return(&mocks.TermsOfServiceStore{})
|
|
mock.On("Token").Return(&mocks.TokenStore{})
|
|
mock.On("User").Return(&mocks.UserStore{})
|
|
mock.On("UserAccessToken").Return(&mocks.UserAccessTokenStore{})
|
|
mock.On("UserTermsOfService").Return(&mocks.UserTermsOfServiceStore{})
|
|
mock.On("Webhook").Return(&mocks.WebhookStore{})
|
|
mock.On("NotifyAdmin").Return(&mocks.NotifyAdminStore{})
|
|
mock.On("Draft").Return(&mocks.DraftStore{})
|
|
mock.On("PostPriority").Return(&mocks.PostPriorityStore{})
|
|
mock.On("PostAcknowledgement").Return(&mocks.PostAcknowledgementStore{})
|
|
mock.On("PostPersistentNotification").Return(&mocks.PostPersistentNotificationStore{})
|
|
mock.On("DesktopTokens").Return(&mocks.DesktopTokensStore{})
|
|
mock.On("ChannelBookmark").Return(&mocks.ChannelBookmarkStore{})
|
|
mock.On("ScheduledPost").Return(&mocks.ScheduledPostStore{})
|
|
mock.On("PropertyField").Return(&mocks.PropertyFieldStore{})
|
|
mock.On("PropertyGroup").Return(&mocks.PropertyGroupStore{})
|
|
mock.On("PropertyValue").Return(&mocks.PropertyValueStore{})
|
|
mock.On("AccessControlPolicy").Return(&mocks.AccessControlPolicyStore{})
|
|
mock.On("Attributes").Return(&mocks.AttributesStore{})
|
|
mock.On("ContentFlagging").Return(&mocks.ContentFlaggingStore{})
|
|
return mock
|
|
}
|
|
|
|
func TestRetry(t *testing.T) {
|
|
t.Run("on regular error should not retry", func(t *testing.T) {
|
|
mock := genStore()
|
|
mockBotStore := mock.Bot().(*mocks.BotStore)
|
|
mockBotStore.On("Get", "test", false).Return(nil, errors.New("regular error")).Times(1)
|
|
mock.On("Bot").Return(&mockBotStore)
|
|
layer := New(mock)
|
|
layer.Bot().Get("test", false)
|
|
mockBotStore.AssertExpectations(t)
|
|
})
|
|
t.Run("on success should not retry", func(t *testing.T) {
|
|
mock := genStore()
|
|
mockBotStore := mock.Bot().(*mocks.BotStore)
|
|
mockBotStore.On("Get", "test", false).Return(&model.Bot{}, nil).Times(1)
|
|
mock.On("Bot").Return(&mockBotStore)
|
|
layer := New(mock)
|
|
layer.Bot().Get("test", false)
|
|
mockBotStore.AssertExpectations(t)
|
|
})
|
|
|
|
t.Run("on postgres repeatable error should retry", func(t *testing.T) {
|
|
for _, errCode := range []string{"40001", "40P01"} {
|
|
t.Run("error "+errCode, func(t *testing.T) {
|
|
mock := genStore()
|
|
mockBotStore := mock.Bot().(*mocks.BotStore)
|
|
pqErr := pq.Error{Code: pq.ErrorCode(errCode)}
|
|
mockBotStore.On("Get", "test", false).Return(nil, errors.Wrap(&pqErr, "test-error")).Times(3)
|
|
mock.On("Bot").Return(&mockBotStore)
|
|
layer := New(mock)
|
|
layer.Bot().Get("test", false)
|
|
mockBotStore.AssertExpectations(t)
|
|
})
|
|
}
|
|
})
|
|
|
|
t.Run("on postgres not repeatable error should not retry", func(t *testing.T) {
|
|
mock := genStore()
|
|
mockBotStore := mock.Bot().(*mocks.BotStore)
|
|
pqErr := pq.Error{Code: "20000"}
|
|
mockBotStore.On("Get", "test", false).Return(nil, errors.Wrap(&pqErr, "test-error")).Times(1)
|
|
mock.On("Bot").Return(&mockBotStore)
|
|
layer := New(mock)
|
|
layer.Bot().Get("test", false)
|
|
mockBotStore.AssertExpectations(t)
|
|
})
|
|
}
|