From 0bedbf57892a7b516f8498c2e34420567a5b179f Mon Sep 17 00:00:00 2001 From: "gandalf-the-greybeard[bot]" Date: Sun, 15 Mar 2026 18:17:51 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=206=20E2E=20failures=20=E2=80=94?= =?UTF-8?q?=20cluster=20URL=20prefix=20+=20settings=20registration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/components/AppBarScoreBadge.test.tsx | 6 +++++- src/components/AppBarScoreBadge.tsx | 5 +++-- src/index.tsx | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/AppBarScoreBadge.test.tsx b/src/components/AppBarScoreBadge.test.tsx index 6285507..75616ca 100644 --- a/src/components/AppBarScoreBadge.test.tsx +++ b/src/components/AppBarScoreBadge.test.tsx @@ -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}`, }, })); diff --git a/src/components/AppBarScoreBadge.tsx b/src/components/AppBarScoreBadge.tsx index 8f34f77..02b6bbb 100644 --- a/src/components/AppBarScoreBadge.tsx +++ b/src/components/AppBarScoreBadge.tsx @@ -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 ( diff --git a/src/index.tsx b/src/index.tsx index e5d068f..5a90bbe 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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 }) => { -- 2.52.0