Skip to content

Commit

Permalink
Update E2E tests for new admin portal routing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsatam committed Sep 21, 2023
1 parent 846693f commit 0c7ebc0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion portal/v2/src/ClusterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function ClusterDetailPanel(props: {
<Icon styles={headerIconStyles} iconName="openshift-svg"></Icon>
</Stack.Item>
<Stack.Item>
<div className={headerStyles.titleText}>{currentCluster?.name}</div>
<div id="ClusterDetailName" className={headerStyles.titleText}>{currentCluster?.name}</div>
<div className={headerStyles.subtitleText}>Cluster</div>
<ToolIcons resourceId={currentCluster ? currentCluster?.resourceId : ""} version={Number(data?.version) !== undefined ? Number(data?.version) : 0} csrfToken={props.csrfToken} sshBox={props.sshBox}/>
</Stack.Item>
Expand Down
31 changes: 27 additions & 4 deletions test/e2e/admin_portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package e2e

import (
"errors"
"fmt"
"os"
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -26,6 +28,8 @@ var _ = Describe("Admin Portal E2E Testing", func() {
var wd selenium.WebDriver
var host string

var clusterDetailTabs = []string{"Overview", "Nodes", "Machines", "MachineSets", "APIStatistics", "KCMStatistics", "DNSStatistics", "IngressStatistics", "ClusterOperators"}

JustBeforeEach(func() {
host, wdPoint = adminPortalSessionSetup()
wd = *wdPoint
Expand Down Expand Up @@ -207,20 +211,39 @@ var _ = Describe("Admin Portal E2E Testing", func() {
})

It("Should display the correct cluster detail view for the resource ID parameter in the URL", func() {
wd.Get(host + "/" + "?resourceid=" + resourceIDFromEnv())
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)

detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())

elem, err := wd.FindElement(selenium.ByCSSSelector, "div[class='titleText-112']")
elem, err := wd.FindElement(selenium.ByID, "ClusterDetailName")
Expect(err).ToNot(HaveOccurred())
Expect(elem.Text()).To(Equal(clusterName))
})

It("Should update URL for each tab in cluster detail page", func() {
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)

detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expect(err).ToNot(HaveOccurred())
Expect(detailPanel.IsDisplayed()).To(BeTrue())

for _, tab := range clusterDetailTabs {
button, err := wd.FindElement(selenium.ByCSSSelector, fmt.Sprintf("div[name='%s']", tab))
Expect(err).ToNot(HaveOccurred())
button.Click()

currentUrl, err := wd.CurrentURL()
Expect(err).ToNot(HaveOccurred())
Expect(currentUrl).To(HaveSuffix("%s%s/%s", host, resourceIDFromEnv(), strings.ToLower(tab)))
}
})

It("Should display refresh button to get latest details for each tab in cluster detail page", func() {
wd.Get(host + "/" + "?resourceid=" + resourceIDFromEnv())
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)

detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expand Down Expand Up @@ -343,7 +366,7 @@ var _ = Describe("Admin Portal E2E Testing", func() {
})

It("Should display the action icons on cluster detail page", func() {
wd.Get(host + "/" + "?resourceid=" + resourceIDFromEnv())
wd.Get(host + resourceIDFromEnv())
wd.WaitWithTimeout(conditions.ElementIsLocated(selenium.ByID, "ClusterDetailPanel"), time.Second*3)

detailPanel, err := wd.FindElement(selenium.ByID, "ClusterDetailPanel")
Expand Down

0 comments on commit 0c7ebc0

Please sign in to comment.