Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { act, cleanup, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
|
|
import { AccountSuspensionBanner } from '@/components/feedback/AccountSuspensionBanner'
|
|
import { ACCOUNT_SUSPENSION_STORAGE_KEY, setAccountSuspended } from '@/lib/accountSuspension'
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
localStorage.clear()
|
|
})
|
|
|
|
describe('AccountSuspensionBanner', () => {
|
|
it('stays hidden for an active account', () => {
|
|
render(<AccountSuspensionBanner />)
|
|
|
|
expect(screen.queryByRole('alert')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('shows support guidance when suspension is persisted', () => {
|
|
localStorage.setItem(ACCOUNT_SUSPENSION_STORAGE_KEY, 'true')
|
|
render(<AccountSuspensionBanner />)
|
|
|
|
expect(screen.getByRole('alert')).toHaveTextContent('حساب کاربری شما مسدود شده است')
|
|
expect(screen.getByRole('link', { name: 'تماس با پشتیبانی' })).toHaveAttribute('href', '/contact')
|
|
})
|
|
|
|
it('reacts immediately when an API response reports suspension', () => {
|
|
render(<AccountSuspensionBanner />)
|
|
act(() => {
|
|
setAccountSuspended(true)
|
|
})
|
|
|
|
expect(screen.getByRole('alert')).toBeInTheDocument()
|
|
})
|
|
})
|