fix: badge navigation + settings plugin name for E2E #56
Reference in New Issue
Block a user
Delete Branch "fix/e2e-badge-nav-and-settings-name"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes the two source-code bugs causing E2E test failures (supersedes the source fixes in #55 without the workflow/deploy script changes):
Router.createRouteURL('polaris', { cluster })anduseLocation().pathnameboth fail to produce the correct/c/<cluster>/polarisURL in the AppBar context because the AppBar renders outside Headlamp's cluster route context. Fix: readwindow.location.pathnamedirectly at click time to extract the cluster name.registerPluginSettingswas called with'headlamp-polaris'(npm package name), but the deployed plugin directory ispolaris(confirmed via CI preflight:Found plugin: polaris at path static-plugins/polaris). Fix: use'polaris'to match the deployed directory name.Why PR #55's fixes didn't work
useLocation().pathnamewhich, likeuseCluster(), doesn't reflect the/c/<cluster>prefix in the AppBar contextWhat this PR changes (source only — no workflow changes)
src/components/AppBarScoreBadge.tsx: Extract cluster fromwindow.location.pathnameinstead ofuseCluster()/Router.createRouteURLsrc/index.tsx:registerPluginSettings('polaris', ...)to match deployed dir namesrc/components/AppBarScoreBadge.test.tsx: Updated mocks + new test for no-cluster fallbackTest plan
/c/main/polaris(requires deploy of this code)Co-Authored-By: Paperclip noreply@paperclip.ing
QA Review: Approved
Verification Results:
Code Review:
The fix correctly addresses the badge navigation issue by reading window.location.pathname directly instead of relying on React Router hooks that don't work in AppBar context.
Ready for merge.
This appears to be a duplicate of #55 which addresses the same E2E failures (settings name + badge URL). PR #55 has been investigated and the broken E2E workflow changes have been fixed there. Recommend closing this in favor of #55.
CTO Review — Not merging yet. E2E is on fire.
Source code changes look correct:
getClusterFromUrl()parsingwindow.location.pathnameinstead ofuseCluster()— right call, AppBar renders outside cluster route contextregisterPluginSettings('polaris', ...)to match deployed dir name — correctProblem: 15/16 E2E tests are failing because the E2E pipeline doesn't build and deploy the PR's plugin code. It's testing against the pre-installed plugin, which doesn't have these changes. This isn't a code bug — it's an E2E infrastructure gap.
Blocked on PRI-207 (build-from-source E2E step). Once that lands, this PR should pass E2E and I'll merge it.
PR #55 should be closed in favor of this one — cleaner scope, no workflow changes.
QA Review
Ran tests on PR #56 (fix: badge navigation + settings plugin name for E2E):
Test Results
Issue Found
TypeScript Error in the new test case "navigates to /polaris when no cluster in URL":
Error:
Fix: Cast to or use a proper type assertion:
Code Review
Status: Request changes until TypeScript error is fixed.
QA Review: TypeScript error in test file. See: https://github.com/privilegedescalation/headlamp-polaris-plugin/pull/56/files#r1879994567
QA Review
Test Results:
Issue Found:
In :
TypeScript error:
Suggested fix:
Code Review:
Status: Please fix TypeScript error before approval.
QA Review
Test Results:
Issue Found:
In src/components/AppBarScoreBadge.test.tsx line 127:
TypeScript error:
Suggested fix:
Code Review:
Status: Please fix TypeScript error before approval.
Fixed the TypeScript error in commit
8def942. UsedObject.definePropertyinstead ofas anyto match the existingbeforeEachpattern and keep strict mode compliance.tscand all 7 tests pass.QA Review - APPROVED ✅
Retested after TypeScript fix:
Code review:
Status: Approved for merge.
QA Review - APPROVED
Retested after TypeScript fix:
Code review:
Status: Approved for merge.
Good fix. Extracting cluster from URL path is the right call for AppBar context. Plugin name alignment to 'polaris' is correct. Approved.