Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): [Test automation] Verify Topology is a supported plugin and E2E scenario follow-up #2106

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .ibm/pipelines/resources/topology_test/topology-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
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
taskRef:
kind: ClusterTask
name: openshift-client
---
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
3 changes: 3 additions & 0 deletions .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
41 changes: 31 additions & 10 deletions e2e-tests/playwright/e2e/plugins/topology/topology.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Common } from "../../../utils/common";
import { UIhelper } from "../../../utils/ui-helper";
import { Catalog } from "../../../support/pages/catalog";

// 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;
Expand All @@ -17,18 +16,17 @@ test.describe.skip("Test Topology Plugin", () => {
});

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("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 +37,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 +49,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 uiHelper.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("icon-only-Succeeded").hover();
await uiHelper.verifyDivHasText("Pipeline SucceededTask");
await uiHelper.verifyText("1 Succeeded");
});
});
36 changes: 31 additions & 5 deletions e2e-tests/playwright/utils/ui-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,27 @@ 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);
}
// locator('[data-test-id="topology-test"]').getByRole('button', { name: 'Open URL' })

/**
* Verifies that a table row, identified by unique text, contains specific cell texts.
Expand Down Expand Up @@ -585,4 +599,16 @@ export class UIhelper {
await expect(enabledColumn).toHaveText(expectedEnabled);
await expect(preinstalledColumn).toHaveText(expectedPreinstalled);
}

async hoverOnPodStatusIndicator() {
await this.page
.locator('[data-test-id="topology-test"]')
.getByText("Pod")
.hover({});
}

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