diff --git a/api4/insights_test.go b/api4/insights_test.go index 9c090c1a37..06395382f7 100644 --- a/api4/insights_test.go +++ b/api4/insights_test.go @@ -19,9 +19,6 @@ func TestGetTopReactionsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -245,9 +242,6 @@ func TestGetTopReactionsForUserSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -437,9 +431,6 @@ func TestGetTopChannelsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -536,9 +527,6 @@ func TestGetTopChannelsForUserSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -617,10 +605,6 @@ func TestGetTopThreadsForTeamSince(t *testing.T) { defer th.TearDown() th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - th.LoginBasic() client := th.Client @@ -707,10 +691,6 @@ func TestGetTopThreadsForUserSince(t *testing.T) { defer th.TearDown() th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) - th.ConfigStore.SetReadOnlyFF(false) - defer th.ConfigStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - th.LoginBasic() client := th.Client diff --git a/app/channel_test.go b/app/channel_test.go index 13f5e27cd5..1561d5143c 100644 --- a/app/channel_test.go +++ b/app/channel_test.go @@ -2381,10 +2381,6 @@ func TestGetTopChannelsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - channel2 := th.CreateChannel(th.BasicTeam) channel3 := th.CreatePrivateChannel(th.BasicTeam) channel4 := th.CreatePrivateChannel(th.BasicTeam) @@ -2439,10 +2435,6 @@ func TestGetTopChannelsForUserSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - channel2 := th.CreateChannel(th.BasicTeam) channel3 := th.CreatePrivateChannel(th.BasicTeam) channel4 := th.CreatePrivateChannel(th.BasicTeam) @@ -2497,10 +2489,6 @@ func TestPostCountsByDuration(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - channel2 := th.CreateChannel(th.BasicTeam) channel3 := th.CreatePrivateChannel(th.BasicTeam) channel4 := th.CreatePrivateChannel(th.BasicTeam) diff --git a/app/plugin_api_test.go b/app/plugin_api_test.go index cfed84128b..00b61d1976 100644 --- a/app/plugin_api_test.go +++ b/app/plugin_api_test.go @@ -182,7 +182,7 @@ func TestPluginAPIGetUserPreferences(t *testing.T) { assert.Equal(t, user1.Id, preferences[0].UserId) assert.Equal(t, model.PreferenceCategoryInsights, preferences[0].Category) assert.Equal(t, model.PreferenceNameInsights, preferences[0].Name) - assert.Equal(t, "{\"insights_modal_viewed\":false}", preferences[0].Value) + assert.Equal(t, "{\"insights_modal_viewed\":true}", preferences[0].Value) assert.Equal(t, user1.Id, preferences[1].UserId) assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[1].Category) @@ -269,7 +269,7 @@ func TestPluginAPIUpdateUserPreferences(t *testing.T) { assert.Equal(t, user1.Id, preferences[0].UserId) assert.Equal(t, model.PreferenceCategoryInsights, preferences[0].Category) assert.Equal(t, model.PreferenceNameInsights, preferences[0].Name) - assert.Equal(t, "{\"insights_modal_viewed\":false}", preferences[0].Value) + assert.Equal(t, "{\"insights_modal_viewed\":true}", preferences[0].Value) assert.Equal(t, user1.Id, preferences[1].UserId) assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[1].Category) diff --git a/app/post_test.go b/app/post_test.go index 4cc4d44bfe..86032957a6 100644 --- a/app/post_test.go +++ b/app/post_test.go @@ -2822,10 +2822,6 @@ func TestGetTopThreadsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - // create a public channel, a private channel channelPublic := th.CreateChannel(th.BasicTeam) channelPrivate := th.CreatePrivateChannel(th.BasicTeam) @@ -2898,10 +2894,6 @@ func TestGetTopThreadsForUserSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) - // create a public channel, a private channel channelPublic := th.CreateChannel(th.BasicTeam) channelPrivate := th.CreatePrivateChannel(th.BasicTeam) diff --git a/app/reaction_test.go b/app/reaction_test.go index 1b13f97f3c..3a3908731f 100644 --- a/app/reaction_test.go +++ b/app/reaction_test.go @@ -92,7 +92,6 @@ func TestGetTopReactionsForTeamSince(t *testing.T) { th.Server.configStore.SetReadOnlyFF(false) defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) userId := th.BasicUser.Id user2Id := th.BasicUser2.Id @@ -252,6 +251,7 @@ func TestGetTopReactionsForTeamSince(t *testing.T) { t.Run("get-top-reactions-for-team-since feature flag", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = false }) + defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) _, err := th.App.GetTopReactionsForTeamSince(userId, teamId, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 5}) assert.NotNil(t, err) }) @@ -263,7 +263,6 @@ func TestGetTopReactionsForUserSince(t *testing.T) { th.Server.configStore.SetReadOnlyFF(false) defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) userId := th.BasicUser.Id @@ -423,6 +422,7 @@ func TestGetTopReactionsForUserSince(t *testing.T) { t.Run("get-top-reactions-for-user-since feature flag", func(t *testing.T) { th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = false }) + defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) _, err := th.App.GetTopReactionsForUserSince(userId, teamId, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 5}) assert.NotNil(t, err) }) diff --git a/app/user_test.go b/app/user_test.go index d81db13edc..63491c3f53 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -254,16 +254,16 @@ func TestCreateUser(t *testing.T) { []string{ ` package main - + import ( "github.com/mattermost/mattermost-server/v6/plugin" "github.com/mattermost/mattermost-server/v6/model" ) - + type MyPlugin struct { plugin.MattermostPlugin } - + func (p *MyPlugin) UserHasBeenCreated(c *plugin.Context, user *model.User) { user.Nickname = "sanitized" if len(user.Password) > 0 { @@ -271,7 +271,7 @@ func TestCreateUser(t *testing.T) { } p.API.UpdateUser(user) } - + func main() { plugin.ClientMain(&MyPlugin{}) } @@ -1729,9 +1729,6 @@ func TestCreateUserWithInitialPreferences(t *testing.T) { defer th.TearDown() t.Run("successfully create a user with initial tutorial and recommended steps preferences", func(t *testing.T) { - th.Server.configStore.SetReadOnlyFF(false) - defer th.Server.configStore.SetReadOnlyFF(true) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) testUser := th.CreateUser() defer th.App.PermanentDeleteUser(th.Context, testUser) @@ -1755,6 +1752,7 @@ func TestCreateUserWithInitialPreferences(t *testing.T) { th.Server.configStore.SetReadOnlyFF(false) defer th.Server.configStore.SetReadOnlyFF(true) th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = false }) + defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) testUser := th.CreateUser() defer th.App.PermanentDeleteUser(th.Context, testUser) diff --git a/model/feature_flags.go b/model/feature_flags.go index 13a56bf000..b5b48a77f9 100644 --- a/model/feature_flags.go +++ b/model/feature_flags.go @@ -92,7 +92,7 @@ func (f *FeatureFlags) SetDefaults() { f.EnableInactivityCheckJob = true f.UseCaseOnboarding = true f.GraphQL = false - f.InsightsEnabled = false + f.InsightsEnabled = true f.CommandPalette = false f.AdvancedTextEditor = true f.CallsEnabled = true