MM-11424 Extend bulk import to support themes across teams(#9305) (#9419)

* MM-11424 Extend bulk import to support themes across teams(#9305)

Also added:
Advanced Settings:
+'feature_enabled_markdown_preview'
+'formatting'
Sidebar Settings:
+'show_unread_section'

* MM-11424 (PR review) user teams' theme validator test updated

* MM-11424 (PR review) added test with valid JSON of invalid theme(by structure)

JSON string contains numeric and JSON object fields, not just a correct "string":"string" map
Этот коммит содержится в:
FurmanovD
2018-09-17 13:46:06 +03:00
коммит произвёл George Goldberg
родитель 35c148d255
Коммит 517faccc33
7 изменённых файлов: 113 добавлений и 14 удалений

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

@@ -1016,6 +1016,7 @@ func TestImportImportUser(t *testing.T) {
data.Teams = &[]UserTeamImportData{
{
Name: &teamName,
Theme: ptrStr(`{"awayIndicator":"#DBBD4E","buttonBg":"#23A1FF","buttonColor":"#FFFFFF","centerChannelBg":"#ffffff","centerChannelColor":"#333333","codeTheme":"github","image":"/static/files/a4a388b38b32678e83823ef1b3e17766.png","linkColor":"#2389d7","mentionBg":"#2389d7","mentionColor":"#ffffff","mentionHighlightBg":"#fff2bb","mentionHighlightLink":"#2f81b7","newMessageSeparator":"#FF8800","onlineIndicator":"#7DBE00","sidebarBg":"#fafafa","sidebarHeaderBg":"#3481B9","sidebarHeaderTextColor":"#ffffff","sidebarText":"#333333","sidebarTextActiveBorder":"#378FD2","sidebarTextActiveColor":"#111111","sidebarTextHoverBg":"#e6f2fa","sidebarUnreadText":"#333333","type":"Mattermost"}`),
Roles: ptrStr("team_user team_admin"),
Channels: &[]UserChannelImportData{
{
@@ -1049,6 +1050,7 @@ func TestImportImportUser(t *testing.T) {
}
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_FAVORITE_CHANNEL, channel.Id, "true")
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_THEME, team.Id, *(*data.Teams)[0].Theme)
// No more new member objects.
if tmc, err := th.App.GetTeamMembers(team.Id, 0, 1000); err != nil {
@@ -1074,6 +1076,9 @@ func TestImportImportUser(t *testing.T) {
MessageDisplay: ptrStr("compact"),
ChannelDisplayMode: ptrStr("centered"),
TutorialStep: ptrStr("3"),
UseMarkdownPreview: ptrStr("true"),
UseFormatting: ptrStr("true"),
ShowUnreadSection: ptrStr("true"),
}
if err := th.App.ImportUser(&data, false); err != nil {
t.Fatalf("Should have succeeded.")
@@ -1091,6 +1096,9 @@ func TestImportImportUser(t *testing.T) {
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "message_display", *data.MessageDisplay)
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "channel_display_mode", *data.ChannelDisplayMode)
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_TUTORIAL_STEPS, user.Id, *data.TutorialStep)
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, "feature_enabled_markdown_preview", *data.UseMarkdownPreview)
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS, "formatting", *data.UseFormatting)
checkPreference(t, th.App, user.Id, model.PREFERENCE_CATEGORY_SIDEBAR_SETTINGS, "show_unread_section", *data.ShowUnreadSection)
// Change those preferences.
data = UserImportData{