feat(PBI-58): Vitest-tests voor SoloTaskCard veldmapping en 4-regels layout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bd7478861b
commit
27e820bcc7
1 changed files with 84 additions and 0 deletions
84
__tests__/components/solo/solo-task-card.test.tsx
Normal file
84
__tests__/components/solo/solo-task-card.test.tsx
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// @vitest-environment jsdom
|
||||
import '@testing-library/jest-dom'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import type { SoloTask } from '@/components/solo/solo-board'
|
||||
|
||||
vi.mock('@/components/ui/tooltip', () => ({
|
||||
TooltipProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
TooltipTrigger: ({ children }: { children?: React.ReactNode }) => <>{children}</>,
|
||||
TooltipContent: ({ children }: { children: React.ReactNode }) => <span data-testid="tooltip-content">{children}</span>,
|
||||
}))
|
||||
vi.mock('@dnd-kit/core', () => ({
|
||||
useDraggable: () => ({ attributes: {}, listeners: {}, setNodeRef: vi.fn(), transform: null, isDragging: false }),
|
||||
}))
|
||||
vi.mock('@/stores/solo-store', () => ({
|
||||
useSoloStore: () => null,
|
||||
}))
|
||||
vi.mock('@/components/shared/code-badge', () => ({
|
||||
CodeBadge: ({ code }: { code: string }) => <span data-testid="code-badge">{code}</span>,
|
||||
}))
|
||||
|
||||
import { SoloTaskCard, SoloTaskCardOverlay } from '@/components/solo/solo-task-card'
|
||||
|
||||
function makeSoloTask(overrides: Partial<SoloTask> = {}): SoloTask {
|
||||
return {
|
||||
id: 'task-1',
|
||||
title: 'Taak titel',
|
||||
description: 'Omschrijving van de taak die langer is dan tachtig tekens voor test',
|
||||
implementation_plan: null,
|
||||
priority: 2,
|
||||
sort_order: 0,
|
||||
status: 'TO_DO',
|
||||
verify_only: false,
|
||||
verify_required: 'ALIGNED',
|
||||
story_id: 'story-1',
|
||||
story_code: 'ST-1',
|
||||
story_title: 'Story titel',
|
||||
task_code: 'T-1',
|
||||
pbi_code: 'PBI-1',
|
||||
pbi_title: 'PBI titel',
|
||||
pbi_description: 'PBI omschrijving',
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
describe('SoloTaskCard', () => {
|
||||
it('toont taaknaam, task_code, pbi_code, story_code, story_title', () => {
|
||||
render(<SoloTaskCard task={makeSoloTask()} isDemo={false} onClick={vi.fn()} />)
|
||||
expect(screen.getAllByText('Taak titel').length).toBeGreaterThan(0)
|
||||
expect(screen.getAllByText('T-1').length).toBeGreaterThan(0)
|
||||
expect(screen.getAllByText('PBI-1').length).toBeGreaterThan(0)
|
||||
expect(screen.getByText('ST-1')).toBeInTheDocument()
|
||||
expect(screen.getByText('Story titel')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('verbergt pbi_code badge als pbi_code null is', () => {
|
||||
render(<SoloTaskCard task={makeSoloTask({ pbi_code: null })} isDemo={false} onClick={vi.fn()} />)
|
||||
const badges = screen.queryAllByTestId('code-badge')
|
||||
const codes = badges.map(b => b.textContent)
|
||||
expect(codes).not.toContain('PBI-1')
|
||||
})
|
||||
|
||||
it('verbergt description als description null is', () => {
|
||||
const task = makeSoloTask({ description: null })
|
||||
render(<SoloTaskCard task={task} isDemo={false} onClick={vi.fn()} />)
|
||||
expect(screen.queryByText(/Omschrijving/)).toBeNull()
|
||||
})
|
||||
|
||||
it('toont description als tekst', () => {
|
||||
render(<SoloTaskCard task={makeSoloTask()} isDemo={false} onClick={vi.fn()} />)
|
||||
expect(screen.getAllByText('Omschrijving van de taak die langer is dan tachtig tekens voor test').length).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('SoloTaskCardOverlay', () => {
|
||||
it('toont taaknaam en codes zonder tooltip-wrappers', () => {
|
||||
render(<SoloTaskCardOverlay task={makeSoloTask()} />)
|
||||
expect(screen.getByText('Taak titel')).toBeInTheDocument()
|
||||
expect(screen.getByText('T-1')).toBeInTheDocument()
|
||||
expect(screen.getByText('PBI-1')).toBeInTheDocument()
|
||||
expect(screen.queryAllByTestId('tooltip-content')).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue