fix: resolve 6 E2E failures — cluster URL prefix + settings registration

Two root causes for the remaining 6 E2E failures after PR #50:

1. AppBarScoreBadge: Router.createRouteURL('polaris') was called without
   the cluster parameter, producing '/polaris' instead of '/c/main/polaris'.
   Now uses K8s.useCluster() to pass the active cluster. (appbar.spec.ts:18)

2. Plugin settings: registerPluginSettings was called with 'polaris' but
   the package.json name is 'headlamp-polaris'. Headlamp matches settings
   registrations to the package name, so the component never rendered.
   (settings.spec.ts — all 5 tests)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
gandalf-the-greybeard[bot]
2026-03-15 18:17:51 +00:00
parent fb3d262eb7
commit 0bedbf5789
3 changed files with 9 additions and 4 deletions
+5 -1
View File
@@ -7,8 +7,12 @@ import { makeAuditData, makeResult } from '../test-utils';
// Mock Headlamp lib
vi.mock('@kinvolk/headlamp-plugin/lib', () => ({
ApiProxy: { request: vi.fn() },
K8s: {
useCluster: () => 'test-cluster',
},
Router: {
createRouteURL: (name: string) => `/c/test-cluster/${name}`,
createRouteURL: (name: string, params?: { cluster?: string }) =>
`/c/${params?.cluster ?? 'default'}/${name}`,
},
}));
+3 -2
View File
@@ -1,4 +1,4 @@
import { Router } from '@kinvolk/headlamp-plugin/lib';
import { K8s, Router } from '@kinvolk/headlamp-plugin/lib';
import { useTheme } from '@mui/material/styles';
import React from 'react';
import { useHistory } from 'react-router-dom';
@@ -13,6 +13,7 @@ export default function AppBarScoreBadge() {
const theme = useTheme();
const { data, loading } = usePolarisDataContext();
const history = useHistory();
const cluster = K8s.useCluster();
if (loading || !data) {
return null; // Graceful degradation when Polaris unavailable
@@ -35,7 +36,7 @@ export default function AppBarScoreBadge() {
};
const handleClick = () => {
history.push(Router.createRouteURL('polaris'));
history.push(Router.createRouteURL('polaris', { cluster: cluster ?? '' }));
};
return (
+1 -1
View File
@@ -99,7 +99,7 @@ registerRoute({
});
// Register plugin settings
registerPluginSettings('polaris', PolarisSettings, true);
registerPluginSettings('headlamp-polaris', PolarisSettings, true);
// Register details view section for supported controller types
registerDetailsViewSection(({ resource }) => {