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>
Этот коммит содержится в:
sazzad hossain
2024-03-14 02:52:15 +06:00
коммит произвёл GitHub
родитель ac3eb04dcc
Коммит 1bd9407e78
2 изменённых файлов: 49 добавлений и 1 удалений

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

@@ -50,7 +50,14 @@ func (ts *TeamService) createDefaultChannels(rctx request.CTX, teamID string) ([
channels := []*model.Channel{}
defaultChannelNames := ts.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}
// 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.

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

@@ -31,6 +31,47 @@ func TestCreateTeam(t *testing.T) {
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) {
th := Setup(t)
defer th.TearDown()