diff --git a/server/channels/api4/insights_test.go b/server/channels/api4/insights_test.go index 9b32844606..bbbd3a1cf7 100644 --- a/server/channels/api4/insights_test.go +++ b/server/channels/api4/insights_test.go @@ -22,6 +22,11 @@ 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)) + th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -259,6 +264,11 @@ 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 userId := th.BasicUser.Id @@ -452,6 +462,11 @@ 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)) + th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client @@ -562,6 +577,11 @@ 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 userId := th.BasicUser.Id @@ -644,6 +664,11 @@ 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.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) + th.LoginBasic() client := th.Client @@ -737,6 +762,11 @@ func TestGetTopThreadsForUserSince(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)) + th.LoginBasic() client := th.Client @@ -867,6 +897,11 @@ func TestGetTopInactiveChannelsForTeamSince(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)) + // delete offtopic, town-square, th.basicchannel channel - which interferes with 'least' active channel results offTopicChannel, appErr := th.App.GetChannelByName(th.Context, "off-topic", th.BasicTeam.Id, false) require.Nil(t, appErr, "Expected nil, didn't receive nil") @@ -994,6 +1029,11 @@ func TestGetTopDMsForUserSince(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)) + th.ConfigStore.SetReadOnlyFF(false) defer th.ConfigStore.SetReadOnlyFF(true) th.App.UpdateConfig(func(c *model.Config) { @@ -1121,6 +1161,10 @@ func TestNewTeamMembersSince(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.LoginBasic() team := th.CreateTeam() diff --git a/server/channels/app/channel_test.go b/server/channels/app/channel_test.go index 19cb1307b5..4968717c4c 100644 --- a/server/channels/app/channel_test.go +++ b/server/channels/app/channel_test.go @@ -2482,6 +2482,10 @@ 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 }) + channel2 := th.CreateChannel(th.Context, th.BasicTeam) // add a bot post to ensure it's not counted @@ -2594,6 +2598,10 @@ 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 }) + channel2 := th.CreateChannel(th.Context, th.BasicTeam) // add a bot post to ensure it's not counted @@ -2672,6 +2680,10 @@ func TestPostCountsByDuration(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 }) + channel2 := th.CreateChannel(th.Context, th.BasicTeam) channel3 := th.CreatePrivateChannel(th.Context, th.BasicTeam) channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam) @@ -2793,6 +2805,10 @@ func TestGetTopInactiveChannelsForTeamSince(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 }) + channel2 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) channel3 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) @@ -2889,6 +2905,10 @@ func TestGetTopInactiveChannelsForUserSince(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 }) + // delete offtopic, town-square, th.basicchannel channels - which interferes with 'least' active channel results offTopicChannel, appErr := th.App.GetChannelByName(th.Context, "off-topic", th.BasicTeam.Id, false) require.Nil(t, appErr, "Expected nil, didn't receive nil") diff --git a/server/channels/app/helper_test.go b/server/channels/app/helper_test.go index 5d05c7e610..d332d6809b 100644 --- a/server/channels/app/helper_test.go +++ b/server/channels/app/helper_test.go @@ -41,6 +41,7 @@ type TestHelper struct { LogBuffer *mlog.Buffer TestLogger *mlog.Logger IncludeCacheLayer bool + ConfigStore *config.Store tempWorkspace string } @@ -96,6 +97,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo LogBuffer: buffer, TestLogger: testLogger, IncludeCacheLayer: includeCacheLayer, + ConfigStore: configStore, } th.Context.SetLogger(testLogger) diff --git a/server/channels/app/plugin_api_test.go b/server/channels/app/plugin_api_test.go index ff417a02b2..841611d1f8 100644 --- a/server/channels/app/plugin_api_test.go +++ b/server/channels/app/plugin_api_test.go @@ -183,7 +183,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\":true}", preferences[0].Value) + assert.Equal(t, "{\"insights_modal_viewed\":false}", preferences[0].Value) assert.Equal(t, user1.Id, preferences[1].UserId) assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[1].Category) @@ -271,7 +271,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\":true}", preferences[0].Value) + assert.Equal(t, "{\"insights_modal_viewed\":false}", preferences[0].Value) assert.Equal(t, user1.Id, preferences[1].UserId) assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[1].Category) diff --git a/server/channels/app/post_test.go b/server/channels/app/post_test.go index 46d08855c0..7389b4ce63 100644 --- a/server/channels/app/post_test.go +++ b/server/channels/app/post_test.go @@ -3033,6 +3033,10 @@ func TestGetTopThreadsForTeamSince(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 }) + // create a public channel, a private channel channelPublic := th.CreateChannel(th.Context, th.BasicTeam) channelPrivate := th.CreatePrivateChannel(th.Context, th.BasicTeam) @@ -3105,6 +3109,10 @@ func TestGetTopThreadsForUserSince(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 }) + // create a public channel, a private channel channelPublic := th.CreateChannel(th.Context, th.BasicTeam) channelPrivate := th.CreatePrivateChannel(th.Context, th.BasicTeam) @@ -3260,6 +3268,8 @@ func TestGetTopDMsForUserSince(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 }) // users diff --git a/server/channels/app/reaction_test.go b/server/channels/app/reaction_test.go index 6add1fc68d..d28d49ebad 100644 --- a/server/channels/app/reaction_test.go +++ b/server/channels/app/reaction_test.go @@ -92,6 +92,7 @@ func TestGetTopReactionsForTeamSince(t *testing.T) { th.Server.platform.SetConfigReadOnlyFF(false) defer th.Server.platform.SetConfigReadOnlyFF(true) + th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) userId := th.BasicUser.Id user2Id := th.BasicUser2.Id @@ -263,6 +264,7 @@ func TestGetTopReactionsForUserSince(t *testing.T) { th.Server.platform.SetConfigReadOnlyFF(false) defer th.Server.platform.SetConfigReadOnlyFF(true) + th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) userId := th.BasicUser.Id diff --git a/server/channels/app/team_test.go b/server/channels/app/team_test.go index 232a28acb4..c5bc805335 100644 --- a/server/channels/app/team_test.go +++ b/server/channels/app/team_test.go @@ -1659,6 +1659,10 @@ func TestGetNewTeamMembersSince(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 }) + team := th.CreateTeam() t.Run("counts team members", func(t *testing.T) { diff --git a/server/channels/app/user_test.go b/server/channels/app/user_test.go index 00ddd43aae..d62cebb4c9 100644 --- a/server/channels/app/user_test.go +++ b/server/channels/app/user_test.go @@ -1808,6 +1808,10 @@ 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.ConfigStore.SetReadOnlyFF(false) + defer th.ConfigStore.SetReadOnlyFF(true) + th.App.UpdateConfig(func(cfg *model.Config) { cfg.FeatureFlags.InsightsEnabled = true }) + testUser := th.CreateUser() defer th.App.PermanentDeleteUser(th.Context, testUser) diff --git a/server/public/model/feature_flags.go b/server/public/model/feature_flags.go index a5959b4ff4..bbf1342879 100644 --- a/server/public/model/feature_flags.go +++ b/server/public/model/feature_flags.go @@ -87,7 +87,7 @@ func (f *FeatureFlags) SetDefaults() { f.BoardsDataRetention = false f.NormalizeLdapDNs = false f.GraphQL = false - f.InsightsEnabled = true + f.InsightsEnabled = false f.CommandPalette = false f.CallsEnabled = true f.SendWelcomePost = true