-
Notifications
You must be signed in to change notification settings - Fork 109
RHDHBUGS-3057: Refactor e2e tests for the scorecard plugin #3245
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
Changes from all commits
6845168
5283834
1d79f52
1cdddb3
0e82b1e
78d6614
ffe1cd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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', | ||
| 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 |
|---|---|---|
|
|
@@ -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, | ||
|
|
@@ -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) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
|
@@ -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(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.