Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
32 lines
1005 B
TypeScript
32 lines
1005 B
TypeScript
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import ConsumerState from '@/components/feedback/ConsumerState'
|
|
|
|
afterEach(cleanup)
|
|
|
|
describe('ConsumerState', () => {
|
|
it('exposes an empty state as status', () => {
|
|
render(<ConsumerState title="موردی پیدا نشد" />)
|
|
|
|
expect(screen.getByRole('status')).toHaveTextContent('موردی پیدا نشد')
|
|
})
|
|
|
|
it('exposes an error and runs its retry action', () => {
|
|
const onAction = vi.fn()
|
|
|
|
render(
|
|
<ConsumerState
|
|
actionLabel="تلاش دوباره"
|
|
title="دریافت اطلاعات ناموفق بود"
|
|
variant="error"
|
|
onAction={onAction}
|
|
/>
|
|
)
|
|
|
|
expect(screen.getByRole('alert')).toHaveTextContent('دریافت اطلاعات ناموفق بود')
|
|
fireEvent.click(screen.getByRole('button', { name: 'تلاش دوباره' }))
|
|
expect(onAction).toHaveBeenCalledOnce()
|
|
})
|
|
})
|