fix: render heading immediately in MetricsPage before ctxLoading resolves #43
Reference in New Issue
Block a user
Delete Branch "fix/metrics-heading-renders-immediately"
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
Fix E2E navigation test failure where the heading was never found within 15s timeout when navigating directly to
/c/main/intel-gpu/metrics.Root cause: The
SectionHeaderwas blocked behind thectxLoadingcheck in MetricsPage. When navigating directly to the metrics route (vs via sidebar), theK8s.ResourceClasses.useList()hooks inIntelGpuDataContextcan take time to resolve, causingctxLoadingto remaintruebeyond the test timeout.Fix: Move
SectionHeaderoutside the loading check so it renders immediately. TheLoadernow appears below the heading while waiting for context. Also disabled theRefreshbutton duringctxLoading.Changes
src/components/MetricsPage.tsx: Moved heading before loading check, added disabled/opacity styling to Refresh button during ctxLoadingsrc/components/MetricsPage.test.tsx: Updated test to verify heading is visible even when ctxLoading=trueTesting
navigation between plugin views worksshould now pass (specifically the/metricsstep)Fixes: headlamp-intel-gpu-plugin#42
cc @cpfarhood
QA Code Review — PR #43 (fix/metrics-heading-renders-immediately)
Status: Code review PASSES — pending CI pass + E2E validation from Patty
Local verification
vite-plugin-svgr/client/vite/clientmissing type definitions present onmain) ✅Root cause analysis
The fix correctly addresses the issue. The original early-return pattern
if (ctxLoading) { return <Loader> }prevented theSectionHeaderfrom rendering untilK8s.ResourceClasses.useList()hooks resolved inIntelGpuDataContext. On direct navigation to/metrics, this could exceed the 15s E2E timeout.Change-by-change review
MetricsPage.tsx— heading moved outside ctxLoading guard ✅SectionHeader title="Intel GPU — Metrics"now renders unconditionally. Correct fix.{ctxLoading && <Loader title="Loading Intel GPU data..." />}moved below the header section. The loader still appears while waiting for context — UX is preserved.disabled={fetching || ctxLoading}— prevents spurious fetches during loading. Correct.opacity: 0.6+cursor: not-allowedwhen disabled. Good UX, uses CSS variables where appropriate.Behavioral change note (non-blocking):
MetricRequirementsnow renders duringctxLoading=true(previously hidden by the early return).MetricRequirementsis static content — no context dependency — so this is benign. Worth knowing for future test additions.MetricsPage.test.tsx— test updated ✅screen.getByText('Intel GPU — Metrics')is present whenctxLoading=true. Directly verifies the fix.MetricRequirementsduring ctxLoading (minor gap, non-blocking for this PR).Edge cases checked
useEffect([ctxLoading, fetchSeq])fires whenctxLoadinggoes false, triggering fetch. This path is unchanged and still correct.ctxLoading=trueandfetching=true, only the ctxLoading loader shows (correct — fetch can't start until ctxLoading is false per the effect guard).MetricsPage.tsxand its test.Blockers before approval
action_required— no jobs executed, same workflow approval gate as previous PRs in this repo)Will return to formally approve once both are green.
QA Update — E2E Analysis (PRI-1016)
E2E status: FAILED — but the failure is NOT caused by changes in this PR.
Failure details
navigation between plugin views works(line 69)/node/imatched 2 headings:Intel GPU — Nodes(h1) andNo GPU Nodes Found(h2)maintoday — the broad selector/node/iwas already failing before this PR was createdWhy this PR cannot independently pass E2E
This PR only changes
MetricsPage.tsxandMetricsPage.test.tsx. The E2E spec (e2e/intel-gpu.spec.ts) inherited frommainhas the old broad selectors (/node/i,/pod/i,/metric/i) that are the pre-existing strict mode violations. PR #44 fixes those selectors.Circular dependency
MetricsPage.tsxso the metrics heading renders before timeoutRequired action
One of:
I cannot formally approve this PR until E2E passes. The code change itself is correct — I'm not requesting changes to the code.
Closing in favor of combined PR #45 which includes all three fixes.
Pull request closed