diff --git a/cmd/sandbox/list.go b/cmd/sandbox/list.go index aff8ceeb..970f70bc 100644 --- a/cmd/sandbox/list.go +++ b/cmd/sandbox/list.go @@ -119,9 +119,9 @@ func printSandboxes(cmd *cobra.Command, clients *shared.ClientFactory, token str if s.Status != "" { status := style.Secondary(fmt.Sprintf("Status: %s", strings.ToTitle(s.Status))) if strings.EqualFold(s.Status, "archived") { - clients.IO.PrintInfo(ctx, false, " %s", style.Styler().Red(status)) + clients.IO.PrintInfo(ctx, false, " %s", style.Red(status)) } else { - clients.IO.PrintInfo(ctx, false, " %s", style.Styler().Green(status)) + clients.IO.PrintInfo(ctx, false, " %s", style.Green(status)) } } diff --git a/cmd/sandbox/list_test.go b/cmd/sandbox/list_test.go index 5223c50a..ef099982 100644 --- a/cmd/sandbox/list_test.go +++ b/cmd/sandbox/list_test.go @@ -49,7 +49,7 @@ func TestListCommand(t *testing.T) { cm.API.AssertCalled(t, "ListSandboxes", mock.Anything, "xoxb-test-token", "") }, }, - "with sandboxes": { + "with active sandboxes": { CmdArgs: []string{"--experiment=sandboxes", "--token", "xoxb-test-token"}, Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { testToken := "xoxb-test-token" @@ -73,7 +73,36 @@ func TestListCommand(t *testing.T) { cm.Config.ExperimentsFlag = []string{string(experiment.Sandboxes)} cm.Config.LoadExperiments(ctx, cm.IO.PrintDebug) }, - ExpectedStdoutOutputs: []string{"my-sandbox", "T123", "https://my-sandbox.slack.com"}, + ExpectedStdoutOutputs: []string{"my-sandbox", "T123", "https://my-sandbox.slack.com", "Status: ACTIVE"}, + ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { + cm.API.AssertCalled(t, "ListSandboxes", mock.Anything, "xoxb-test-token", "") + }, + }, + "with archived sandbox": { + CmdArgs: []string{"--experiment=sandboxes", "--token", "xoxb-test-token"}, + Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) { + testToken := "xoxb-test-token" + cm.Auth.On("AuthWithToken", mock.Anything, testToken).Return(types.SlackAuth{Token: testToken}, nil) + cm.Auth.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).Return("https://api.slack.com") + cm.Auth.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).Return("https://slackb.com/events/cli") + sandboxes := []types.Sandbox{ + { + SandboxTeamID: "T456", + SandboxName: "old-sandbox", + SandboxDomain: "old-sandbox", + Status: "archived", + DateCreated: 1700000000, + DateArchived: 1710000000, + }, + } + cm.API.On("ListSandboxes", mock.Anything, testToken, "").Return(sandboxes, nil) + cm.API.On("UsersInfo", mock.Anything, mock.Anything, mock.Anything).Return(&types.UserInfo{Profile: types.UserProfile{}}, nil) + + cm.AddDefaultMocks() + cm.Config.ExperimentsFlag = []string{string(experiment.Sandboxes)} + cm.Config.LoadExperiments(ctx, cm.IO.PrintDebug) + }, + ExpectedStdoutOutputs: []string{"old-sandbox", "T456", "Status: ARCHIVED"}, ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) { cm.API.AssertCalled(t, "ListSandboxes", mock.Anything, "xoxb-test-token", "") }, diff --git a/internal/style/style.go b/internal/style/style.go index 1a474061..44fb6e2b 100644 --- a/internal/style/style.go +++ b/internal/style/style.go @@ -153,7 +153,7 @@ func Warning(text string) string { if !isCharmEnabled { return legacyWarning(text) } - return render(lipgloss.NewStyle().Foreground(slackGreen).Bold(true), text) + return render(lipgloss.NewStyle().Foreground(slackYellow).Bold(true), text) } func Header(text string) string {