-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add support for 'feedback --name slack-platform' #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c0d8957
a5348db
e802c13
3afcc5a
82a2d12
50b499a
4e705c1
99a19e9
f373184
b635bca
602085f
ef08e3c
3e6abf4
8bb4c1e
c745bda
d3ea0a8
06e247e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,9 @@ const ( | |
|
|
||
| // Supported survey names | ||
| const ( | ||
| SlackCLIFeedback = "slack-cli" | ||
| SlackPlatformFeedback = "platform-improvements" | ||
| SlackCLIFeedback = "slack-cli" | ||
| SlackPlatformFeedback = "slack-platform" | ||
| SlackPlatformFeedbackDeprecated = "platform-improvements" // DEPRECATED(semver:major) | ||
| ) | ||
|
|
||
| type SurveyConfigInterface interface { | ||
|
|
@@ -92,7 +93,7 @@ var SurveyStore = map[string]SlackSurvey{ | |
| Info: func(ctx context.Context, clients *shared.ClientFactory) { | ||
| clients.IO.PrintInfo(ctx, false, fmt.Sprintf( | ||
| "%s\n%s\n", | ||
| style.Secondary("Ask questions, submit issues, or suggest features for the SLack CLI:"), | ||
| style.Secondary("Ask questions, submit issues, or suggest features for the Slack CLI:"), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: Writing tests found a typo!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mwbrooks Whew great catch! It's nice to know this wasn't released, but darn that's an |
||
| style.Secondary(style.Highlight("https://github.com/slackapi/slack-cli/issues")), | ||
| )) | ||
| }, | ||
|
|
@@ -242,6 +243,12 @@ func runFeedbackCommand(ctx context.Context, clients *shared.ClientFactory, cmd | |
| return nil | ||
| } | ||
|
|
||
| // DEPRECATED(semver:major): Support the deprecated survey name for backwards compatibility | ||
| if surveyNameFlag == SlackPlatformFeedbackDeprecated { | ||
| surveyNameFlag = SlackPlatformFeedback | ||
| clients.IO.PrintWarning(ctx, "DEPRECATED: The '--name %s' flag is deprecated; use '--name %s' instead", SlackPlatformFeedbackDeprecated, SlackPlatformFeedback) | ||
| } | ||
|
|
||
| surveyNames, surveyPromptOptions := initSurveyOpts(ctx, clients, SurveyStore) | ||
|
|
||
| if _, ok := SurveyStore[surveyNameFlag]; !ok && surveyNameFlag != "" { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ import ( | |
| "github.com/slackapi/slack-cli/internal/slackerror" | ||
| "github.com/slackapi/slack-cli/internal/slacktrace" | ||
| "github.com/slackapi/slack-cli/internal/style" | ||
| "github.com/slackapi/slack-cli/test/testutil" | ||
| "github.com/spf13/cobra" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/mock" | ||
| ) | ||
|
|
@@ -66,7 +68,9 @@ func TestFeedbackCommand(t *testing.T) { | |
|
|
||
| clients := shared.NewClientFactory(clientsMock.MockClientFactory()) | ||
|
|
||
| _surveys := SurveyStore | ||
| SurveyStore = surveys | ||
| defer func() { SurveyStore = _surveys }() | ||
|
Comment on lines
+71
to
+73
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: After adding some Command Table Tests, I noticed that the tests started failing when ran together. The reason is that the current tests clobber the global 🧪 In a follow-up PR, I'd like to refactor these tests to all use the Command Table Test. |
||
|
|
||
| // Execute test | ||
| cmd := NewFeedbackCommand(clients) | ||
|
|
@@ -134,7 +138,9 @@ func TestFeedbackCommand(t *testing.T) { | |
|
|
||
| clients := shared.NewClientFactory(clientsMock.MockClientFactory()) | ||
|
|
||
| _surveys := SurveyStore | ||
| SurveyStore = surveys | ||
| defer func() { SurveyStore = _surveys }() | ||
|
|
||
| // Execute test | ||
| cmd := NewFeedbackCommand(clients) | ||
|
|
@@ -243,7 +249,9 @@ func TestShowSurveyMessages(t *testing.T) { | |
|
|
||
| clients := shared.NewClientFactory(clientsMock.MockClientFactory()) | ||
|
|
||
| _surveys := SurveyStore | ||
| SurveyStore = surveys | ||
| defer func() { SurveyStore = _surveys }() | ||
|
|
||
| // Execute test | ||
| err := ShowSurveyMessages(ctx, clients) | ||
|
|
@@ -252,3 +260,60 @@ func TestShowSurveyMessages(t *testing.T) { | |
| clientsMock.Browser.AssertCalled(t, "OpenURL", "https://C.com?project_id=projectID&system_id=systemID&utm_medium=cli&utm_source=cli") | ||
| }) | ||
| } | ||
|
|
||
| func Test_Feedback_FeedbackCommand(t *testing.T) { | ||
| testutil.TableTestCommand(t, testutil.CommandTests{ | ||
| // DEPRECATED(semver:major): Support the deprecated survey name for backwards compatibility | ||
| "supports deprecated --name platform-improvements": { | ||
| CmdArgs: []string{"--name", "platform-improvements"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| setupFeedbackCommandMocks(t, ctx, cm, cf) | ||
| }, | ||
| ExpectedOutputs: []string{ | ||
| "[email protected]", | ||
| "https://docs.slack.dev/developer-support", | ||
| }, | ||
| }, | ||
| "supports --name slack-cli": { | ||
| CmdArgs: []string{"--name", "slack-cli"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| setupFeedbackCommandMocks(t, ctx, cm, cf) | ||
| }, | ||
| ExpectedOutputs: []string{ | ||
| "Ask questions, submit issues, or suggest features for the Slack CLI", | ||
| "https://github.com/slackapi/slack-cli/issues", | ||
| }, | ||
| }, | ||
| "supports --name slack-platform": { | ||
| CmdArgs: []string{"--name", "slack-platform"}, | ||
| Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| setupFeedbackCommandMocks(t, ctx, cm, cf) | ||
| }, | ||
| ExpectedOutputs: []string{ | ||
| "[email protected]", | ||
| "https://docs.slack.dev/developer-support", | ||
| }, | ||
| }, | ||
|
Comment on lines
+287
to
+296
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💌 👏 |
||
| }, func(cf *shared.ClientFactory) *cobra.Command { | ||
| cmd := NewFeedbackCommand(cf) | ||
| return cmd | ||
| }) | ||
| } | ||
|
|
||
| // setupFeedbackCommandMocks prepares common mocks for these tests | ||
| func setupFeedbackCommandMocks(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { | ||
| cm.AddDefaultMocks() | ||
|
|
||
| scm := &config.SystemConfigMock{} | ||
| scm.On("GetSurveyConfig", mock.Anything, mock.Anything).Return(config.SurveyConfig{}, nil) | ||
| scm.On("GetSystemID", mock.Anything).Return("systemID", nil) | ||
| scm.On("SetSurveyConfig", mock.Anything, mock.Anything, mock.Anything).Return(nil) | ||
| cm.Config.SystemConfig = scm | ||
|
|
||
| pcm := &config.ProjectConfigMock{} | ||
| pcm.On("GetSurveyConfig", mock.Anything, mock.Anything).Return(config.SurveyConfig{}, nil) | ||
| pcm.On("GetProjectID", mock.Anything).Return("projectID", nil) | ||
| cm.Config.ProjectConfig = pcm | ||
|
|
||
| cm.IO.On("ConfirmPrompt", mock.Anything, "Open in browser?", mock.Anything).Return(false) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Added a
DEPRECATED(semver:X)comment to make this easier to find in the future. We are a little consistent with our deprecation comments -TODO(semver:major)and others also exist. Preference?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for both this comment and calling out the formatting!
IIRC we are using
TODO(semver:major)more often, but this is often for internal breaking changes AFAICT.I think
DEPRECATEDis meaningful here since it captures the ongoing support with an existing alternative option, but IMO thesemver:majorpart is the most important! This is what I would use in searching for these 😉There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I learned in review of #71 that
gohas a convention around making machine-readable comments that I'm interested in exploring:https://go.dev/wiki/Comments#directives
Using a similar pattern might be interesting for these more "conventional" comments, but I don't believe we have explicit notes on how these should be used overall...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One addition to this comment might also note the deprecated suggestions? 📚
Edit: I realize you make a similar comment a few lines down - no blocker here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
//go:directive is interesting. It led me down a path to find the use of the// DEPRECATED:comment in Golang. So, perhaps we can start to use that convention to signal deprecated code. I definitely agree that the(semver:major)scope is most important though!