Skip to content
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

Improve Cloud Slack e2e test resiliency around Slack workspace connect #1352

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading