feat(ui): afficher les tags dans la liste des cartes
This commit is contained in:
1 parent
67569e2d16
commit
bf2c9ae4fb
2 files changed
+25
-1
No files matched your search
@@ -27,7 +27,7 @@ const CARDS = [
|
||||
question: 'Cest quoi un commit ?',
|
||||
response: 'Un snapshot du projet',
|
||||
theme: 'git',
|
||||
tags: [],
|
||||
tags: ['commit', 'repo'],
|
||||
createdAt: new Date('2026-01-01T08:00:00Z'),
|
||||
updatedAt: new Date('2026-01-01T08:00:00Z'),
|
||||
},
|
||||
@@ -68,6 +68,14 @@ it('affiche le thème de chaque carte', async () => {
|
||||
expect(within(item as HTMLElement).getByText('git')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('affiche les tags de chaque carte', async () => {
|
||||
vi.mocked(cardsApi.list).mockResolvedValue(CARDS)
|
||||
render(<CardList />)
|
||||
const item = (await screen.findByText('Cest quoi un commit ?')).closest('li')
|
||||
expect(within(item as HTMLElement).getByText('#commit')).toBeInTheDocument()
|
||||
expect(within(item as HTMLElement).getByText('#repo')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('affiche un message si aucune carte', async () => {
|
||||
vi.mocked(cardsApi.list).mockResolvedValue([])
|
||||
render(<CardList />)
|
||||
|
||||
@@ -8,6 +8,7 @@ interface ListedCard {
|
||||
id: string
|
||||
question: string
|
||||
theme: string
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
export function CardList() {
|
||||
@@ -25,6 +26,7 @@ export function CardList() {
|
||||
id: card.id,
|
||||
question: card.question,
|
||||
theme: card.theme,
|
||||
tags: card.tags,
|
||||
})),
|
||||
)
|
||||
}
|
||||
@@ -62,7 +64,21 @@ export function CardList() {
|
||||
href={`/cards/${card.id}`}
|
||||
className="flex items-center justify-between px-4 py-3 hover:bg-slate-50"
|
||||
>
|
||||
<span className="flex flex-col gap-1">
|
||||
<span className="font-medium">{card.question}</span>
|
||||
{card.tags.length > 0 && (
|
||||
<span className="flex flex-wrap gap-1.5">
|
||||
{card.tags.map((tag) => (
|
||||
<span
|
||||
key={tag}
|
||||
className="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-600"
|
||||
>
|
||||
#{tag}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-600">
|
||||
{card.theme}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user