Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const AGGREGATED_CARDS_METRIC_IDS = {
jiraMetricId: 'jira.open_issues',
githubMetricId: 'github.open_prs',
githubOpenPrsKpi: 'openPrsKpi',
jiraOpenIssuesKpi: 'openIssuesKpi',
gitHubOpenPrsWeightedKpi: 'openPrsWeightedKpi',
} as const;

/** Must match `title` in App.tsx homepage widget config (Add widget picker). */
export const AGGREGATED_CARDS_WIDGET_TITLES = {
jiraMetricId: 'Scorecard: With deprecated metricId property (Jira)',
githubMetricId: 'Scorecard: With default aggregation config (GitHub)',
githubOpenPrsKpi: 'Scorecard: GitHub open PRs',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] naming-convention

Inconsistent casing for the GitHub prefix: githubMetricId and githubOpenPrsKpi use lowercase github, while gitHubOpenPrsWeightedKpi uses camelCase gitHub. Same inconsistency in scorecardResponseUtils.ts.

Suggested fix: Standardize to github (lowercase) prefix across all new identifiers.

jiraOpenIssuesKpi: 'Scorecard: Jira open blocking tickets',
gitHubOpenPrsWeightedKpi: 'Scorecard: GitHub open PRs (weighted health)',
} as const;

export const AGGREGATED_CARDS_METADATA = {
jiraDeprecatedMetricId: {
id: AGGREGATED_CARDS_METRIC_IDS.jiraMetricId,
title: 'Scorecard: With deprecated metricId property (Jira)',
metricId: 'jira.open_issues',
},
githubDefaultAggregation: {
id: AGGREGATED_CARDS_METRIC_IDS.githubMetricId,
title: 'Scorecard: With default aggregation config (GitHub)',
metricId: 'github.open_prs',
},
jiraOpenIssuesKpi: {
id: AGGREGATED_CARDS_METRIC_IDS.jiraOpenIssuesKpi,
title: 'Scorecard: Jira open blocking tickets',
metricId: 'jira.open_issues',
},
githubOpenPrsKpi: {
id: AGGREGATED_CARDS_METRIC_IDS.githubOpenPrsKpi,
title: 'Scorecard: GitHub open PRs',
metricId: 'github.open_prs',
},
githubOpenPrsWeightedKpi: {
id: AGGREGATED_CARDS_METRIC_IDS.gitHubOpenPrsWeightedKpi,
title: 'Scorecard: GitHub open PRs (weighted health)',
metricId: 'github.open_prs',
},
} as const;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Locator, Page, expect } from '@playwright/test';
import { AGGREGATED_CARDS_WIDGET_TITLES } from '../constants/homepageWidgetTitles';
import { AGGREGATED_CARDS_WIDGET_TITLES } from '../constants/aggregations';
import {
ScorecardMessages,
getEntityCount,
Expand Down Expand Up @@ -63,9 +63,7 @@ export class HomePage {
cardPattern = /Scorecard:\s*GitHub open PRs|ScorecardGithubHomepage/i;
} else if (cardName === 'Scorecard: Jira open blocking') {
cardPattern = /Scorecard:\s*Jira open blocking|ScorecardJiraHomepage/i;
} else if (
cardName === AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi
) {
} else if (cardName === AGGREGATED_CARDS_WIDGET_TITLES.openPrsWeightedKpi) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[high] logic-error

Property AGGREGATED_CARDS_WIDGET_TITLES.openPrsWeightedKpi does not exist on the new AGGREGATED_CARDS_WIDGET_TITLES object defined in aggregations.ts. The new object uses key gitHubOpenPrsWeightedKpi. Accessing .openPrsWeightedKpi evaluates to undefined, so the else if branch will never match and the weighted KPI card name will fall through to the generic else branch.

Suggested fix: Change AGGREGATED_CARDS_WIDGET_TITLES.openPrsWeightedKpi to AGGREGATED_CARDS_WIDGET_TITLES.gitHubOpenPrsWeightedKpi.

cardPattern =
/Scorecard:\s*GitHub open PRs \(weighted health\)|ScorecardOpenPrsWeightedKpi/i;
} else {
Expand Down Expand Up @@ -131,18 +129,20 @@ export class HomePage {
}

/**
* Clicks the homepage KPI drill-down link (healthy/total subheader).
* Clicks the homepage KPI drill-down link (healthy/total subheader) within a card.
* Defaults to 10/10 (plain “10 entities” link). Pass overrides when mock `result.total` differs.
*/
async clickDrillDownLink(options?: { healthy?: string; total?: string }) {
async clickDrillDownLink(
card: Locator,
options?: { healthy?: string; total?: string },
) {
const healthy = options?.healthy ?? '10';
const total = options?.total ?? '10';
const name = getHomepageEntityCalculationHealthText(
this.translations,
healthy,
total,
);
// Multiple homepage scorecards can share the same health string; target the first match.
await this.page.getByRole('link', { name }).first().click();
await card.getByRole('link', { name }).click();
}
}
Loading
Loading