MM-53703 Add display-name for experimental default channel (#26191)
* [MM-53703] add displayname for experimental default channel (#24644) * [MM-53703] add unit test for default experimental channel (#24644) * Update server/channels/app/teams/teams_test.go --------- Co-authored-by: Sazzad Hossain <sazzad.hossain@marginedge.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ac3eb04dcc
Коммит
1bd9407e78
@@ -50,7 +50,14 @@ func (ts *TeamService) createDefaultChannels(rctx request.CTX, teamID string) ([
|
|||||||
channels := []*model.Channel{}
|
channels := []*model.Channel{}
|
||||||
defaultChannelNames := ts.DefaultChannelNames()
|
defaultChannelNames := ts.DefaultChannelNames()
|
||||||
for _, name := range defaultChannelNames {
|
for _, name := range defaultChannelNames {
|
||||||
displayName := i18n.TDefault(displayNames[name], name)
|
var displayName string
|
||||||
|
if displayNameValue, ok := displayNames[name]; ok {
|
||||||
|
displayName = i18n.TDefault(displayNameValue, name)
|
||||||
|
} else {
|
||||||
|
// If the default channel is experimental (from config.json)
|
||||||
|
// we don't have to translate
|
||||||
|
displayName = name
|
||||||
|
}
|
||||||
channel := &model.Channel{DisplayName: displayName, Name: name, Type: model.ChannelTypeOpen, TeamId: teamID}
|
channel := &model.Channel{DisplayName: displayName, Name: name, Type: model.ChannelTypeOpen, TeamId: teamID}
|
||||||
// We should use the channel service here (coming soon). Ideally, we should just emit an event
|
// We should use the channel service here (coming soon). Ideally, we should just emit an event
|
||||||
// and let the subscribers do the job, in this case it would be the channels service.
|
// and let the subscribers do the job, in this case it would be the channels service.
|
||||||
|
|||||||
@@ -31,6 +31,47 @@ func TestCreateTeam(t *testing.T) {
|
|||||||
require.Error(t, err, "Should not create a new team - team already exist")
|
require.Error(t, err, "Should not create a new team - team already exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateTeamWithExperimentalDefaultChannels(t *testing.T) {
|
||||||
|
th := Setup(t)
|
||||||
|
th.UpdateConfig(func(cfg *model.Config) {
|
||||||
|
cfg.TeamSettings.ExperimentalDefaultChannels = []string{"channel-1", "channel-2"}
|
||||||
|
})
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
id := model.NewId()
|
||||||
|
team := &model.Team{
|
||||||
|
DisplayName: "dn_" + id,
|
||||||
|
Name: "name" + id,
|
||||||
|
Email: "success+" + id + "@simulator.amazonses.com",
|
||||||
|
Type: model.TeamOpen,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := th.service.CreateTeam(th.Context, team)
|
||||||
|
require.NoError(t, err, "Should create a new team")
|
||||||
|
|
||||||
|
createdTeam, err := th.service.GetTeam(team.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, createdTeam.Name, "name"+id)
|
||||||
|
|
||||||
|
channels, err := th.service.channelStore.GetAll(team.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, channels, 3)
|
||||||
|
|
||||||
|
ch, err := th.service.channelStore.GetByName(team.Id, "town-square", false)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, ch)
|
||||||
|
|
||||||
|
ch, err = th.service.channelStore.GetByName(team.Id, "channel-1", false)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, ch)
|
||||||
|
require.Equal(t, ch.DisplayName, "channel-1")
|
||||||
|
|
||||||
|
ch, err = th.service.channelStore.GetByName(team.Id, "channel-2", false)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, ch)
|
||||||
|
require.Equal(t, ch.DisplayName, "channel-2")
|
||||||
|
}
|
||||||
|
|
||||||
func TestJoinUserToTeam(t *testing.T) {
|
func TestJoinUserToTeam(t *testing.T) {
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user