feat(design): add IMS Admin primitives (Button, StatusTag, Checkbox, FilterChip, Segmented, Avatar, Drawer) and restyle Field, Card, Modal

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:28:34 +08:00
co-authored by Claude Haiku 4.5
parent 01343d732e
commit 2a5b9332c7
15 changed files with 417 additions and 248 deletions
+9 -31
View File
@@ -2,49 +2,27 @@ import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { Modal } from '@/components/ui/modal'
describe('Modal (Modernist dialog)', () => {
describe('Modal', () => {
it('renders nothing when closed', () => {
const { container } = render(
<Modal open={false} onClose={() => {}} title="T">
body
</Modal>,
)
const { container } = render(<Modal open={false} onClose={() => {}} title="T">body</Modal>)
expect(container.firstChild).toBeNull()
})
it('renders a dialog with title, body and footer on the surface fill', () => {
render(
<Modal open onClose={() => {}} title="Confirm" footer={<span>actions</span>}>
body text
</Modal>,
)
it('renders a 12px card dialog with the floating shadow and a 1px header rule', () => {
render(<Modal open onClose={() => {}} title="Confirm" footer={<span>actions</span>}>body text</Modal>)
const dialog = screen.getByRole('dialog')
expect(dialog).toBeTruthy()
expect(screen.getByText('Confirm')).toBeTruthy()
expect(screen.getByText('body text')).toBeTruthy()
expect(screen.getByText('actions')).toBeTruthy()
expect(dialog.innerHTML).toContain('bg-surface')
expect(dialog.innerHTML).toContain('shadow-lg')
})
it('has no rounded corners and uses a 2px title rule', () => {
render(
<Modal open onClose={() => {}} title="T">
x
</Modal>,
)
const html = screen.getByRole('dialog').innerHTML
expect(html).not.toMatch(/rounded/)
expect(html).toContain('border-b')
expect(dialog.innerHTML).toContain('rounded-xl')
expect(dialog.innerHTML).toContain('shadow-float')
expect(dialog.innerHTML).toContain('border-b border-rule')
expect(dialog.innerHTML).not.toContain('border-b-2')
})
it('closes from the X button and on Escape', () => {
const onClose = vi.fn()
render(
<Modal open onClose={onClose} title="T">
x
</Modal>,
)
render(<Modal open onClose={onClose} title="T">x</Modal>)
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
fireEvent.keyDown(document, { key: 'Escape' })
expect(onClose).toHaveBeenCalledTimes(2)