RHDHBUGS-3057: Refactor e2e tests for the scorecard plugin#3245
RHDHBUGS-3057: Refactor e2e tests for the scorecard plugin#3245imykhno wants to merge 3 commits into
Conversation
…functions Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
Code Review by Qodo
1.
|
Changed Packages
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3245 +/- ##
=======================================
Coverage 53.23% 53.23%
=======================================
Files 2413 2413
Lines 86358 86358
Branches 23912 23913 +1
=======================================
Hits 45974 45974
Misses 38907 38907
Partials 1477 1477
*This pull request uses carry forward flags. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…nts and improve widget handling Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
Review Summary by QodoRefactor scorecard e2e tests with aggregation utilities and improved test structure
WalkthroughsDescription• Refactored e2e test structure with new aggregation constants and utility functions • Reorganized constants from homepageWidgetTitles.ts to aggregations.ts with improved naming • Extracted common test setup logic into reusable homepageWidgetUtils.ts helper functions • Enhanced API utilities with aggregation response waiting and validation capabilities • Improved test organization by grouping related aggregation tests with shared setup Diagramflowchart LR
A["Old Constants<br/>homepageWidgetTitles.ts"] -->|Migrate & Rename| B["New Constants<br/>aggregations.ts"]
C["Scattered Test Setup<br/>Code"] -->|Extract| D["Utility Functions<br/>homepageWidgetUtils.ts"]
E["Basic API Utils<br/>apiUtils.ts"] -->|Enhance| F["Aggregation Response<br/>Waiting & Validation"]
B --> G["Cleaner Test Code<br/>scorecard.test.ts"]
D --> G
F --> G
File Changes1. workspaces/scorecard/packages/app-legacy/e2e-tests/constants/aggregations.ts
|
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
ca1706a to
1d79f52
Compare
|
|
/publish |
|
/fs-review |
2 similar comments
|
/fs-review |
|
/fs-review |
ReviewFindingsHigh
Medium
Low
Info
|
| }); | ||
| } | ||
|
|
||
| export async function mockAggregationNoDataFound(page: Page): Promise<void> { |
There was a problem hiding this comment.
[high] logic-error
mockAggregationNoDataFound intercepts /api/scorecard/aggregations/ which matches metadata URLs. For metadata URLs, url.split('/').pop() returns 'metadata' which doesn't match any aggregation ID, falling through to the 404 branch. Card titles/descriptions fail to load, producing an error UI instead of the intended 'no data found' state. The existing mockHomepageAggregationsPermissionDenied correctly handles this by checking url.includes('/metadata').
Suggested fix: Add a metadata check at the top of the route handler: if url.includes('/metadata'), return 200 with the appropriate metadata response using the existing aggregationMetadataForRequestUrl helper.
| function isAggregationDataUrl(url: string, aggregationId: string): boolean { | ||
| return ( | ||
| url.includes(`/api/scorecard/aggregations/${aggregationId}`) && | ||
| !url.includes('/metadata') |
There was a problem hiding this comment.
[low] edge-case
isAggregationDataUrl uses url.split('/').pop() which would include query parameters if present, causing match failures.
| response: object; | ||
| status?: number; | ||
| }; | ||
|
|
There was a problem hiding this comment.
[low] naming-convention
addWidgets is exported but only used internally by setupHomepageAggregationCard within the same file. Consider removing the export.



Hey, I just made a Pull Request!
This refactoring follows the merge of #2923. The expectation was that tests will be reviewed and added those tests that are missing to test scorecard aggregation card customization. Additionally, this PR incorporates the feedback and comments raised during the review of #2923.
PR is for:
✔️ Checklist