Skip to content

Commit

Permalink
chore(e2e): [Test automation] Verify Topology is a supported plugin a…
Browse files Browse the repository at this point in the history
…nd E2E scenario follow-up (#2191)

* [Test automation] Verify Topology is a supported plugin and E2E scenario follow-up

* Namespace removed

* [Test automation] Verify Topology is a supported plugin and E2E scenario follow-up

* Namespace removed

* [Test automation] Verify Topology is a supported plugin and E2E scenario follow-up

* Namespace removed

* Sleep test

* TLS issue

* pipeline config change

* cleanup

* cleanup

* cleanup

* 1.4 changes

* fix

* Requested changes

* Requested changes
  • Loading branch information
teknaS47 authored Jan 19, 2025
1 parent 0653e1d commit b91248f
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 18 deletions.
87 changes: 87 additions & 0 deletions .ibm/pipelines/resources/topology_test/topology-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: topology-test
labels:
app.kubernetes.io/instance: topology-test
app.kubernetes.io/name: topology-test
backstage.io/kubernetes-id: developer-hub
spec:
tasks:
- name: deploy
taskSpec:
steps:
- name: oc
image: 'quay.io/openshift/origin-cli:latest'
script: |
#!/bin/sh
oc "$@"
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: topology-test-run
labels:
app: topology-test
backstage.io/kubernetes-id: developer-hub
spec:
pipelineRef:
name: topology-test
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: topology-test
labels:
app.kubernetes.io/instance: topology-test
app.kubernetes.io/name: topology-test
backstage.io/kubernetes-id: developer-hub
annotations:
app.openshift.io/vcs-uri: "https://github.com/janus-idp/backstage-showcase"
spec:
replicas: 1
selector:
matchLabels:
app: topology-test
template:
metadata:
labels:
app: topology-test
backstage.io/kubernetes-id: developer-hub
spec:
containers:
- name: topology
image: nginxinc/nginx-unprivileged:stable-alpine
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: topology-test-service
labels:
app: topology-test
backstage.io/kubernetes-id: developer-hub
spec:
selector:
app: topology-test
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: topology-test-route
labels:
app: topology-test
backstage.io/kubernetes-id: developer-hub
spec:
to:
kind: Service
name: topology-test-service
port:
targetPort: 8080
wildcardPolicy: None
5 changes: 4 additions & 1 deletion .ibm/pipelines/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ apply_yaml_files() {
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline.yaml"
oc apply -f "$dir/resources/pipeline-run/hello-world-pipeline-run.yaml"

# Create Deployment and Pipeline for Topology test.
oc apply -f "$dir/resources/topology_test/topology-test.yaml"

}

deploy_test_backstage_provider() {
Expand Down Expand Up @@ -542,7 +545,7 @@ run_tests() {
cd "${DIR}/../../e2e-tests"
local e2e_tests_dir
e2e_tests_dir=$(pwd)

yarn install
yarn playwright install chromium

Expand Down
2 changes: 2 additions & 0 deletions .ibm/pipelines/value_files/values_showcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ upstream:
value: 'true'
- name: NODE_OPTIONS
value: '--no-node-snapshot'
- name: NODE_TLS_REJECT_UNAUTHORIZED
value: '0'
extraAppConfig:
- configMapRef: app-config-rhdh
filename: app-config-rhdh.yaml
Expand Down
48 changes: 36 additions & 12 deletions e2e-tests/playwright/e2e/plugins/topology/topology.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@ import { test, expect } from "@playwright/test";
import { Common } from "../../../utils/common";
import { UIhelper } from "../../../utils/ui-helper";
import { Catalog } from "../../../support/pages/catalog";
import { Topology } from "../../../support/pages/topology";

// Test disabled due to comments in JIRA ticket RHIDP-3437
test.describe.skip("Test Topology Plugin", () => {
test.describe("Test Topology Plugin", () => {
let common: Common;
let uiHelper: UIhelper;
let catalog: Catalog;
let topology: Topology;

test.beforeEach(async ({ page }) => {
common = new Common(page);
uiHelper = new UIhelper(page);
catalog = new Catalog(page);
topology = new Topology(page);
await common.loginAsGuest();
});

test("Verify pods visibility in the Topology tab", async ({ page }) => {
test.setTimeout(40000);
await catalog.goToBackstageJanusProject();
await uiHelper.clickTab("Topology");
await uiHelper.verifyText("backstage-janus");
await page.getByRole("button", { name: "Fit to Screen" }).click();
await uiHelper.verifyText("rhdh");
await uiHelper.verifyText("rhdh-rbac");
await uiHelper.verifyButtonURL(
"Open URL",
"https://rhdh-backstage-showcase",
);
await page.locator("image").first().click();
// await uiHelper.verifyText("rhdh");
// await uiHelper.verifyText("rhdh-rbac");
await uiHelper.verifyText("topology-test");
await uiHelper.verifyButtonURL("Open URL", "topology-test-route", {
locator: `[data-test-id="topology-test"]`,
});
await page.locator("[data-test-id=topology-test] image").first().click();
await page.getByLabel("Pod").click();
await page.getByLabel("Pod").getByText("1", { exact: true }).click();
await uiHelper.clickTab("Details");
Expand All @@ -39,7 +40,7 @@ test.describe.skip("Test Topology Plugin", () => {
await uiHelper.verifyHeading("Services");
await uiHelper.verifyHeading("Routes");
await expect(
page.getByRole("link", { name: "https://rhdh-backstage-" }),
page.getByRole("link", { name: "topology-test-route" }),
).toBeVisible();
await expect(page.getByTitle("Deployment")).toBeVisible();
await uiHelper.verifyText("S");
Expand All @@ -51,6 +52,29 @@ test.describe.skip("Test Topology Plugin", () => {
await page.getByLabel("Pod count").click();
await uiHelper.verifyText("1");
await uiHelper.verifyText("Pod");
await page.getByLabel("Pod count").click();
await topology.hoverOnPodStatusIndicator();
await uiHelper.verifyTextInTooltip("Running");
await uiHelper.verifyText("1Running");
await uiHelper.verifyButtonURL(
"Edit source code",
"https://github.com/janus-idp/backstage-showcase",
);
await uiHelper.clickTab("Resources");
await uiHelper.verifyText("P");
expect(await page.getByTestId("icon-with-title-Running")).toBeVisible();
expect(
await page.getByTestId("icon-with-title-Running").locator("svg"),
).toBeVisible();
expect(
await page
.getByTestId("icon-with-title-Running")
.getByTestId("status-text"),
).toHaveText("Running");
await uiHelper.verifyHeading("PipelineRuns");
await uiHelper.verifyText("PL");
await uiHelper.verifyText("PLR");
await page.getByTestId("status-ok").first().click();
await uiHelper.verifyDivHasText("Pipeline SucceededTask");
await uiHelper.verifyText("2 Succeeded");
});
});
17 changes: 17 additions & 0 deletions e2e-tests/playwright/support/pages/topology.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Page } from "@playwright/test";

export class Topology {
private page: Page;

constructor(page: Page) {
this.page = page;
}

async hoverOnPodStatusIndicator() {
await this.page
.locator('[data-test-id="topology-test"]')
.getByText("Pod")
.first()
.hover({});
}
}
28 changes: 23 additions & 5 deletions e2e-tests/playwright/utils/ui-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,24 @@ export class UIhelper {
});
}

async verifyButtonURL(label: string | RegExp, url: string | RegExp) {
const buttonUrl = await this.page
.getByRole("button", { name: label })
.first()
.getAttribute("href");
async verifyButtonURL(
label: string | RegExp,
url: string | RegExp,
options: { locator?: string } = {
locator: "",
},
) {
const buttonUrl =
options.locator == ""
? await this.page
.getByRole("button", { name: label })
.first()
.getAttribute("href")
: await this.page
.locator(options.locator)
.getByRole("button", { name: label })
.first()
.getAttribute("href");
expect(buttonUrl).toContain(url);
}

Expand Down Expand Up @@ -603,4 +616,9 @@ export class UIhelper {
await expect(enabledColumn).toHaveText(expectedEnabled);
await expect(preinstalledColumn).toHaveText(expectedPreinstalled);
}

async verifyTextInTooltip(text: string | RegExp) {
const tooltip = await this.page.getByRole("tooltip").getByText(text);
expect(tooltip).toBeVisible();
}
}

0 comments on commit b91248f

Please sign in to comment.