@@ -28,6 +28,8 @@ import (
2828 "github.com/slackapi/slack-cli/internal/slackerror"
2929 "github.com/slackapi/slack-cli/internal/slacktrace"
3030 "github.com/slackapi/slack-cli/internal/style"
31+ "github.com/slackapi/slack-cli/test/testutil"
32+ "github.com/spf13/cobra"
3133 "github.com/stretchr/testify/assert"
3234 "github.com/stretchr/testify/mock"
3335)
@@ -66,7 +68,9 @@ func TestFeedbackCommand(t *testing.T) {
6668
6769 clients := shared .NewClientFactory (clientsMock .MockClientFactory ())
6870
71+ _surveys := SurveyStore
6972 SurveyStore = surveys
73+ defer func () { SurveyStore = _surveys }()
7074
7175 // Execute test
7276 cmd := NewFeedbackCommand (clients )
@@ -134,7 +138,9 @@ func TestFeedbackCommand(t *testing.T) {
134138
135139 clients := shared .NewClientFactory (clientsMock .MockClientFactory ())
136140
141+ _surveys := SurveyStore
137142 SurveyStore = surveys
143+ defer func () { SurveyStore = _surveys }()
138144
139145 // Execute test
140146 cmd := NewFeedbackCommand (clients )
@@ -243,7 +249,9 @@ func TestShowSurveyMessages(t *testing.T) {
243249
244250 clients := shared .NewClientFactory (clientsMock .MockClientFactory ())
245251
252+ _surveys := SurveyStore
246253 SurveyStore = surveys
254+ defer func () { SurveyStore = _surveys }()
247255
248256 // Execute test
249257 err := ShowSurveyMessages (ctx , clients )
@@ -252,3 +260,60 @@ func TestShowSurveyMessages(t *testing.T) {
252260 clientsMock .Browser .AssertCalled (t , "OpenURL" , "https://C.com?project_id=projectID&system_id=systemID&utm_medium=cli&utm_source=cli" )
253261 })
254262}
263+
264+ func Test_Feedback_FeedbackCommand (t * testing.T ) {
265+ testutil .TableTestCommand (t , testutil.CommandTests {
266+ // DEPRECATED(semver:major): Support the deprecated survey name for backwards compatibility
267+ "supports deprecated --name platform-improvements" : {
268+ CmdArgs : []string {"--name" , "platform-improvements" },
269+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
270+ setupFeedbackCommandMocks (t , ctx , cm , cf )
271+ },
272+ ExpectedOutputs : []string {
273+ 274+ "https://docs.slack.dev/developer-support" ,
275+ },
276+ },
277+ "supports --name slack-cli" : {
278+ CmdArgs : []string {"--name" , "slack-cli" },
279+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
280+ setupFeedbackCommandMocks (t , ctx , cm , cf )
281+ },
282+ ExpectedOutputs : []string {
283+ "Ask questions, submit issues, or suggest features for the Slack CLI" ,
284+ "https://github.com/slackapi/slack-cli/issues" ,
285+ },
286+ },
287+ "supports --name slack-platform" : {
288+ CmdArgs : []string {"--name" , "slack-platform" },
289+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
290+ setupFeedbackCommandMocks (t , ctx , cm , cf )
291+ },
292+ ExpectedOutputs : []string {
293+ 294+ "https://docs.slack.dev/developer-support" ,
295+ },
296+ },
297+ }, func (cf * shared.ClientFactory ) * cobra.Command {
298+ cmd := NewFeedbackCommand (cf )
299+ return cmd
300+ })
301+ }
302+
303+ // setupFeedbackCommandMocks prepares common mocks for these tests
304+ func setupFeedbackCommandMocks (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
305+ cm .AddDefaultMocks ()
306+
307+ scm := & config.SystemConfigMock {}
308+ scm .On ("GetSurveyConfig" , mock .Anything , mock .Anything ).Return (config.SurveyConfig {}, nil )
309+ scm .On ("GetSystemID" , mock .Anything ).Return ("systemID" , nil )
310+ scm .On ("SetSurveyConfig" , mock .Anything , mock .Anything , mock .Anything ).Return (nil )
311+ cm .Config .SystemConfig = scm
312+
313+ pcm := & config.ProjectConfigMock {}
314+ pcm .On ("GetSurveyConfig" , mock .Anything , mock .Anything ).Return (config.SurveyConfig {}, nil )
315+ pcm .On ("GetProjectID" , mock .Anything ).Return ("projectID" , nil )
316+ cm .Config .ProjectConfig = pcm
317+
318+ cm .IO .On ("ConfirmPrompt" , mock .Anything , "Open in browser?" , mock .Anything ).Return (false )
319+ }
0 commit comments