@@ -32,8 +32,28 @@ import (
3232
3333func Test_App_SettingsCommand (t * testing.T ) {
3434 testutil .TableTestCommand (t , testutil.CommandTests {
35- "requires a valid project directory" : {
36- ExpectedError : slackerror .New (slackerror .ErrInvalidAppDirectory ),
35+ "opens app listing page when not in a project directory" : {
36+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
37+ appSelectMock := prompts .NewAppSelectMock ()
38+ appSelectMock .On (
39+ "AppSelectPrompt" ,
40+ mock .Anything ,
41+ mock .Anything ,
42+ prompts .ShowAllEnvironments ,
43+ prompts .ShowInstalledAndUninstalledApps ,
44+ ).Return (
45+ prompts.SelectedApp {},
46+ slackerror .New (slackerror .ErrInstallationRequired ),
47+ )
48+ settingsAppSelectPromptFunc = appSelectMock .AppSelectPrompt
49+ cm .API .On ("Host" ).Return ("https://slack.com" )
50+ },
51+ ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
52+ expectedURL := "https://api.slack.com/apps"
53+ cm .Browser .AssertCalled (t , "OpenURL" , expectedURL )
54+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsStart , mock .Anything )
55+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsSuccess , []string {expectedURL })
56+ },
3757 },
3858 "errors for rosi applications" : {
3959 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
@@ -113,7 +133,40 @@ func Test_App_SettingsCommand(t *testing.T) {
113133 cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsSuccess , []string {expectedURL })
114134 },
115135 },
116- "requires an existing application" : {
136+ "opens app listing page when no apps exist" : {
137+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
138+ cf .SDKConfig .WorkingDirectory = "."
139+ projectConfigMock := config .NewProjectConfigMock ()
140+ projectConfigMock .On (
141+ "GetManifestSource" ,
142+ mock .Anything ,
143+ ).Return (
144+ config .ManifestSourceRemote ,
145+ nil ,
146+ )
147+ cm .Config .ProjectConfig = projectConfigMock
148+ appSelectMock := prompts .NewAppSelectMock ()
149+ appSelectMock .On (
150+ "AppSelectPrompt" ,
151+ mock .Anything ,
152+ mock .Anything ,
153+ prompts .ShowAllEnvironments ,
154+ prompts .ShowInstalledAndUninstalledApps ,
155+ ).Return (
156+ prompts.SelectedApp {},
157+ slackerror .New (slackerror .ErrInstallationRequired ),
158+ )
159+ settingsAppSelectPromptFunc = appSelectMock .AppSelectPrompt
160+ cm .API .On ("Host" ).Return ("https://slack.com" )
161+ },
162+ ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
163+ expectedURL := "https://api.slack.com/apps"
164+ cm .Browser .AssertCalled (t , "OpenURL" , expectedURL )
165+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsStart , mock .Anything )
166+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsSuccess , []string {expectedURL })
167+ },
168+ },
169+ "opens app listing page for development environment when no apps exist" : {
117170 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
118171 cf .SDKConfig .WorkingDirectory = "."
119172 projectConfigMock := config .NewProjectConfigMock ()
@@ -137,8 +190,14 @@ func Test_App_SettingsCommand(t *testing.T) {
137190 slackerror .New (slackerror .ErrInstallationRequired ),
138191 )
139192 settingsAppSelectPromptFunc = appSelectMock .AppSelectPrompt
193+ cm .API .On ("Host" ).Return ("https://dev1234.slack.com" )
194+ },
195+ ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
196+ expectedURL := "https://api.dev1234.slack.com/apps"
197+ cm .Browser .AssertCalled (t , "OpenURL" , expectedURL )
198+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsStart , mock .Anything )
199+ cm .IO .AssertCalled (t , "PrintTrace" , mock .Anything , slacktrace .AppSettingsSuccess , []string {expectedURL })
140200 },
141- ExpectedError : slackerror .New (slackerror .ErrInstallationRequired ),
142201 },
143202 "opens the url to app settings of an app in production" : {
144203 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
0 commit comments