fix(web): make plan transitions admission-safe

This commit is contained in:
fz
2026-07-24 16:55:04 +08:00
parent aed744dbbe
commit e90b3bc5a2
18 changed files with 214 additions and 61 deletions

View File

@@ -12,7 +12,7 @@ afterEach(cleanup)
function setup(over?: Partial<InputBarProps>) {
const props: InputBarProps = {
draft: 'hello', running: false, disabled: false, error: null,
draft: 'hello', running: false, submitting: false, disabled: false, error: null,
variant: 'composer',
onDraftChange: vi.fn(), onSend: vi.fn(), onStop: vi.fn(),
...over,
@@ -83,6 +83,15 @@ describe('running lock and primary button', () => {
expect(props.onSend).not.toHaveBeenCalled()
})
it('submission locks duplicate sends only until Host admission settles', () => {
const { textarea, button, props } = setup({ submitting: true })
expect(textarea.disabled).toBe(true)
expect(textarea.placeholder).toBe('正在发送…')
expect(button.disabled).toBe(true)
fireEvent.click(button)
expect(props.onSend).not.toHaveBeenCalled()
})
it('idle primary sends and disables on empty draft', () => {
const { button, props } = setup()
fireEvent.click(button)