From 517faccc332ce48de43e597d1b2d29a3961241e7 Mon Sep 17 00:00:00 2001 From: FurmanovD <39990503+FurmanovD@users.noreply.github.com> Date: Mon, 17 Sep 2018 13:46:06 +0300 Subject: 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 --- app/import_validators_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/import_validators_test.go') diff --git a/app/import_validators_test.go b/app/import_validators_test.go index 5fb0518f7..617b5cd96 100644 --- a/app/import_validators_test.go +++ b/app/import_validators_test.go @@ -692,6 +692,25 @@ func TestImportValidateUserTeamsImportData(t *testing.T) { if err := validateUserTeamsImportData(&data); err != nil { t.Fatal("Should have succeeded with valid roles.") } + + // Valid (with JSON string of theme) + data[0].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"}`) + if err := validateUserTeamsImportData(&data); err != nil { + t.Fatal("Should have succeeded with valid theme.") + } + + // Invalid (invalid JSON string of theme) + data[0].Theme = ptrStr(`This is the invalid string which cannot be marshalled to JSON object :) + {"#DBBD4E","buttonBg", "#23A1FF", buttonColor`) + if err := validateUserTeamsImportData(&data); err == nil { + t.Fatal("Should have fail with invalid JSON string of theme.") + } + + // Invalid (valid JSON but invalid theme description) + data[0].Theme = ptrStr(`{"somekey": 25, "json_obj1": {"color": "#DBBD4E","buttonBg": "#23A1FF"}}`) + if err := validateUserTeamsImportData(&data); err == nil { + t.Fatal("Should have fail with valid JSON which contains invalid string of theme description.") + } + data[0].Theme = nil } func TestImportValidateUserChannelsImportData(t *testing.T) { -- cgit v1.2.3-1-g7c22