Skip to content

Commit

Permalink
Add more screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jun 18, 2024
1 parent 7ab399d commit 778115e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/actions/cloud-slack-e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ runs:
SLACK_TESTER_TESTER_BOT_TOKEN: ${{ inputs.slack_tester_bot_token }}
SLACK_BOT_DISPLAY_NAME: ${{ inputs.slack_bot_display_name }}
SLACK_TESTER_BOT_NAME: ${{ inputs.slack_tester_bot_name }}
SLACK_TESTER_MESSAGE_WAIT_TIMEOUT: 90s
SLACK_TESTER_MESSAGE_WAIT_TIMEOUT: 180s


BOTKUBE_CLOUD_API_BASE_URL: ${{ inputs.botkube_cloud_api_base_url }}
Expand Down
42 changes: 27 additions & 15 deletions test/cloud-slack-dev-e2e/botkube_page_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func (p *BotkubeCloudPage) CreateNewInstance(t *testing.T, name string) {
}

func (p *BotkubeCloudPage) InstallAgentInCluster(t *testing.T, botkubeBinary string) {
t.Log("Installing Botkube using Botkube CLI")

t.Log("Getting Botkube install command")
installCmd := p.page.MustElement("div#install-upgrade-cmd > kbd").MustText()

t.Log("Installing Botkube using Botkube CLI")
args, err := shellwords.Parse(installCmd)
args = append(args, "--auto-approve")
require.NoError(t, err)
Expand All @@ -119,6 +119,7 @@ func (p *BotkubeCloudPage) InstallAgentInCluster(t *testing.T, botkubeBinary str
}

func (p *BotkubeCloudPage) OpenSlackAppIntegrationPage(t *testing.T) {
t.Log("Opening Slack App Integration Page")
p.page.MustElement(`button[aria-label="Add tab"]`).MustClick()
p.page.MustWaitStable()
p.page.MustElementR("button", "^Slack$").MustClick()
Expand Down Expand Up @@ -176,17 +177,17 @@ func (p *BotkubeCloudPage) FinishWizard(t *testing.T) {

p.page.MustElementR("button", "/^Next$/i").
MustWaitEnabled().
// we need to wait, otherwise, we click the same 'Next' button twice, before the query is executed, and we are really
// moved to the next step. If we have the navigation updated for each step, it will be resolved.
MustClick().MustWaitStable()
// We need to wait, otherwise, we click the same 'Next' button twice before the query is executed, and we are not really
// moved to the next step. Updating the navigation would resolve that issue.
MustClick().MustWaitStable()

p.page.Screenshot("after-first-next")

t.Log("Using pre-selected plugins. Navigating to wizard summary")
p.page.MustElementR("button", "/^Next$/i").
MustWaitEnabled().
// we need to wait, otherwise, we click the same 'Next' button twice, before the query is executed, and we are really
// moved to the next step. If we have the navigation updated for each step, it will be resolved.
// We need to wait, otherwise, we click the same 'Next' button twice before the query is executed, and we are not really
// moved to the next step. Updating the navigation would resolve that issue.
MustClick().MustWaitStable()
p.page.Screenshot("after-second-next")

Expand All @@ -198,33 +199,44 @@ func (p *BotkubeCloudPage) FinishWizard(t *testing.T) {

// wait till gql mutation passes, and navigates to install details, otherwise, we could navigate to instance details with state 'draft'
p.page.MustWaitNavigation()
p.page.Screenshot()
p.page.Screenshot("after-deploy-changes-navigation")
}

func (p *BotkubeCloudPage) UpdateKubectlNamespace(t *testing.T) {
t.Log("Updating 'kubectl' namespace property")
p.page.MustElementR(`div[role="tab"]`, "Plugins").MustFocus().MustClick().MustWaitStable()

p.page.MustWaitStable()
p.page.MustElement(`button[id^="botkube/kubectl_"]`).MustClick()
p.page.MustElement(`div[data-node-key="ui-form"]`).MustClick()

p.openKubectlUpdateForm()

p.page.MustElementR("input#root_defaultNamespace", "default").MustSelectAllText().MustInput("kube-system")
p.page.Screenshot("after-changing-namespace-property")
p.page.MustElementR("button", "/^Update$/i").MustClick()
p.page.Screenshot("after-clicking-plugin-update")

t.Log("Submitting changes")
p.page.MustElementR("button", "/^Deploy changes$/i").MustClick().MustWaitStable()
p.page.MustWaitStable()
p.page.MustElementR("button", "/Deploy changes/i").MustClick()
p.page.Screenshot("after-deploying-plugin-changes")
}

func (p *BotkubeCloudPage) VerifyUpdatedKubectlNamespace(t *testing.T) {
t.Log("Verifying that the 'namespace' value was updated and persisted properly")

p.openKubectlUpdateForm()
p.page.MustElementR("input#root_defaultNamespace", "kube-system")
}

func (p *BotkubeCloudPage) openKubectlUpdateForm() {
p.page.Screenshot("before-selecting-plugins-tab")
p.page.MustElementR(`div[role="tab"]`, "Plugins").MustFocus().MustClick().MustWaitStable()

p.page.MustWaitStable()
p.page.Screenshot("after-selecting-plugins-tab")

p.page.MustElement(`button[id^="botkube/kubectl_"]`).MustClick()
p.page.Screenshot("after-opening-kubectl-cfg")

p.page.MustElement(`div[data-node-key="ui-form"]`).MustClick()
p.page.Screenshot("after-selecting-kubectl-cfg-form")
p.page.MustElementR("input#root_defaultNamespace", "kube-system")
}

func appendOrgIDQueryParam(t *testing.T, inURL, orgID string) string {
Expand Down
32 changes: 14 additions & 18 deletions test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ func TestCloudSlackE2E(t *testing.T) {
botkubeCloudPage.SetupSlackWorkspace(t, channel.Name())
botkubeCloudPage.FinishWizard(t)
botkubeCloudPage.VerifyDeploymentStatus(t, "Connected")
botkubeCloudPage.UpdateKubectlNamespace(t)
botkubeCloudPage.VerifyDeploymentStatus(t, "Updating")
botkubeCloudPage.VerifyDeploymentStatus(t, "Connected")
botkubeCloudPage.VerifyUpdatedKubectlNamespace(t)

if !isHeadless { // it is flaky on CI, more investigation needed
botkubeCloudPage.UpdateKubectlNamespace(t)
botkubeCloudPage.VerifyDeploymentStatus(t, "Updating")
botkubeCloudPage.VerifyDeploymentStatus(t, "Connected")
botkubeCloudPage.VerifyUpdatedKubectlNamespace(t)
}

})

t.Run("Run E2E tests with deployment", func(t *testing.T) {
Expand Down Expand Up @@ -317,12 +321,12 @@ func TestCloudSlackE2E(t *testing.T) {
t.Log("Disabling notification...")
tester.PostMessageToBot(t, channel.Identifier(), "disable notifications")

t.Log("Waiting for config reload message...")
t.Log(time.Now().Format(time.TimeOnly), "Waiting for config reload message...")
expectedReloadMsg := fmt.Sprintf(":arrows_counterclockwise: Configuration reload requested for cluster '%s'. Hold on a sec...", connectedDeploy.Name)
err = tester.OnChannel().WaitForMessagePostedRecentlyEqual(tester.BotUserID(), channel.ID(), expectedReloadMsg)
require.NoError(t, err)

t.Log("Waiting for watch begin message...")
t.Log(time.Now().Format(time.TimeOnly), "Waiting for watch begin message...")
expectedWatchBeginMsg := fmt.Sprintf("My watch begins for cluster '%s'! :crossed_swords:", connectedDeploy.Name)
recentMessages := 2 // take into the account the optional "upgrade checker message"
err = tester.OnChannel().WaitForMessagePosted(tester.BotUserID(), channel.ID(), recentMessages, func(msg string) (bool, int, string) {
Expand Down Expand Up @@ -353,13 +357,12 @@ func TestCloudSlackE2E(t *testing.T) {
d := gqlCli.MustGetDeployment(t, graphql.ID(connectedDeploy.ID)) // Get final resource version
connectedDeploy = removeSourcesAndAddActions(t, gqlCli.Client, &d)

t.Log("Waiting for config reload message...")
t.Log(time.Now().Format(time.TimeOnly), "Waiting for config reload message...")
expectedReloadMsg := fmt.Sprintf(":arrows_counterclockwise: Configuration reload requested for cluster '%s'. Hold on a sec...", connectedDeploy.Name)
tester.SetTimeout(90 * time.Second)
err = tester.OnChannel().WaitForMessagePostedRecentlyEqual(tester.BotUserID(), channel.ID(), expectedReloadMsg)
require.NoError(t, err)

t.Log("Waiting for watch begin message...")
t.Log(time.Now().Format(time.TimeOnly), "Waiting for watch begin message...")
expectedWatchBeginMsg := fmt.Sprintf("My watch begins for cluster '%s'! :crossed_swords:", connectedDeploy.Name)
recentMessages := 2 // take into the account the optional "upgrade checker message"
err = tester.OnChannel().WaitForMessagePosted(tester.BotUserID(), channel.ID(), recentMessages, func(msg string) (bool, int, string) {
Expand Down Expand Up @@ -457,19 +460,12 @@ func removeSourcesAndAddActions(t *testing.T, gql *graphql.Client, existingDeplo
for _, slack := range existingDeployment.Platforms.CloudSlacks {
var channelUpdateInputs []*gqlModel.ChannelBindingsByNameAndIDUpdateInput
for _, channel := range slack.Channels {
var executors []*string
for _, e := range channel.Bindings.Executors {
if strings.Contains(strings.ToLower(e), "ai") { // AI is also a source plugin
continue
}
executors = append(executors, &e)
}
channelUpdateInputs = append(channelUpdateInputs, &gqlModel.ChannelBindingsByNameAndIDUpdateInput{
ChannelID: "", // this is used for UI only so we don't need to provide it
Name: channel.Name,
Bindings: &gqlModel.BotBindingsUpdateInput{
Sources: []*string{},
Executors: executors,
Sources: []*string{},
Executors: []*string{},
},
})
}
Expand Down
8 changes: 5 additions & 3 deletions test/cloud-slack-dev-e2e/gql.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package cloud_slack_dev_e2e

import (
"strings"

gqlModel "github.com/kubeshop/botkube-cloud/botkube-cloud-backend/pkg/graphql"
)

Expand Down Expand Up @@ -50,13 +52,13 @@ func CreateActionUpdateInput(deploy *gqlModel.Deployment) []*gqlModel.ActionCrea
}
}

// DeploymentSourceAndExecutor returns last source and executor plugin found under plugins.
// DeploymentSourceAndExecutor returns last 'kubernetes' source and 'kubectl' executor plugin found under plugins.
func DeploymentSourceAndExecutor(deploy *gqlModel.Deployment) (source string, executor string) {
for _, plugin := range deploy.Plugins {
if plugin.Type == gqlModel.PluginTypeSource {
if plugin.Type == gqlModel.PluginTypeSource && strings.Contains(plugin.Name, "kubernetes"){
source = plugin.ConfigurationName
}
if plugin.Type == gqlModel.PluginTypeExecutor {
if plugin.Type == gqlModel.PluginTypeExecutor && strings.Contains(plugin.Name, "kubectl"){
executor = plugin.ConfigurationName
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/commplatform/slack_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type SlackConfig struct {
CloudTesterAppToken string `envconfig:"optional"`
CloudTesterName string `envconfig:"default=tester2"`
RecentMessagesLimit int `envconfig:"default=6"`
MessageWaitTimeout time.Duration `envconfig:"default=50s"`
MessageWaitTimeout time.Duration `envconfig:"default=180s"`
}

type SlackChannel struct {
Expand Down

0 comments on commit 778115e

Please sign in to comment.