1616
1717import { test , expect } from '@playwright/test' ;
1818import { mockScorecardResponse } from './utils/apiUtils' ;
19- import { ComponentImportPage } from './pages/ComponentImportPage' ;
2019import { CatalogPage } from './pages/CatalogPage' ;
2120import { ScorecardPage } from './pages/ScorecardPage' ;
2221import { setupRBAC } from './utils/rbacSetup' ;
@@ -26,89 +25,115 @@ import {
2625 unavailableMetricResponse ,
2726 invalidThresholdResponse ,
2827} from './utils/scorecardResponseUtils' ;
28+ import {
29+ ScorecardMessages ,
30+ evaluateMessage ,
31+ getTranslations ,
32+ } from './utils/translationUtils' ;
33+ import { runAccessibilityTests } from './utils/accessibility' ;
2934
3035test . describe . serial ( 'Pre-RBAC Access Tests' , ( ) => {
36+ let translations : ScorecardMessages ;
37+ let currentLocale : string ;
38+
39+ test . beforeAll ( async ( { browser } ) => {
40+ const context = await browser . newContext ( ) ;
41+ const page = await context . newPage ( ) ;
42+ currentLocale = await page . evaluate ( ( ) => globalThis . navigator . language ) ;
43+ translations = getTranslations ( currentLocale ) ;
44+ await context . close ( ) ;
45+ } ) ;
46+
3147 test ( 'Display access denied message when RBAC is not configured' , async ( {
3248 page,
33- } ) => {
49+ } , testInfo ) => {
3450 const catalogPage = new CatalogPage ( page ) ;
3551 await page . goto ( '/' ) ;
36- await catalogPage . navigateToCatalog ( ) ;
52+ await catalogPage . navigateToCatalog ( currentLocale ) ;
3753 await catalogPage . openComponent ( 'Red Hat Developer Hub' ) ;
3854 await page . getByText ( 'Scorecard' ) . click ( ) ;
3955
40- await expect ( page . getByText ( 'Missing permission' ) ) . toBeVisible ( ) ;
56+ await expect (
57+ page . getByText ( translations . permissionRequired . title ) ,
58+ ) . toBeVisible ( ) ;
4159 await expect ( page . getByRole ( 'article' ) ) . toContainText (
42- 'To view Scorecard plugin, contact your administrator to give the scorecard.metric.read permission.' ,
60+ evaluateMessage (
61+ translations . permissionRequired . description ,
62+ 'scorecard.metric.read' ,
63+ ) ,
4364 ) ;
65+
66+ await runAccessibilityTests ( page , testInfo ) ;
4467 } ) ;
4568} ) ;
4669
4770test . describe . serial ( 'Scorecard Plugin Tests' , ( ) => {
4871 let catalogPage : CatalogPage ;
49- let importPage : ComponentImportPage ;
5072 let scorecardPage : ScorecardPage ;
73+ let translations : ScorecardMessages ;
74+ let currentLocale : string ;
5175
5276 test . beforeAll ( async ( { browser } ) => {
5377 const context = await browser . newContext ( ) ;
5478 const page = await context . newPage ( ) ;
5579
5680 await setupRBAC ( page ) ;
5781
82+ currentLocale = await page . evaluate ( ( ) => globalThis . navigator . language ) ;
83+ translations = getTranslations ( currentLocale ) ;
84+
5885 await context . close ( ) ;
5986 } ) ;
6087
6188 test . beforeEach ( async ( { page } ) => {
6289 catalogPage = new CatalogPage ( page ) ;
63- importPage = new ComponentImportPage ( page ) ;
64- scorecardPage = new ScorecardPage ( page ) ;
90+ scorecardPage = new ScorecardPage ( page , translations ) ;
6591 } ) ;
6692
67- test ( 'Import component and validate scorecard tabs for GitHub PRs and Jira tickets' , async ( {
93+ test ( 'Validate scorecard tabs for GitHub PRs and Jira tickets' , async ( {
6894 page,
69- } ) => {
95+ } , testInfo ) => {
7096 await mockScorecardResponse ( page , customScorecardResponse ) ;
7197
7298 await page . goto ( '/' ) ;
73- await catalogPage . navigateToCatalog ( ) ;
74- await importPage . startComponentImport ( ) ;
75- await importPage . analyzeComponent (
76- 'https://github.com/rhdh-pai-qe/backstage-catalog/blob/main/catalog-info.yaml' ,
77- ) ;
78- await importPage . viewImportedComponent ( ) ;
99+ await catalogPage . navigateToCatalog ( currentLocale ) ;
100+ await catalogPage . openComponent ( 'Red Hat Developer Hub' ) ;
79101 await scorecardPage . openTab ( ) ;
80-
81102 await scorecardPage . verifyScorecardValues ( {
82- 'GitHub open PRs' : '9' ,
83- 'Jira open blocking tickets' : '8' ,
103+ [ translations . metric [ 'github.open_prs' ] . title ] : '9' ,
104+ [ translations . metric [ 'jira.open_issues' ] . title ] : '8' ,
84105 } ) ;
85106
86107 for ( const metric of scorecardPage . scorecardMetrics ) {
87108 await scorecardPage . validateScorecardAriaFor ( metric ) ;
88109 }
110+
111+ await runAccessibilityTests ( page , testInfo ) ;
89112 } ) ;
90113
91114 test ( 'Display empty state when scorecard API returns no metrics' , async ( {
92115 page,
93- } ) => {
116+ } , testInfo ) => {
94117 await mockScorecardResponse ( page , emptyScorecardResponse ) ;
95118
96119 await page . goto ( '/' ) ;
97- await catalogPage . navigateToCatalog ( ) ;
98- await catalogPage . openComponent ( 'rhdh-app ' ) ;
120+ await catalogPage . navigateToCatalog ( currentLocale ) ;
121+ await catalogPage . openComponent ( 'Red Hat Developer Hub ' ) ;
99122 await scorecardPage . openTab ( ) ;
100123
101124 await scorecardPage . expectEmptyState ( ) ;
125+
126+ await runAccessibilityTests ( page , testInfo ) ;
102127 } ) ;
103128
104129 test ( 'Displays error state for unavailable data while rendering metrics' , async ( {
105130 page,
106- } ) => {
131+ } , testInfo ) => {
107132 await mockScorecardResponse ( page , unavailableMetricResponse ) ;
108133
109134 await page . goto ( '/' ) ;
110- await catalogPage . navigateToCatalog ( ) ;
111- await catalogPage . openComponent ( 'rhdh-app ' ) ;
135+ await catalogPage . navigateToCatalog ( currentLocale ) ;
136+ await catalogPage . openComponent ( 'Red Hat Developer Hub ' ) ;
112137 await scorecardPage . openTab ( ) ;
113138
114139 const jiraMetric = scorecardPage . scorecardMetrics [ 1 ] ;
@@ -125,9 +150,10 @@ test.describe.serial('Scorecard Plugin Tests', () => {
125150 expect ( isGithubVisible ) . toBe ( true ) ;
126151
127152 const errorLocator = page . getByRole ( 'heading' , {
128- name : 'Metric data unavailable' ,
153+ name : translations . errors . metricDataUnavailable ,
129154 } ) ;
130155 await expect ( errorLocator ) . toBeVisible ( ) ;
156+ await runAccessibilityTests ( page , testInfo ) ;
131157
132158 await errorLocator . hover ( ) ;
133159 const errorMetric = unavailableMetricResponse . find (
@@ -145,12 +171,12 @@ test.describe.serial('Scorecard Plugin Tests', () => {
145171
146172 test ( 'Display error state for invalid threshold config while rendering metrics' , async ( {
147173 page,
148- } ) => {
174+ } , testInfo ) => {
149175 await mockScorecardResponse ( page , invalidThresholdResponse ) ;
150176
151177 await page . goto ( '/' ) ;
152- await catalogPage . navigateToCatalog ( ) ;
153- await catalogPage . openComponent ( 'rhdh-app ' ) ;
178+ await catalogPage . navigateToCatalog ( currentLocale ) ;
179+ await catalogPage . openComponent ( 'Red Hat Developer Hub ' ) ;
154180 await scorecardPage . openTab ( ) ;
155181
156182 const githubMetric = scorecardPage . scorecardMetrics [ 0 ] ;
@@ -167,9 +193,10 @@ test.describe.serial('Scorecard Plugin Tests', () => {
167193 expect ( isJiraVisible ) . toBe ( true ) ;
168194
169195 const errorLocator = page . getByRole ( 'heading' , {
170- name : 'Invalid thresholds' ,
196+ name : translations . errors . invalidThresholds ,
171197 } ) ;
172198 await expect ( errorLocator ) . toBeVisible ( ) ;
199+ await runAccessibilityTests ( page , testInfo ) ;
173200
174201 await errorLocator . hover ( ) ;
175202 const errorTooltip = invalidThresholdResponse . find (
0 commit comments