-
Notifications
You must be signed in to change notification settings - Fork 115
RHIDP-12121: Support "StatusGrouped" and "Average" types of aggregation #2923
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
bca1a70
36f6193
11f5d25
bcd6186
bed8060
fd15c6c
4e483aa
52f98a5
b0d716c
a87361d
b264e55
f531700
0e94a12
b9dae06
da54b6d
5a3f3e6
ea941a5
ba41570
05cc855
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,8 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-backend': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-common': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard-node': minor | ||
| '@red-hat-developer-hub/backstage-plugin-scorecard': minor | ||
| --- | ||
|
|
||
| Adds `**average**` as an aggregation KPI type alongside `**statusGrouped**`, with configurable `**options.statusScores**` and optional `**options.thresholds**` (same shape as metric thresholds) for homepage donut coloring against `**averageScore × 100**`, with built-in defaults when omitted. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,10 @@ import { | |
| emptyGithubAggregatedResponse, | ||
| emptyJiraAggregatedResponse, | ||
| openPrsKpiMetadataResponse, | ||
| openPrsWeightedAggregatedResponse, | ||
| emptyOpenPrsWeightedAggregatedResponse, | ||
| openPrsWeightedKpiMetadataResponse, | ||
| openPrsWeightedUnsupportedAggregationResponse, | ||
| notAllowedAggregationErrorBody, | ||
| githubEntitiesDrillDownResponse, | ||
| jiraEntitiesDrillDownResponse, | ||
|
|
@@ -58,6 +62,11 @@ import { | |
| mockAllDefaultHomepageAggregationsSuccess, | ||
| mockHomepageAggregationsPermissionDenied, | ||
| } from './utils/mockHomepageAggregations'; | ||
| import { | ||
| expectAverageCardCenterPercent, | ||
| verifyAverageDonutCenterTooltip, | ||
| verifyAverageLegendTooltipForStatus, | ||
| } from './utils/averageCardAssertions'; | ||
| import { runAccessibilityTests } from './utils/accessibility'; | ||
| import { ScorecardRoutes } from './constants/routes'; | ||
| import { | ||
|
|
@@ -83,6 +92,7 @@ async function addAggregatedScorecardWidgets(homePage: HomePage) { | |
| await homePage.addCard(AGGREGATED_CARDS_WIDGET_TITLES.withDefaultAggregation); | ||
| await homePage.addCard(AGGREGATED_CARDS_WIDGET_TITLES.withGithubOpenPrs); | ||
| await homePage.addCard(AGGREGATED_CARDS_WIDGET_TITLES.withJiraOpenIssuesKpi); | ||
| await homePage.addCard(AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi); | ||
|
|
||
| await homePage.saveChanges(); | ||
| } | ||
|
|
@@ -965,5 +975,176 @@ test.describe('Scorecard Plugin Tests', () => { | |
| ); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Average aggregation KPI (openPrsWeightedKpi)', () => { | ||
| test('Verify title and description from API metadata', async () => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| openPrsWeightedAggregatedResponse, | ||
| ); | ||
|
|
||
| await addWidgets( | ||
| homePage, | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await page.reload(); | ||
|
|
||
| const card = homePage.getCard( | ||
| AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| ); | ||
| await expect(card).toBeVisible(); | ||
| await expect(card).toContainText( | ||
| openPrsWeightedKpiMetadataResponse.title, | ||
| ); | ||
| await expect(card).toContainText( | ||
| openPrsWeightedKpiMetadataResponse.description, | ||
| ); | ||
| }); | ||
|
|
||
| test('Verify center score and average tooltips', async () => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| openPrsWeightedAggregatedResponse, | ||
| ); | ||
|
|
||
| await addWidgets( | ||
| homePage, | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await page.reload(); | ||
|
|
||
| const card = homePage.getCard( | ||
| AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| ); | ||
| await expectAverageCardCenterPercent(card, '50%'); | ||
| await verifyAverageDonutCenterTooltip( | ||
| page, | ||
| card, | ||
| translations, | ||
| 500, | ||
| 1000, | ||
| ); | ||
| await verifyAverageLegendTooltipForStatus( | ||
| page, | ||
| card, | ||
| translations, | ||
| currentLocale, | ||
| 'success', | ||
| ); | ||
| }); | ||
|
|
||
| test('Verify empty aggregated response shows no data', async () => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| emptyOpenPrsWeightedAggregatedResponse, | ||
| ); | ||
|
|
||
| await addWidgets( | ||
| homePage, | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await page.reload(); | ||
|
|
||
| await homePage.expectCardHasNoDataFound( | ||
| AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| ); | ||
| }); | ||
|
|
||
| test('Accessibility on weighted average card', async ({ | ||
| browser: _browser, | ||
| }, testInfo) => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| openPrsWeightedAggregatedResponse, | ||
| ); | ||
|
|
||
| await homePage.navigateToHome(); | ||
| await homePage.enterEditMode(); | ||
| await homePage.clearAllCards(); | ||
| await homePage.addCard( | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await homePage.saveChanges(); | ||
| await page.reload(); | ||
|
Member
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. Why is this page.reload needed? Can you please create a bug so that we follow-up. Users should see the right cards and latest data after they save the homepage.
Contributor
Author
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. I will create a bug to follow and resolve all your comments related to e2e tests
Contributor
Author
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. The bug was created - link |
||
|
|
||
| await runAccessibilityTests(page, testInfo); | ||
| }); | ||
|
|
||
| test('GitHub weighted KPI: drill-down, average card, and table', async () => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| openPrsWeightedAggregatedResponse, | ||
| ); | ||
| await mockScorecardEntitiesDrillDownWithSort( | ||
| page, | ||
| githubEntitiesDrillDownResponse, | ||
| 'github.open_prs', | ||
| ); | ||
|
|
||
| await homePage.navigateToHome(); | ||
| await page.reload(); | ||
|
Member
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. Why is this needed? |
||
| await homePage.enterEditMode(); | ||
| await homePage.clearAllCards(); | ||
| await homePage.addCard( | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await homePage.saveChanges(); | ||
|
|
||
| await homePage.clickDrillDownLink(); | ||
| await scorecardDrillDownPage.expectOnPage('github.open_prs', { | ||
| aggregationId: AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| }); | ||
| await scorecardDrillDownPage.expectPageTitle( | ||
| 'github.open_prs', | ||
| openPrsWeightedKpiMetadataResponse.title, | ||
| ); | ||
|
|
||
| const drillCard = scorecardDrillDownPage.getDrillDownCard( | ||
| 'github.open_prs', | ||
| { | ||
| aggregationId: AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| }, | ||
| ); | ||
| await expectAverageCardCenterPercent(drillCard, '50%'); | ||
| await scorecardDrillDownPage.verifySomeEntitiesNotReportingTooltip(); | ||
| await scorecardDrillDownPage.expectTableHeadersVisible(); | ||
| await scorecardDrillDownPage.expectEntityNamesVisible([ | ||
| 'all-scorecards-service', | ||
| 'Red Hat Developer Hub', | ||
| 'github-scorecard-only-service', | ||
| 'all-scorecards-service-different-owner', | ||
| 'backend-api', | ||
| ]); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe('Unsupported aggregation type', () => { | ||
| test('Shows unsupported message when aggregationType is unknown', async () => { | ||
| await mockApiResponse( | ||
| page, | ||
| ScorecardRoutes.OPEN_PRS_WEIGHTED_KPI_AGGREGATION_ROUTE, | ||
| openPrsWeightedUnsupportedAggregationResponse, | ||
| ); | ||
|
|
||
| await addWidgets( | ||
| homePage, | ||
| AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi, | ||
| ); | ||
| await page.reload(); | ||
|
Member
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. Same |
||
|
|
||
| const card = homePage.getCard( | ||
| AGGREGATED_CARDS_METRIC_IDS.withOpenPrsWeightedKpi, | ||
| ); | ||
| await expect(card).toContainText( | ||
| translations.errors.unsupportedAggregationType, | ||
| ); | ||
| await expect(card).toContainText('customUnknownAggregationKind'); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
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.
The other comments: why? Can we follow up ok this with a bug please?