From 805b02fba7728614e1eaed6c49f6a485c1cebb13 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 29 Jan 2026 19:35:37 -0800 Subject: [PATCH] fix: cleanup checks for apps after opening 'app settings' without a project --- cmd/app/settings.go | 3 +++ cmd/app/settings_test.go | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/app/settings.go b/cmd/app/settings.go index 08c6426..e926e40 100644 --- a/cmd/app/settings.go +++ b/cmd/app/settings.go @@ -101,6 +101,9 @@ func appSettingsCommandRunE(clients *shared.ClientFactory, cmd *cobra.Command, a if err != nil { // If no apps exist, open the list of all apps known to the developer if slackerror.Is(err, slackerror.ErrInstallationRequired) { + // Clean up any empty .slack directory and files created during app selection + clients.AppClient().CleanUp() + host := clients.API().Host() parsed, err := url.Parse(host) if err != nil { diff --git a/cmd/app/settings_test.go b/cmd/app/settings_test.go index 5c5f6df..1f3a16a 100644 --- a/cmd/app/settings_test.go +++ b/cmd/app/settings_test.go @@ -16,6 +16,7 @@ package app import ( "context" + "path/filepath" "testing" "github.com/slackapi/slack-cli/internal/app" @@ -23,16 +24,18 @@ import ( "github.com/slackapi/slack-cli/internal/prompts" "github.com/slackapi/slack-cli/internal/shared" "github.com/slackapi/slack-cli/internal/shared/types" + "github.com/slackapi/slack-cli/internal/slackdeps" "github.com/slackapi/slack-cli/internal/slackerror" "github.com/slackapi/slack-cli/internal/slacktrace" "github.com/slackapi/slack-cli/test/testutil" "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) func Test_App_SettingsCommand(t *testing.T) { testutil.TableTestCommand(t, testutil.CommandTests{ - "opens app listing page when not in a project directory": { + "opens app listing page when run from a random directory": { Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { appSelectMock := prompts.NewAppSelectMock() appSelectMock.On( @@ -53,6 +56,10 @@ func Test_App_SettingsCommand(t *testing.T) { cm.Browser.AssertCalled(t, "OpenURL", expectedURL) cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.AppSettingsStart, mock.Anything) cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.AppSettingsSuccess, []string{expectedURL}) + // Verify no .slack directory was left behind + slackDir := filepath.Join(slackdeps.MockWorkingDirectory, ".slack") + _, err := cm.Fs.Stat(slackDir) + assert.True(t, cm.Os.IsNotExist(err), ".slack directory should not exist") }, }, "errors for rosi applications": {