github.com/adacta-ru/mattermost-server/v6@v6.0.0/app/slashcommands/command_invite_people_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package slashcommands
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  
    11  	"github.com/adacta-ru/mattermost-server/v6/model"
    12  )
    13  
    14  func TestInvitePeopleProvider(t *testing.T) {
    15  	th := setup(t).initBasic()
    16  	defer th.tearDown()
    17  
    18  	th.App.UpdateConfig(func(cfg *model.Config) {
    19  		*cfg.EmailSettings.SendEmailNotifications = true
    20  		*cfg.ServiceSettings.EnableEmailInvitations = true
    21  	})
    22  
    23  	cmd := InvitePeopleProvider{}
    24  
    25  	notTeamUser := th.createUser()
    26  
    27  	// Test without required permissions
    28  	args := &model.CommandArgs{
    29  		T:         func(s string, args ...interface{}) string { return s },
    30  		ChannelId: th.BasicChannel.Id,
    31  		TeamId:    th.BasicTeam.Id,
    32  		UserId:    notTeamUser.Id,
    33  	}
    34  
    35  	actual := cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
    36  	assert.Equal(t, "api.command_invite_people.permission.app_error", actual.Text)
    37  
    38  	// Test with required permissions.
    39  	args.UserId = th.BasicUser.Id
    40  	actual = cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
    41  	assert.Equal(t, "api.command.invite_people.sent", actual.Text)
    42  }