PLT-2992 Added the ability to use different themes for each team (#3411)

* Cleaned up user_settings_theme.jsx and import_theme_modal.jsx

* Made ImportThemeModal use a callback to return the theme to the user settings modal instead of saving it directly

* Moved user theme from model to preferences

* Added serverside API to delete preferences TODO update package with client stuff

* Changed constants.jsx so that Preferences and ActionTypes can be imported on their own

* Updated ThemeProps migration code to properly rename solarized code themes

* Fixed warnings thrown by AppDispatcher

* Added clientside UI to support team-specific themes

* Removed debugging code from test

* Fixed setting a user's theme when they haven't set their theme before
This commit is contained in:
Harrison Healey
2016-07-14 10:08:36 -04:00
committed by Christopher Speller
parent 8e810bc2eb
commit caabfbcdd5
23 changed files with 671 additions and 273 deletions

View File

@@ -161,3 +161,49 @@ func TestGetPreference(t *testing.T) {
t.Fatal("preference updated incorrectly")
}
}
func TestDeletePreferences(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
user1 := th.BasicUser
var originalCount int
if result, err := Client.GetAllPreferences(); err != nil {
t.Fatal(err)
} else {
originalCount = len(result.Data.(model.Preferences))
}
// save 10 preferences
var preferences model.Preferences
for i := 0; i < 10; i++ {
preference := model.Preference{
UserId: user1.Id,
Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW,
Name: model.NewId(),
}
preferences = append(preferences, preference)
}
if _, err := Client.SetPreferences(&preferences); err != nil {
t.Fatal(err)
}
// delete 10 preferences
th.LoginBasic2()
if _, err := Client.DeletePreferences(&preferences); err == nil {
t.Fatal("shouldn't have been able to delete another user's preferences")
}
th.LoginBasic()
if _, err := Client.DeletePreferences(&preferences); err != nil {
t.Fatal(err)
}
if result, err := Client.GetAllPreferences(); err != nil {
t.Fatal(err)
} else if data := result.Data.(model.Preferences); len(data) != originalCount {
t.Fatal("should've deleted preferences")
}
}