[MM-43785] Hide insights feature intro for new users (#20214)

* tools updates

* Revert "tools updates"

This reverts commit 6293297b55803c5a263e200ebd80192899666ae9.

* hide insights modal by default for new users

* updating feature flag for test

* updating preference tests

* fixing lint

* fixing comment

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ben Cooke
2022-06-08 14:56:34 -04:00
коммит произвёл GitHub
родитель 719e4504b8
Коммит 2c63e8dd08
5 изменённых файлов: 93 добавлений и 34 удалений

Просмотреть файл

@@ -1729,36 +1729,72 @@ 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)
preferences, appErr := th.App.GetPreferencesForUser(testUser.Id)
require.Nil(t, appErr)
tutorialStepPref := preferences[1]
recommendedNextStepsPref := preferences[0]
tutorialStepPref := preferences[2]
recommendedNextStepsPref := preferences[1]
insightsPref := preferences[0]
assert.Equal(t, tutorialStepPref.Name, testUser.Id)
assert.Equal(t, recommendedNextStepsPref.Category, model.PreferenceRecommendedNextSteps)
assert.Equal(t, recommendedNextStepsPref.Name, "hide")
assert.Equal(t, recommendedNextStepsPref.Value, "false")
assert.Equal(t, insightsPref.Name, "insights_tutorial_state")
assert.Equal(t, insightsPref.Value, "{\"insights_modal_viewed\":true}")
})
t.Run("successfully create a user with insights feature flag disabled", 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 = false })
testUser := th.CreateUser()
defer th.App.PermanentDeleteUser(th.Context, testUser)
preferences, appErr := th.App.GetPreferencesForUser(testUser.Id)
require.Nil(t, appErr)
tutorialStepPref := preferences[2]
recommendedNextStepsPref := preferences[1]
insightsPref := preferences[0]
assert.Equal(t, tutorialStepPref.Name, testUser.Id)
assert.Equal(t, recommendedNextStepsPref.Category, model.PreferenceRecommendedNextSteps)
assert.Equal(t, recommendedNextStepsPref.Name, "hide")
assert.Equal(t, recommendedNextStepsPref.Value, "false")
assert.Equal(t, insightsPref.Name, "insights_tutorial_state")
assert.Equal(t, insightsPref.Value, "{\"insights_modal_viewed\":false}")
})
t.Run("successfully create a guest 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.CreateGuest()
defer th.App.PermanentDeleteUser(th.Context, testUser)
preferences, appErr := th.App.GetPreferencesForUser(testUser.Id)
require.Nil(t, appErr)
assert.Equal(t, testUser.Id, preferences[0].UserId)
assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[0].Category)
assert.Equal(t, "hide", preferences[0].Name)
assert.Equal(t, "false", preferences[0].Value)
assert.Equal(t, testUser.Id, preferences[1].UserId)
assert.Equal(t, model.PreferenceCategoryTutorialSteps, preferences[1].Category)
assert.Equal(t, testUser.Id, preferences[1].Name)
assert.Equal(t, "0", preferences[1].Value)
assert.Equal(t, model.PreferenceRecommendedNextSteps, preferences[1].Category)
assert.Equal(t, "hide", preferences[1].Name)
assert.Equal(t, "false", preferences[1].Value)
assert.Equal(t, testUser.Id, preferences[2].UserId)
assert.Equal(t, model.PreferenceCategoryTutorialSteps, preferences[2].Category)
assert.Equal(t, testUser.Id, preferences[2].Name)
assert.Equal(t, "0", preferences[2].Value)
assert.Equal(t, testUser.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)
})
}