Skip to content

Commit ca1706a

Browse files
committed
refactor(tests): update scorecard tests to use new aggregation constants and improve widget handling
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
1 parent 6845168 commit ca1706a

7 files changed

Lines changed: 439 additions & 464 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export const AGGREGATED_CARDS_METRIC_IDS = {
18+
jiraMetricId: 'jira.open_issues',
19+
githubMetricId: 'github.open_prs',
20+
githubOpenPrsKpi: 'openPrsKpi',
21+
jiraOpenIssuesKpi: 'openIssuesKpi',
22+
openPrsWeightedKpi: 'openPrsWeightedKpi',
23+
} as const;
24+
25+
/** Must match `title` in App.tsx homepage widget config (Add widget picker). */
26+
export const AGGREGATED_CARDS_WIDGET_TITLES = {
27+
jiraMetricId: 'Scorecard: With deprecated metricId property (Jira)',
28+
githubMetricId: 'Scorecard: With default aggregation config (GitHub)',
29+
githubOpenPrsKpi: 'Scorecard: GitHub open PRs',
30+
jiraOpenIssuesKpi: 'Scorecard: Jira open blocking tickets',
31+
openPrsWeightedKpi: 'Scorecard: GitHub open PRs (weighted health)',
32+
} as const;
33+
34+
export const AGGREGATED_CARDS_METADATA = {
35+
deprecatedMetricId: {
36+
id: AGGREGATED_CARDS_METRIC_IDS.jiraMetricId,
37+
title: 'Scorecard: With deprecated metricId property (Jira)',
38+
metricId: 'jira.open_issues',
39+
},
40+
defaultAggregation: {
41+
id: AGGREGATED_CARDS_METRIC_IDS.githubMetricId,
42+
title: 'Scorecard: With default aggregation config (GitHub)',
43+
metricId: 'github.open_prs',
44+
},
45+
jiraOpenIssuesKpi: {
46+
id: AGGREGATED_CARDS_METRIC_IDS.jiraOpenIssuesKpi,
47+
title: 'Scorecard: Jira open blocking tickets',
48+
metricId: 'jira.open_issues',
49+
},
50+
githubOpenPrsKpi: {
51+
id: AGGREGATED_CARDS_METRIC_IDS.githubOpenPrsKpi,
52+
title: 'Scorecard: GitHub open PRs',
53+
metricId: 'github.open_prs',
54+
},
55+
openPrsWeightedKpi: {
56+
id: AGGREGATED_CARDS_METRIC_IDS.openPrsWeightedKpi,
57+
title: 'Scorecard: GitHub open PRs (weighted health)',
58+
metricId: 'github.open_prs',
59+
},
60+
} as const;

workspaces/scorecard/packages/app-legacy/e2e-tests/constants/homepageWidgetTitles.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

workspaces/scorecard/packages/app-legacy/e2e-tests/pages/HomePage.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { Locator, Page, expect } from '@playwright/test';
18-
import { AGGREGATED_CARDS_WIDGET_TITLES } from '../constants/homepageWidgetTitles';
18+
import { AGGREGATED_CARDS_WIDGET_TITLES } from '../constants/aggregations';
1919
import {
2020
ScorecardMessages,
2121
getEntityCount,
@@ -63,9 +63,7 @@ export class HomePage {
6363
cardPattern = /Scorecard:\s*GitHub open PRs|ScorecardGithubHomepage/i;
6464
} else if (cardName === 'Scorecard: Jira open blocking') {
6565
cardPattern = /Scorecard:\s*Jira open blocking|ScorecardJiraHomepage/i;
66-
} else if (
67-
cardName === AGGREGATED_CARDS_WIDGET_TITLES.withOpenPrsWeightedKpi
68-
) {
66+
} else if (cardName === AGGREGATED_CARDS_WIDGET_TITLES.openPrsWeightedKpi) {
6967
cardPattern =
7068
/Scorecard:\s*GitHub open PRs \(weighted health\)|ScorecardOpenPrsWeightedKpi/i;
7169
} else {

0 commit comments

Comments
 (0)