diff --git a/test/cloud-slack-dev-e2e/e2e_test.go b/test/cloud-slack-dev-e2e/e2e_test.go index a67ce26bc..2ba73c5f4 100644 --- a/test/cloud-slack-dev-e2e/e2e_test.go +++ b/test/cloud-slack-dev-e2e/e2e_test.go @@ -14,7 +14,6 @@ import ( "testing" "time" - "github.com/MakeNowJust/heredoc" "github.com/go-rod/rod" "github.com/go-rod/rod/lib/launcher" "github.com/go-rod/rod/lib/proto" @@ -346,6 +345,10 @@ func TestCloudSlackE2E(t *testing.T) { } err = tester.WaitForMessagePosted(tester.BotUserID(), channel.ID(), 3, assertionFn) + cmdHeader := func(command string) string { + return fmt.Sprintf("`%s` on `%s`", command, deployment.Name) + } + t.Run("Check basic commands", func(t *testing.T) { t.Log("Testing ping with --cluster-name") command := fmt.Sprintf("ping --cluster-name %s", deployment.Name) @@ -383,7 +386,7 @@ func TestCloudSlackE2E(t *testing.T) { t.Log("Testing getting all deployments") command = "kubectl get deployments -A" assertionFn := func(msg string) (bool, int, string) { - return strings.Contains(msg, heredoc.Doc(fmt.Sprintf("`%s` on `%s`", command, deployment.Name))) && + return strings.Contains(msg, cmdHeader(command)) && strings.Contains(msg, "coredns") && strings.Contains(msg, "botkube"), 0, "" } @@ -454,12 +457,20 @@ func TestCloudSlackE2E(t *testing.T) { t.Log("Verifying disabled notification on Cloud...") deploy := gqlCli.MustGetDeployment(t, graphql.ID(deployment.ID)) require.True(t, *deploy.Platforms.CloudSlacks[0].Channels[0].NotificationsDisabled) + + t.Log("Verifying disabled notifications on chat...") + command := "status notifications" + expectedBody := formatx.CodeBlock(fmt.Sprintf("Notifications from cluster '%s' are disabled here.", deployment.Name)) + expectedMessage := fmt.Sprintf("%s\n%s", cmdHeader(command), expectedBody) + tester.PostMessageToBot(t, channel.ID(), "status notifications") + err = tester.WaitForLastMessageEqual(tester.BotUserID(), channel.ID(), expectedMessage) + require.NoError(t, err) }) t.Run("Cloud -> Botkube Deployment sync", func(t *testing.T) { t.Log("Removing source binding from Slack platform & add actions") d := gqlCli.MustGetDeployment(t, graphql.ID(deployment.ID)) // Get final resource version - deployment = removeCloudSlackSourcesFromDeployment(t, gqlCli.Client, &d) + deployment = removeSourcesAndAddActions(t, gqlCli.Client, &d) t.Log("Waiting for config reload message...") expectedReloadMsg := fmt.Sprintf(":arrows_counterclockwise: Configuration reload requested for cluster '%s'. Hold on a sec...", deployment.Name) @@ -473,12 +484,12 @@ func TestCloudSlackE2E(t *testing.T) { tester.PostMessageToBot(t, channel.ID(), "list sources") t.Log("Waiting for empty source list...") - expectedSourceListMsg := fmt.Sprintf("`list sources` on `%s`\n```\nSOURCE ENABLED\n```", deployment.Name) + expectedSourceListMsg := fmt.Sprintf("%s\n```\nSOURCE ENABLED\n```", cmdHeader("list sources")) err = tester.WaitForLastMessageEqual(tester.BotUserID(), channel.ID(), expectedSourceListMsg) require.NoError(t, err) tester.PostMessageToBot(t, channel.ID(), "list actions") t.Log("Waiting for actions list...") - expectedActionsListMsg := fmt.Sprintf("`list actions` on `%s`\n```\nACTION ENABLED DISPLAY NAME\naction_xxx22 true Action Name\n```", deployment.Name) + expectedActionsListMsg := fmt.Sprintf("%s\n```\nACTION ENABLED DISPLAY NAME\naction_xxx22 true Action Name\n```", cmdHeader("list actions")) err = tester.WaitForLastMessageEqual(tester.BotUserID(), channel.ID(), expectedActionsListMsg) require.NoError(t, err) }) @@ -554,7 +565,7 @@ func newBrowserPage(t *testing.T, browser *rod.Browser, cfg E2ESlackConfig) *rod return page } -func removeCloudSlackSourcesFromDeployment(t *testing.T, gql *graphql.Client, existingDeployment *gqlModel.Deployment) *gqlModel.Deployment { +func removeSourcesAndAddActions(t *testing.T, gql *graphql.Client, existingDeployment *gqlModel.Deployment) *gqlModel.Deployment { existingDeployment.HelmCommand = nil existingDeployment.InstallUpgradeInstructions = nil existingDeployment.APIKey = nil