admin/components/feedback/AccountSuspensionBanner.test.tsx
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

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()
})
})