fix: handle empty candidate trait lists

Return empty JSON arrays from the API and normalize nullable values from older servers before rendering candidate match counts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Daniel Noulet 2026-09-19 21:34:12 +02:00
parent 6969f79015
commit fd06fbbb5d
4 changed files with 36 additions and 3 deletions

View file

@ -69,7 +69,7 @@ function mockApi() {
participant,
score: 90,
matchedTraits: ['Go'],
missingTraits: [],
missingTraits: null,
},
])
if (path === '/api/jobs/7/invitations' && method === 'GET') return response([])
@ -129,6 +129,17 @@ describe('Go Guess frontend', () => {
mockApi()
})
it('renders candidate matches when an older API returns null trait arrays', async () => {
authenticate()
const user = userEvent.setup()
renderApp('/jobs/7')
await user.click(await screen.findByRole('tab', { name: /candidate match/i }))
expect(await screen.findByText('90%')).toBeInTheDocument()
expect(screen.getByText('Missing').nextElementSibling).toHaveTextContent('0')
})
it('persists login, navigates from the login URL, and shows API jobs', async () => {
const user = userEvent.setup()
window.history.replaceState({}, '', '/login')