import { describe, expect, it } from 'vitest';

import {
  createEmptyAgent,
  useAgentDesignerState,
} from './useAgentDesignerState';

describe('useAgentDesignerState generation stream', () => {
  it('defaults new and legacy agents to streaming', () => {
    expect(createEmptyAgent().generationConfigJson?.stream).toBe(true);

    const designer = useAgentDesignerState();
    designer.reset({ name: '旧智能体' });

    expect(designer.state.agent.generationConfigJson?.stream).toBe(true);
    expect(designer.buildPayloadAgent().generationConfigJson?.stream).toBe(
      true,
    );
  });

  it('preserves an explicitly disabled stream value in the payload', () => {
    const designer = useAgentDesignerState();
    designer.reset({
      name: '非流式智能体',
      generationConfigJson: { stream: false },
    });

    expect(designer.state.agent.generationConfigJson?.stream).toBe(false);
    expect(designer.buildPayloadAgent().generationConfigJson?.stream).toBe(
      false,
    );
  });
});
