Skip to content

Commit

Permalink
Add temporary workflow to test e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jun 18, 2024
1 parent 8d5de2b commit 87806cf
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 25 deletions.
23 changes: 5 additions & 18 deletions .github/actions/cloud-slack-e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,16 @@ runs:
shell: bash
run: "k3d cluster create cloud-slack-e2e-cluster --wait --timeout=5m"

- name: CLI Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
dist/botkube-cli_linux_amd64_v1/botkube
key: botkube-cli_linux_amd64_v1

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest

- name: Build CLI
- name: Download Botkube CLI
shell: bash
run: make build-single-arch-cli
run: |
curl -Lo botkube https://github.com/kubeshop/botkube/releases/download/v1.12.0/botkube-linux-amd64
chmod +x botkube && mv botkube $PWD/dist/bin/botkube
- name: Add Botkube CLI to env
shell: bash
run: |
echo BOTKUBE_CLI_BINARY_PATH="$PWD/dist/botkube-cli_linux_amd64_v1/botkube" >> $GITHUB_ENV
echo BOTKUBE_CLI_BINARY_PATH="$PWD/dist/bin/botkube" >> $GITHUB_ENV
- name: Setup Go modules
id: modules
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-go-mod-private/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
uses: actions/setup-go@v5
with:
go-version-file: './test/go.mod'
cache: true
cache: false
- name: Download Go modules with private repository
shell: bash
run: |
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/test-ui-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test UI E2E tests on PR

on:
push:
branches:
- extend-ui-tests

env:
GIT_USER: botkube-dev
HELM_VERSION: v3.9.0
K3D_VERSION: v5.4.6
IMAGE_REGISTRY: "ghcr.io"
IMAGE_REPOSITORY: "kubeshop/botkube"
IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch

jobs:
cloud-slack-dev-e2e:
name: Botkube Cloud Slack Dev E2E
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
concurrency:
group: cloud-slack-dev-e2e
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run e2e tests
uses: ./.github/actions/cloud-slack-e2e
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}

slack_workspace_name: ${{ secrets.E2E_DEV_SLACK_WORKSPACE_NAME }}
slack_email: ${{ secrets.E2E_DEV_SLACK_EMAIL }}
slack_password: ${{ secrets.E2E_DEV_SLACK_USER_PASSWORD }}
slack_bot_display_name: "BotkubeDev"
slack_tester_bot_token: ${{ secrets.E2E_DEV_SLACK_TESTER_BOT_TOKEN }}
slack_tester_bot_name: "botkubedev"

botkube_cloud_api_base_url: "https://api-dev.botkube.io"
botkube_cloud_email: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_EMAIL }}
botkube_cloud_password: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }}
botkube_cloud_team_organization_id: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }}

slack_alerts_webhook: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }}

e2e_type: "DEV"
6 changes: 4 additions & 2 deletions test/cloud-slack-dev-e2e/botkube_page_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ func (p *BotkubeCloudPage) SetupSlackWorkspace(t *testing.T, channel string) {

// filter by channel, to make sure that it's visible on the first table page, in order to select it in the next step
t.Log("Filtering by channel name")
p.page.Keyboard.MustType(input.End) // scroll bottom, as the footer collides with selecting filter
p.page.MustElement("table th:nth-child(3) span.ant-dropdown-trigger.ant-table-filter-trigger").MustFocus().MustClick()
//p.page.Keyboard.MustType(input.End) // scroll bottom, as the footer collides with selecting filter
p.page.Mouse.MustScroll(10, 5000)
p.page.Screenshot()
p.page.MustElement("table th:nth-child(3) span.ant-dropdown-trigger.ant-table-filter-trigger").MustClick()

t.Log("Selecting channel checkbox")
p.page.MustElement("input#name-channel").MustInput(channel).MustType(input.Enter)
Expand Down
3 changes: 1 addition & 2 deletions test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestCloudSlackE2E(t *testing.T) {
t.Run("Creating Botkube Instance with newly added Slack Workspace", func(t *testing.T) {
t.Log("Setting up browser...")

launcher := launcher.New().Headless(false)
launcher := launcher.New().Headless(true)
isHeadless := launcher.Has(flags.Headless)
t.Cleanup(launcher.Cleanup)

Expand Down Expand Up @@ -157,7 +157,6 @@ 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")
Expand Down
10 changes: 8 additions & 2 deletions test/cloud-slack-dev-e2e/slack_page_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package cloud_slack_dev_e2e

import (
"testing"
"time"

"github.com/go-rod/rod"
)
Expand Down Expand Up @@ -44,7 +45,13 @@ func (p *SlackPage) ConnectWorkspace(t *testing.T, headless bool, browser *rod.B
p.page.Screenshot()

t.Log("Hide Slack cookie banner that collides with 'Sign in' button")
p.page.MustElement("button#onetrust-accept-btn-handler").MustClick()
cookie, err := p.page.Timeout(5 * time.Second).Element("button#onetrust-accept-btn-handler")
if err != nil {
t.Logf("Failed to obtain cookie element: %s. Skipping...", err.Error())
} else {
cookie.MustClick()
}

p.page.MustElementR("button", "/^Sign in$/i").MustClick()
p.page.Screenshot()

Expand All @@ -63,4 +70,3 @@ func (p *SlackPage) ConnectWorkspace(t *testing.T, headless bool, browser *rod.B

_ = p.page.Close() // the page should be closed automatically anyway
}

0 comments on commit 87806cf

Please sign in to comment.