Skip to content
Open
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
1 change: 1 addition & 0 deletions .ibm/pipelines/auth/secrets-rhdh-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ data:
GITHUB_OAUTH_APP_ID: $GITHUB_OAUTH_APP_ID_ENCODED
GITHUB_OAUTH_APP_SECRET: $GITHUB_OAUTH_APP_SECRET_ENCODED
BACKEND_SECRET: $BACKEND_SECRET
JIRA_TOKEN: $JIRA_TOKEN
type: Opaque
1 change: 1 addition & 0 deletions .ibm/pipelines/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ QE_USER8_ID=$(cat /tmp/secrets/QE_USER8_ID)
QE_USER8_PASS=$(cat /tmp/secrets/QE_USER8_PASS)
QE_USER9_ID=$(cat /tmp/secrets/QE_USER9_ID)
QE_USER9_PASS=$(cat /tmp/secrets/QE_USER9_PASS)
JIRA_TOKEN=$(cat /tmp/secrets/jira_token)

K8S_CLUSTER_TOKEN_TEMPORARY=$(cat /tmp/secrets/K8S_CLUSTER_TOKEN_TEMPORARY)

Expand Down
26 changes: 14 additions & 12 deletions .ibm/pipelines/value_files/values_showcase-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,39 +94,41 @@ global:
- package: ./dynamic-plugins/dist/backstage-community-plugin-analytics-provider-segment
disabled: true
#Enable Scorecard plugin.
- disabled: false
package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard:pr_1499__0.1.0!red-hat-developer-hub-backstage-plugin-scorecard
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard:bs_1.42.5__1.0.0!red-hat-developer-hub-backstage-plugin-scorecard
disabled: false
pluginConfig:
dynamicPlugins:
frontend:
red-hat-developer-hub.backstage-plugin-scorecard:
entityTabs:
- path: "/scorecard"
title: Scorecard
titleKey: catalog.entityPage.scorecard.title
mountPoint: entity.page.scorecard
mountPoints:
- mountPoint: entity.page.scorecard/cards
importName: EntityScorecardContent
config:
layout:
gridColumn: 1 / -1
- disabled: false
package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend:pr_1499__0.1.0!red-hat-developer-hub-backstage-plugin-scorecard-backend
- disabled: false
package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend-module-github:pr_1499__0.1.0!red-hat-developer-hub-backstage-plugin-scorecard-backend-module-github
if:
allOf:
- isKind: component
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend:bs_1.42.5__1.0.0!red-hat-developer-hub-backstage-plugin-scorecard-backend
disabled: false
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend-module-github:bs_1.42.5__1.0.0!red-hat-developer-hub-backstage-plugin-scorecard-backend-module-github
pluginConfig:
integrations:
github:
- host: github.com
token: "{gh-token}"
- disabled: false
package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend-module-jira:pr_1499__0.1.0!red-hat-developer-hub-backstage-plugin-scorecard-backend-module-jira
disabled: false
- package: oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-scorecard-backend-module-jira:pr_1499__0.1.0!red-hat-developer-hub-backstage-plugin-scorecard-backend-module-jira
pluginConfig:
jira:
baseUrl: "{jira-base-url}"
token: "{jira-api-token}"
product: datacenter
baseUrl: https://redhat-team-f703ynt3.atlassian.net
token: ${JIRA_TOKEN}
product: cloud
disabled: false
# Enable orchestrator plugins - Official release (Backstage 1.42.5)
- package: "oci://ghcr.io/redhat-developer/rhdh-plugin-export-overlays/red-hat-developer-hub-backstage-plugin-orchestrator:bs_1.42.5__5.1.0!red-hat-developer-hub-backstage-plugin-orchestrator"
disabled: false
Expand Down
118 changes: 71 additions & 47 deletions e2e-tests/playwright/e2e/plugins/scorecard/scorecard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@

import { test, expect } from "@playwright/test";
import { Common } from "../../../utils/common";
import { mockScorecardResponse } from "../../../utils/scorecard-utils";
import { ComponentImportPage } from "../../../support/page-objects/scorecard/component-import-page";
import { Catalog } from "../../../support/pages/catalog";
import { ScorecardPage } from "../../../support/page-objects/scorecard/scorecard-page";
import {
CUSTOM_SCORECARD_RESPONSE,
EMPTY_SCORECARD_RESPONSE,
UNAVAILABLE_METRIC_RESPONSE,
INVALID_THRESHOLD_RESPONSE,
} from "../../../utils/scorecard-response-utils";

test.describe.serial("Scorecard Plugin Tests", () => {
let context;
Expand Down Expand Up @@ -53,42 +46,33 @@ test.describe.serial("Scorecard Plugin Tests", () => {
});

test("Import component and validate scorecard tabs for GitHub PRs and Jira tickets", async () => {
await mockScorecardResponse(page, CUSTOM_SCORECARD_RESPONSE);

await catalog.go();
await importPage.startComponentImport();
await importPage.analyzeComponent(
"https://github.com/rhdh-pai-qe/backstage-catalog/blob/main/catalog-info.yaml",
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/all-scorecards.yaml",
catalog,
scorecardPage,
);
await importPage.viewImportedComponent();
await scorecardPage.openTab();

await scorecardPage.verifyScorecardValues({
"GitHub open PRs": "9",
"Jira open blocking tickets": "8",
});

for (const metric of scorecardPage.scorecardMetrics) {
await scorecardPage.validateScorecardAriaFor(metric);
}
});

test("Display empty state when scorecard API returns no metrics", async () => {
await mockScorecardResponse(page, EMPTY_SCORECARD_RESPONSE);

await catalog.go();
await catalog.goToByName("rhdh-app");
await scorecardPage.openTab();
test("Validate empty scorecard state", async () => {
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/no-scorecards.yaml",
catalog,
scorecardPage,
);

await scorecardPage.expectEmptyState();
});

test("Displays error state for unavailable data while rendering metrics", async () => {
await mockScorecardResponse(page, UNAVAILABLE_METRIC_RESPONSE);

await catalog.go();
await catalog.goToByName("rhdh-app");
await scorecardPage.openTab();
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/metrics-unavailable.yaml",
catalog,
scorecardPage,
);

const jiraMetric = scorecardPage.scorecardMetrics[1];
const githubMetric = scorecardPage.scorecardMetrics[0];
Expand All @@ -109,22 +93,19 @@ test.describe.serial("Scorecard Plugin Tests", () => {
await expect(errorLocator).toBeVisible();

await errorLocator.hover();
const errorTooltip = UNAVAILABLE_METRIC_RESPONSE.find(
(metric) => metric.id === "github.open-prs",
)?.error;

expect(errorTooltip).toBeTruthy();
await expect(page.getByText(errorTooltip!)).toBeVisible();
const errorTooltip =
"GraphqlResponseError: Request failed due to following response errors: - Could not resolve to a Repository with the name 'dzemanov/react-app-t1'.";
await expect(page.getByText(errorTooltip)).toBeVisible();

await scorecardPage.validateScorecardAriaFor(jiraMetric);
});

test("Display error state for invalid threshold config while rendering metrics", async () => {
await mockScorecardResponse(page, INVALID_THRESHOLD_RESPONSE);

await catalog.go();
await catalog.goToByName("rhdh-app");
await scorecardPage.openTab();
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/invalid-threshold.yaml",
catalog,
scorecardPage,
);

const githubMetric = scorecardPage.scorecardMetrics[0];
const jiraMetric = scorecardPage.scorecardMetrics[1];
Expand All @@ -145,12 +126,55 @@ test.describe.serial("Scorecard Plugin Tests", () => {
await expect(errorLocator).toBeVisible();

await errorLocator.hover();
const errorTooltip = INVALID_THRESHOLD_RESPONSE.find(
(metric) => metric.id === "github.open-prs",
)?.result?.thresholdResult?.error;
const errorTooltip =
"ThresholdConfigFormatError: Invalid threshold annotation 'scorecard.io/github.open_prs.thresholds.rules.error: >50d' in entity 'component:default/invalid-threshold': Cannot parse \"50d\" as number from expression: \">50d\"";
await expect(page.getByText(errorTooltip)).toBeVisible();

await scorecardPage.validateScorecardAriaFor(jiraMetric);
});

test("Validate only GitHub scorecard is displayed", async () => {
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/github-scorecard-only.yaml",
catalog,
scorecardPage,
);

const githubMetric = scorecardPage.scorecardMetrics[0];
const jiraMetric = scorecardPage.scorecardMetrics[1];

const isGithubVisible = await scorecardPage.isScorecardVisible(
githubMetric.title,
);
expect(isGithubVisible).toBe(true);

const isJiraVisible = await scorecardPage.isScorecardVisible(
jiraMetric.title,
);
expect(isJiraVisible).toBe(false);

expect(errorTooltip).toBeTruthy();
await expect(page.getByText(errorTooltip!)).toBeVisible();
await scorecardPage.validateScorecardAriaFor(githubMetric);
});

test("Validate only Jira scorecard is displayed", async () => {
await importPage.importAndOpenScorecard(
"https://github.com/rhdh-pai-qe/RHDH-scorecard-plugin-test/blob/main/jira-scorecard-only.yaml",
catalog,
scorecardPage,
);

const githubMetric = scorecardPage.scorecardMetrics[0];
const jiraMetric = scorecardPage.scorecardMetrics[1];

const isGithubVisible = await scorecardPage.isScorecardVisible(
githubMetric.title,
);
expect(isGithubVisible).toBe(false);

const isJiraVisible = await scorecardPage.isScorecardVisible(
jiraMetric.title,
);
expect(isJiraVisible).toBe(true);

await scorecardPage.validateScorecardAriaFor(jiraMetric);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
import { Page } from "@playwright/test";
import { UIhelper } from "../../../utils/ui-helper";
import { Catalog } from "../../../support/pages/catalog";
import { ScorecardPage } from "./scorecard-page";

export class ComponentImportPage {
readonly page: Page;
Expand All @@ -34,12 +36,29 @@ export class ComponentImportPage {
await this.uiHelper.fillTextInputByLabel("URL", url);
await this.uiHelper.clickButton("Analyze");
await this.uiHelper.clickButton("Import");
//wait for few seconds
await this.page.waitForTimeout(5000);
}

async viewImportedComponent() {
await this.uiHelper.clickButton("View Component");
const entityNotFoundLocator = this.page.getByRole("button", {
name: "Warning: Entity not found",
});
if (await entityNotFoundLocator.isVisible({ timeout: 10000 })) {
await this.page.reload();
}
await this.uiHelper.verifyText("Overview");
}

async importAndOpenScorecard(
url: string,
catalog: Catalog,
scorecardPage: ScorecardPage,
) {
await catalog.go();
await this.startComponentImport();
await this.analyzeComponent(url);
await this.viewImportedComponent();
await scorecardPage.openTab();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { Page, expect } from "@playwright/test";
import { waitUntilApiCallSucceeds } from "../../../utils/scorecard-utils";

export class ScorecardPage {
readonly page: Page;
Expand All @@ -34,25 +33,15 @@ export class ScorecardPage {
{
title: "Jira open blocking tickets",
description:
"Highlights the number of critical, blocking issues that are currently open in Jira.",
"Highlights the number of issues that are currently open in Jira.",
},
];
}

async openTab() {
const scorecardTab = this.page.getByText("Scorecard");
const scorecardTab = this.page.getByText("Scorecard", { exact: true });
await expect(scorecardTab).toBeVisible();
await Promise.all([
waitUntilApiCallSucceeds(this.page),
scorecardTab.click(),
]);
}

async verifyScorecardValues(expectedValues: { [key: string]: string }) {
for (const [metric, value] of Object.entries(expectedValues)) {
await expect(this.page.getByText(metric)).toBeVisible();
await expect(this.page.getByText(value)).toBeVisible();
}
await scorecardTab.click();
}

async expectEmptyState() {
Expand All @@ -79,9 +68,9 @@ export class ScorecardPage {
- article:
- text: ${title}
- paragraph: ${description}
- paragraph: /Error/
- paragraph: /Warning/
- paragraph: /Success/
- paragraph: /Warning/
- paragraph: /Error/
`);
}

Expand Down
Loading
Loading