Merge remote-tracking branch 'origin/master' into feat/web-message-feedback-ui
Adapt to two contract changes master introduced: - The generated Remote face now wraps every business result in RemoteResult, folding carrier failures into an ok:false branch instead of rejecting. The controller reads that envelope at its three call sites and maps a carrier failure onto the same settled shape the controls already render; three specs cover the new branch. - Client packages split their tsconfig into host and client halves, and the host aggregate now compiles any test not named *.client.spec.*. Rename this package's specs to the client convention and drop the ../connection project reference, which pointed at a solution file that no longer carries the client sources. Keep master's mount loop with its rollback-on-failure in api-remotes and add messageFeedbackRemote to it.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// @vitest-environment jsdom
|
||||
import { cleanup, render } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { StateDotState } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
describe('StateDot', () => {
|
||||
it.each(['done', 'warning', 'ongoing', 'error'] as const)('renders state %s as data-state', (state) => {
|
||||
const { container } = render(<StateDot state={state} />)
|
||||
const dot = container.firstElementChild as HTMLElement
|
||||
expect(dot.dataset['state']).toBe(state)
|
||||
expect(dot.getAttribute('aria-hidden')).toBe('true')
|
||||
})
|
||||
|
||||
it('solid states are spans; ongoing is an svg pixel matrix', () => {
|
||||
const { container, rerender } = render(<StateDot state="done" />)
|
||||
expect(container.firstElementChild?.tagName).toBe('SPAN')
|
||||
rerender(<StateDot state="ongoing" />)
|
||||
const matrix = container.firstElementChild as SVGSVGElement
|
||||
expect(matrix.tagName).toBe('svg')
|
||||
const cells = matrix.querySelectorAll('rect')
|
||||
expect(cells).toHaveLength(8)
|
||||
// Chase phase: every cell carries its own negative animation delay.
|
||||
const delays = [...cells].map(cell => (cell).style.animationDelay)
|
||||
expect(new Set(delays).size).toBe(8)
|
||||
})
|
||||
|
||||
it('sizes via the size prop in both shapes', () => {
|
||||
const { container, rerender } = render(<StateDot state="done" size={12} />)
|
||||
const dot = container.firstElementChild as HTMLElement
|
||||
expect(dot.style.width).toBe('12px')
|
||||
expect(dot.style.height).toBe('12px')
|
||||
rerender(<StateDot state="ongoing" size={12} />)
|
||||
const ring = container.firstElementChild as SVGSVGElement
|
||||
expect(ring.getAttribute('width')).toBe('12')
|
||||
expect(ring.getAttribute('height')).toBe('12')
|
||||
})
|
||||
|
||||
it('rejects unknown states at the type level', () => {
|
||||
const bad = (state: StateDotState) => state
|
||||
// @ts-expect-error 'paused' is not one of the four states
|
||||
expect(bad('paused')).toBe('paused')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user