Skip to content

Commit 35508b4

Browse files
nickmazziclaude
andcommitted
fix(automl+autorag): use Link instead of useNavigate for pipeline run link
Replace imperative useNavigate with declarative <Link> for the empty state CTA, improving accessibility (right-click, Cmd+click, screen readers). Fix test routes to include :runId param and verify href. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2c1f95f commit 35508b4

4 files changed

Lines changed: 32 additions & 20 deletions

File tree

packages/automl/frontend/src/app/components/run-results/AutomlLeaderboard.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
type ThProps,
2222
} from '@patternfly/react-table';
2323
import React from 'react';
24-
import { useNavigate, useParams } from 'react-router';
24+
import { Link, useParams } from 'react-router';
2525
import AutomlRunInProgress from '~/app/components/empty-states/AutomlRunInProgress';
2626
import { useAutomlResultsContext, type AutomlModel } from '~/app/context/AutomlResultsContext';
2727
import { RuntimeStateKF } from '~/app/types/pipeline';
@@ -51,7 +51,6 @@ function AutomlLeaderboard({
5151
onClickSaveNotebook,
5252
onRegisterModel,
5353
}: AutomlLeaderboardProps): React.JSX.Element | null {
54-
const navigate = useNavigate();
5554
const { namespace, runId } = useParams<{ namespace: string; runId: string }>();
5655
const { models, parameters, modelsLoading, pipelineRun, pipelineRunLoading } =
5756
useAutomlResultsContext();
@@ -303,12 +302,14 @@ function AutomlLeaderboard({
303302
>
304303
<EmptyStateBody>
305304
<span>
306-
The pipeline run completed but did not generate any models. Please check the{' '}
305+
The pipeline run completed but did not generate any models. Please check the&nbsp;
307306
</span>
308307
<Button
309308
variant="link"
310309
isInline
311-
onClick={() => navigate(`/develop-train/pipelines/runs/${namespace}/runs/${runId}`)}
310+
component={(props) => (
311+
<Link {...props} to={`/develop-train/pipelines/runs/${namespace}/runs/${runId}`} />
312+
)}
312313
>
313314
pipeline configuration and logs
314315
</Button>

packages/automl/frontend/src/app/components/run-results/__tests__/AutomlLeaderboard.spec.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ const renderWithContext = ({
204204
};
205205

206206
return render(
207-
<MemoryRouter initialEntries={[`/automl/${namespace}/results`]}>
207+
<MemoryRouter initialEntries={[`/automl/${namespace}/results/test-run-123`]}>
208208
<Routes>
209209
<Route
210-
path="/automl/:namespace/results"
210+
path="/automl/:namespace/results/:runId"
211211
element={
212212
<AutomlResultsContext.Provider value={contextValue}>
213213
<AutomlLeaderboard
@@ -374,10 +374,15 @@ describe('AutomlLeaderboard component', () => {
374374
expect(emptyState).toHaveTextContent(
375375
'The pipeline run completed but did not generate any models. Please check the pipeline configuration and logs.',
376376
);
377-
// Verify the interactive CTA button exists and is accessible
378-
expect(
379-
within(emptyState).getByRole('button', { name: /pipeline configuration and logs/i }),
380-
).toBeInTheDocument();
377+
// Verify the interactive CTA link exists and navigates to the pipeline run page
378+
const link = within(emptyState).getByRole('link', {
379+
name: /pipeline configuration and logs/i,
380+
});
381+
expect(link).toBeInTheDocument();
382+
expect(link).toHaveAttribute(
383+
'href',
384+
'/develop-train/pipelines/runs/test-namespace/runs/test-run-123',
385+
);
381386
});
382387

383388
it('should render loading skeleton with correct structure', () => {

packages/autorag/frontend/src/app/components/run-results/AutoragLeaderboard.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
type ThProps,
2222
} from '@patternfly/react-table';
2323
import React from 'react';
24-
import { useNavigate, useParams } from 'react-router';
24+
import { Link, useParams } from 'react-router';
2525
import AutoragRunInProgress from '~/app/components/empty-states/AutoragRunInProgress';
2626
import { useAutoragResultsContext } from '~/app/context/AutoragResultsContext';
2727
import type { AutoragPattern } from '~/app/types/autoragPattern';
@@ -68,7 +68,6 @@ function AutoragLeaderboard({
6868
onViewDetails,
6969
onSaveNotebook,
7070
}: AutoragLeaderboardProps): React.JSX.Element | null {
71-
const navigate = useNavigate();
7271
const { namespace, runId } = useParams<{ namespace: string; runId: string }>();
7372
const { patterns, patternsLoading, pipelineRun, pipelineRunLoading } = useAutoragResultsContext();
7473
const optimizedMetric = getOptimizedMetricForRAG(pipelineRun);
@@ -362,12 +361,14 @@ function AutoragLeaderboard({
362361
>
363362
<EmptyStateBody>
364363
<span>
365-
The pipeline run completed but did not generate any patterns. Please check the{' '}
364+
The pipeline run completed but did not generate any patterns. Please check the&nbsp;
366365
</span>
367366
<Button
368367
variant="link"
369368
isInline
370-
onClick={() => navigate(`/develop-train/pipelines/runs/${namespace}/runs/${runId}`)}
369+
component={(props) => (
370+
<Link {...props} to={`/develop-train/pipelines/runs/${namespace}/runs/${runId}`} />
371+
)}
371372
>
372373
pipeline configuration and logs
373374
</Button>

packages/autorag/frontend/src/app/components/run-results/__tests__/AutoragLeaderboard.spec.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ const renderWithContext = ({
227227
};
228228

229229
return render(
230-
<MemoryRouter initialEntries={[`/autorag/${namespace}/results`]}>
230+
<MemoryRouter initialEntries={[`/autorag/${namespace}/results/test-run-123`]}>
231231
<Routes>
232232
<Route
233-
path="/autorag/:namespace/results"
233+
path="/autorag/:namespace/results/:runId"
234234
element={
235235
<AutoragResultsContext.Provider value={contextValue}>
236236
<AutoragLeaderboard />
@@ -374,10 +374,15 @@ describe('AutoragLeaderboard component', () => {
374374
expect(emptyState).toHaveTextContent(
375375
'The pipeline run completed but did not generate any patterns. Please check the pipeline configuration and logs.',
376376
);
377-
// Verify the interactive CTA button exists and is accessible
378-
expect(
379-
within(emptyState).getByRole('button', { name: /pipeline configuration and logs/i }),
380-
).toBeInTheDocument();
377+
// Verify the interactive CTA link exists and navigates to the pipeline run page
378+
const link = within(emptyState).getByRole('link', {
379+
name: /pipeline configuration and logs/i,
380+
});
381+
expect(link).toBeInTheDocument();
382+
expect(link).toHaveAttribute(
383+
'href',
384+
'/develop-train/pipelines/runs/test-namespace/runs/test-run-123',
385+
);
381386
});
382387

383388
it('should render loading skeleton with correct structure', () => {

0 commit comments

Comments
 (0)