Skip to content

Commit

Permalink
Expand UI test (#1027)
Browse files Browse the repository at this point in the history
* refactor ui tests

* store acceptance test artifacts

* create a separate job for ui tests 

* invoke selenium settings for ui tests only

* remove needless input field

Co-authored-by: Jordan Pellizzari <jordan@weave.works>
  • Loading branch information
rokshana-b and jpellizzari committed Nov 20, 2021
1 parent afaa5aa commit 3ae9201
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 54 deletions.
9 changes: 8 additions & 1 deletion .github/actions/run-acceptance-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
gitlab-token:
description: "Token for accessing GitLab"
required: true
artifacts-base-dir:
description: "Directory for test artifacts"
required: true

runs:
using: "composite"
Expand All @@ -31,6 +34,7 @@ runs:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup selenium standalone server
if: ${{ github.job == 'ui-tests' }}
shell: bash
run: |
sudo apt-get update
Expand Down Expand Up @@ -91,16 +95,19 @@ runs:
GITLAB_SUBGROUP: weave-gitops-sub
GITLAB_TOKEN: ${{ inputs.gitlab-token }}
GITLAB_KEY: ${{ inputs.gitlab-key }}
ARTIFACTS_BASE_DIR: ${{ inputs.artifacts-base-dir }}
run: |
export PATH=${PATH}:`go env GOPATH`/bin
export WEGO_BIN_PATH=$(pwd)/bin/gitops
export CLUSTER_PROVIDER=kubectl
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega/...
ginkgo ${{ inputs.focus-or-skip }} --randomizeSuites --reportFile=${{ env.ARTIFACTS_BASE_DIR }}/${{ inputs.result-prefix }}acceptance-test-results.xml -v ./test/acceptance/test/...
if: always()
- name: Store acceptance test results
env:
ARTIFACTS_BASE_DIR: "/tmp/wego-test"
ARTIFACTS_BASE_DIR: ${{ inputs.artifacts-base-dir }}
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: ${{ inputs.result-prefix }}acceptance-test-artifacts
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

smoke-tests-long:
runs-on: ubuntu-latest
Expand All @@ -142,6 +143,7 @@ jobs:
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

acceptance-tests-0:
runs-on: ubuntu-latest
Expand All @@ -151,11 +153,12 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/run-acceptance-test
with:
focus-or-skip: "--skip='Test1|Test2|Test3|SmokeTest|SmokeTestLong'"
focus-or-skip: "--skip='Test1|Test2|Test3|SmokeTest|SmokeTestLong|UITest'"
github-key: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_SSH_KEY }}
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

acceptance-tests-1:
runs-on: ubuntu-latest
Expand All @@ -171,6 +174,7 @@ jobs:
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

acceptance-tests-2:
runs-on: ubuntu-latest
Expand All @@ -186,6 +190,7 @@ jobs:
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

acceptance-tests-3:
runs-on: ubuntu-latest
Expand All @@ -201,6 +206,23 @@ jobs:
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

ui-tests:
runs-on: ubuntu-latest
needs: [lint, build]
timeout-minutes: 90
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/run-acceptance-test
with:
result-prefix: 'ui-test-'
focus-or-skip: "--focus='UITest'"
github-key: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_SSH_KEY }}
github-token: ${{ secrets.WEAVE_GITOPS_TEST_WEAVEWORKS_WEAVE_GITOPS_BOT_TOKEN }}
gitlab-key: ${{ secrets.GITLAB_KEY }}
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
artifacts-base-dir: "/tmp/gitops-test"

library-integration-test:
runs-on: ubuntu-latest
Expand Down
34 changes: 34 additions & 0 deletions test/acceptance/test/pages/add_application_page.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package pages

import (
"github.com/sclevine/agouti"
)

type AddAppPageElements struct {
AddAppHeader *agouti.Selection
AppName *agouti.Selection
AppNamespace *agouti.Selection
AppRepoURL *agouti.Selection
ConfigRepoURL *agouti.Selection
PathToManifests *agouti.Selection
Branch *agouti.Selection
AutoMergeCheck *agouti.Selection
SubmitButton *agouti.Selection
AuthenticationButton *agouti.Selection
}

func GetAddAppPageElements(webDriver *agouti.Page) *AddAppPageElements {
addApplicationPage := AddAppPageElements{
AddAppHeader: webDriver.FindByXPath(`//*[@id="app"]//nav//h2[text()="Add Application"]`),
AppName: webDriver.FindByID("name"),
AppNamespace: webDriver.FindByID("namespace"),
AppRepoURL: webDriver.FindByID("url"),
ConfigRepoURL: webDriver.FindByID("configUrl"),
PathToManifests: webDriver.FindByID("path"),
Branch: webDriver.FindByID("branch"),
AutoMergeCheck: webDriver.FindByXPath(`//input[@type="checkbox" and contains(@class, 'MuiSwitch-input')]`),
SubmitButton: webDriver.FindByXPath(`//button[@type="submit" and //@span=(text()="Submit")]`),
AuthenticationButton: webDriver.FindByXPath(`//button[@type="button"]/span[text()="Authenticate with Github"]`)}

return &addApplicationPage
}
67 changes: 67 additions & 0 deletions test/acceptance/test/pages/application_page.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package pages

import "github.com/sclevine/agouti"

type AppDetailsPageElements struct {
ApplicationsHeader *agouti.Selection
NameSubheader *agouti.Selection
DeploymentTypeSubheader *agouti.Selection
URLSubheader *agouti.Selection
PathSubheader *agouti.Selection
AppName *agouti.Selection
}

type NamedElements struct {
AppNameHeader *agouti.Selection
AppName *agouti.Selection
AppType *agouti.Selection
AppURL *agouti.Selection
AppPathToManifests *agouti.Selection
HelmSuccessMessage *agouti.Selection
KustomizeSuccessMessage *agouti.Selection
}

func GetAppDetailsPageElements(webDriver *agouti.Page) *AppDetailsPageElements {
appDetailsPage := AppDetailsPageElements{
ApplicationsHeader: webDriver.FindByXPath(`//*[@id="app"]//nav/ol/li/a/span/h2[text()="Applications"]`),
NameSubheader: webDriver.FindByXPath(`//table/tbody/tr/td[1]/div[text()="Name"]`),
DeploymentTypeSubheader: webDriver.FindByXPath(`//table/tbody/tr/td[2]/div[text()="Deployment Type"]`),
URLSubheader: webDriver.FindByXPath(`//table/tbody/tr/td[3]/div[text()="URL"]`),
PathSubheader: webDriver.FindByXPath(`//table/tbody/tr/td[4]/div[text()="Path"]`)}

return &appDetailsPage
}

func GetAppNameElements(webDriver *agouti.Page, appName string) *NamedElements {
appNameElements := NamedElements{
AppNameHeader: webDriver.FindByXPath(`//*[@id="app"]//div/nav/ol/li/h2[text()="` + appName + `"]`),
AppName: webDriver.FindByXPath(`//table/tbody/tr/td[1]/div[text()="` + appName + `"]`)}

return &appNameElements
}

func GetAppTypeElement(webDriver *agouti.Page, appType string) *NamedElements {
appTypeElement := NamedElements{
AppType: webDriver.FindByXPath(`//table/tbody/tr/td[2]/div[text()="` + appType + `"]`)}
return &appTypeElement
}

func GetURLElement(webDriver *agouti.Page, appURL string) *NamedElements {
appURLElement := NamedElements{
AppURL: webDriver.FindByXPath(`//table/tbody/tr/td[3]/div[text()="` + appURL + `"]`)}
return &appURLElement
}

func GetPathElement(webDriver *agouti.Page, pathToManifests string) *NamedElements {
appPathElement := NamedElements{
AppPathToManifests: webDriver.FindByXPath(`//table/tbody/tr/td[4]/div[text()="` + pathToManifests + `"]`)}
return &appPathElement
}

func GetMessageElements(webDriver *agouti.Page, msg string) *NamedElements {
successMsgElement := NamedElements{
HelmSuccessMessage: webDriver.FindByXPath(`//table//tbody/tr/td[text()="` + msg + ` install succeeded"]`),
KustomizeSuccessMessage: webDriver.FindByXPath(`//table/tbody/tr/td[text()="` + msg + `"]`)}

return &successMsgElement
}
28 changes: 20 additions & 8 deletions test/acceptance/test/pages/dashboard_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ import (
"github.com/sclevine/agouti"
)

type DashboardWebDriver struct {
LogoImage *agouti.Selection
ApplicationTab *agouti.Selection
type DashboardPageElements struct {
LogoImage *agouti.Selection
ApplicationsHeader *agouti.Selection
AddAppButton *agouti.Selection
}

func Dashboard(webDriver *agouti.Page) DashboardWebDriver {
dashboard := DashboardWebDriver{
LogoImage: webDriver.FindByXPath(`//*[@id="app"]/div//img`),
ApplicationTab: webDriver.FindByXPath(`//*[@id="app"]//div/a/span/span[1]`)}
type AppListElements struct {
AppList *agouti.Selection
}

func GetDashboardPageElements(webDriver *agouti.Page) *DashboardPageElements {
dashboard := DashboardPageElements{
LogoImage: webDriver.FindByXPath(`//*[@id="app"]/div//img`),
ApplicationsHeader: webDriver.FindByXPath(`//*[@id="app"]//div/h2[text()="Applications"]`),
AddAppButton: webDriver.FindByXPath(`//*[@id="app"]//button[@span=(text()="Add Application")]`)}

return &dashboard
}

return dashboard
func GetAppListElements(webDriver *agouti.Page, appName string) *AppListElements {
appList := AppListElements{
AppList: webDriver.FindByXPath(`//*[@id="app"]//tbody/tr/td/span/a[contains(@href,'` + appName + `')]`)}
return &appList
}

0 comments on commit 3ae9201

Please sign in to comment.