HH-789 / HH-793: align theme tokens and BrowserList contract (#16)

This commit is contained in:
2026-08-28 18:58:39 +08:00
parent 60eda8f39e
commit d57fa68866
3 changed files with 32 additions and 6 deletions
+25
View File
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { CoreAdminContext } from 'ra-core'
import { BrowserList } from './BrowserList'
import { theme } from './theme'
afterEach(cleanup)
@@ -21,6 +22,30 @@ function provider(overrides = {}) {
}
describe('BrowserList', () => {
it('uses the semantic design colors', () => {
expect(theme.palette.text.secondary).toBe('#475467')
expect(theme.palette.success.main).toBe('#067647')
expect(theme.palette.warning.main).toBe('#B54708')
expect(theme.palette.error.main).toBe('#B42318')
})
it('keeps CDP data in desktop and mobile views', async () => {
render(<CoreAdminContext dataProvider={provider()}><BrowserList /></CoreAdminContext>)
expect(await screen.findAllByText('http://account-a:9222')).toHaveLength(2)
expect(screen.getAllByText('CDP')).toHaveLength(3)
})
it('shows unknown states with their raw value as secondary evidence', async () => {
const unknownRuntime = { ...runtimes[0], state: 'dead' }
render(<CoreAdminContext dataProvider={provider({ getList: vi.fn().mockResolvedValue({ data: [unknownRuntime], total: 1 }) })}><BrowserList /></CoreAdminContext>)
expect(await screen.findAllByText('未知状态')).toHaveLength(2)
const rawStates = screen.getAllByText('dead')
expect(rawStates).toHaveLength(2)
expect(rawStates[0].className).toContain('MuiTypography-caption')
})
it('disables invalid lifecycle actions and sends explicit domain actions', async () => {
const dataProvider = provider()
render(<CoreAdminContext dataProvider={dataProvider}><BrowserList /></CoreAdminContext>)