From 216cf10d7d06812ba8fba38f6ff00f57392bcefd Mon Sep 17 00:00:00 2001 From: David Leonardi Date: Tue, 29 Sep 2026 23:17:22 +0200 Subject: [PATCH] fix: show stack footer only for multiple jobs --- .../components/job-list/job-stack.test.tsx | 28 ++- .../jobs/components/job-list/job-stack.tsx | 215 ++++++++---------- 2 files changed, 106 insertions(+), 137 deletions(-) diff --git a/src/features/jobs/components/job-list/job-stack.test.tsx b/src/features/jobs/components/job-list/job-stack.test.tsx index 73df740..0040463 100644 --- a/src/features/jobs/components/job-list/job-stack.test.tsx +++ b/src/features/jobs/components/job-list/job-stack.test.tsx @@ -73,7 +73,7 @@ describe('organization card stack', () => { expect(screen.getByRole('status')).not.toHaveTextContent('new jobs found'); }); - it('selects named jobs, mounts one card and links to the complete organization listing', () => { + it('selects named jobs and mounts one card without a duplicate organization link', () => { const { container } = renderStack(jobs); expect(screen.getAllByRole('tab')).toHaveLength(5); expect(screen.getByRole('button', { name: 'Previous job' })).toBeDisabled(); @@ -88,8 +88,8 @@ describe('organization card stack', () => { expect(screen.getByRole('heading')).toHaveTextContent('Engineer 4'); expect(screen.getByRole('button', { name: 'Next job' })).toBeDisabled(); expect( - screen.getByRole('link', { name: 'All jobs at Acme' }), - ).toHaveAttribute('href', '/o-acme~org-acme'); + screen.queryByRole('link', { name: 'All jobs at Acme' }), + ).not.toBeInTheDocument(); expect(container.querySelectorAll('article')).toHaveLength(1); }); @@ -185,15 +185,19 @@ describe('organization card stack', () => { expect(screen.getByRole('status')).toHaveTextContent('1 of 2'); }); - it('omits paging and decorative layers for one job while keeping the organization link', () => { - const { container } = renderStack([jobs[0]]); - expect(screen.queryByRole('navigation')).toBeNull(); - expect(screen.queryByRole('tablist')).toBeNull(); - expect(container.querySelector('div[aria-hidden="true"]')).toBeNull(); - expect( - screen.getByRole('link', { name: 'All jobs at Acme' }), - ).toBeVisible(); - }); + it.each(['run-1', null])( + 'omits the entire footer and layers for one job (import %s)', + (importRunId) => { + const { container } = renderStack([jobs[0]], [jobs[0]], importRunId); + expect(screen.queryByRole('status')).not.toBeInTheDocument(); + expect(screen.queryByRole('navigation')).toBeNull(); + expect(screen.queryByRole('tablist')).toBeNull(); + expect(container.querySelector('div[aria-hidden="true"]')).toBeNull(); + expect( + screen.queryByRole('link', { name: 'All jobs at Acme' }), + ).not.toBeInTheDocument(); + }, + ); it('swipes cards without intercepting vertical scrolling, title scrolling or controls', () => { renderStack(jobs); diff --git a/src/features/jobs/components/job-list/job-stack.tsx b/src/features/jobs/components/job-list/job-stack.tsx index 6ae4769..d6f4219 100644 --- a/src/features/jobs/components/job-list/job-stack.tsx +++ b/src/features/jobs/components/job-list/job-stack.tsx @@ -14,8 +14,8 @@ import { ChevronRightIcon, ArrowRightIcon, } from 'lucide-react'; -import { Button } from '@/components/ui/button'; import { LinkWithLoader } from '@/components/link-with-loader'; +import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import type { JobListItemSchema } from '@/features/jobs/schemas'; import type { JobStackTitle } from '@/features/jobs/job-stack'; @@ -61,7 +61,6 @@ export const JobStack = ({ jobs, jobTitles, importRunId }: JobStackProps) => { const panelId = useId(); const hasPager = jobTitles.length > 1; const navigationLabel = `Jobs at ${organization?.name ?? 'this organization'}`; - const allJobsLabel = `All jobs at ${organization?.name ?? 'this organization'}`; const layers = Math.min(3, jobTitles.length - 1); const duplicateTitles = useMemo(() => { const counts = new Map(); @@ -212,102 +211,94 @@ export const JobStack = ({ jobs, jobTitles, importRunId }: JobStackProps) => { if (event.pointerType === 'mouse' && event.button === 0) startSwipe(event.target as HTMLElement, event.clientX, event.clientY); }; - const footer = ( -
- {hasPager && ( - +
{ > {selected.title}, - {hasPager ? `${index + 1} of ${jobTitles.length}` : '1'}{' '} + {index + 1} of {jobTitles.length}{' '} - {importRunId - ? hasPager - ? 'new jobs found' - : 'new job found' - : hasPager - ? 'matching jobs' - : 'matching job'} + {importRunId ? 'new jobs found' : 'matching jobs'} - {organization && ( -
- -
- )}
- ); + ) : null; return (