Skip to content

Commit

Permalink
Improve Cloud Slack e2e test resiliency around Slack workspace connect (
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec authored Jan 17, 2024
1 parent 61ff870 commit 52e8e13
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,47 +267,54 @@ func TestCloudSlackE2E(t *testing.T) {
botkubePage.MustElementR("div.ant-result-title", "Organization Already Connected!")
} else {
t.Log("Finalizing connection...")
screenshotIfShould(t, cfg, botkubePage)
botkubePage.MustElement("a.logo-link")
screenshotIfShould(t, cfg, botkubePage)
botkubePage.MustElementR("button > span", "Connect").MustParent().MustClick()
// detect homepage
screenshotIfShould(t, cfg, botkubePage)
botkubePage.MustElementR(".ant-layout-content p", "All Botkube installations managed by Botkube Cloud.")
// detect homepage
_, err := botkubePage.ElementR(".ant-layout-content p", "All Botkube installations managed by Botkube Cloud.")
assert.NoError(t, err) // fail the test, but move on: capture the screenshot and try to disconnect Slack workspace later
if err != nil {
screenshotIfShould(t, cfg, botkubePage)
}
}
})

t.Run("Run E2E tests with deployment", func(t *testing.T) {
require.NotEmpty(t, authHeaderValue, "Previous subtest needs to pass to get authorization header value")

t.Log("Initializing Slack...")
tester, err := commplatform.NewSlackTester(cfg.Slack.Tester, nil)
require.NoError(t, err)

t.Log("Initializing users...")
tester.InitUsers(t)

t.Log("Creating channel...")
channel, createChannelCallback := tester.CreateChannel(t, "e2e-test")
t.Cleanup(func() { createChannelCallback(t) })

t.Log("Inviting Bot to the channel...")
tester.InviteBotToChannel(t, channel.ID())

t.Logf("Using Organization ID %q and Authorization header starting with %q", cfg.BotkubeCloud.TeamOrganizationID,
stringsutil.ShortenString(authHeaderValue, 15))

gqlCli := cloud_graphql.NewClientForAuthAndOrg(gqlEndpoint, cfg.BotkubeCloud.TeamOrganizationID, authHeaderValue)

t.Logf("Getting connected Slack workspace...")
slackWorkspaces := gqlCli.MustListSlackWorkspacesForOrg(t, cfg.BotkubeCloud.TeamOrganizationID)
require.Len(t, slackWorkspaces, 1)
slackWorkspace := slackWorkspaces[0]
require.NotNil(t, slackWorkspace)

t.Cleanup(func() {
if !cfg.Slack.DisconnectWorkspaceAfterTests {
return
}
gqlCli.MustDeleteSlackWorkspace(t, cfg.BotkubeCloud.TeamOrganizationID, slackWorkspace.ID)
})

t.Log("Initializing Slack...")
tester, err := commplatform.NewSlackTester(cfg.Slack.Tester, nil)
require.NoError(t, err)

t.Log("Initializing users...")
tester.InitUsers(t)

t.Log("Creating channel...")
channel, createChannelCallback := tester.CreateChannel(t, "e2e-test")
t.Cleanup(func() { createChannelCallback(t) })

t.Log("Inviting Bot to the channel...")
tester.InviteBotToChannel(t, channel.ID())

t.Log("Creating deployment...")
deployment := gqlCli.MustCreateBasicDeploymentWithCloudSlack(t, channel.Name(), slackWorkspace.TeamID, channel.Name())
t.Cleanup(func() {
Expand Down

0 comments on commit 52e8e13

Please sign in to comment.